projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix comdat emitting on macho
[libfirm]
/
ir
/
lpp
/
lpp_comm.c
diff --git
a/ir/lpp/lpp_comm.c
b/ir/lpp/lpp_comm.c
index
616b643
..
8d307e8
100644
(file)
--- a/
ir/lpp/lpp_comm.c
+++ b/
ir/lpp/lpp_comm.c
@@
-33,6
+33,8
@@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
#else
#include <unistd.h>
#include <sys/types.h>
#else
#include <unistd.h>
#include <sys/types.h>
@@
-40,7
+42,8
@@
#include <arpa/inet.h>
#endif
#include <arpa/inet.h>
#endif
-#include "irtools.h"
+#include "xmalloc.h"
+#include "util.h"
#include "debug.h"
#include "lpp_comm.h"
#include "debug.h"
#include "lpp_comm.h"
@@
-55,6
+58,7
@@
struct _lpp_comm_t {
char *r_buf;
};
char *r_buf;
};
+#ifdef DEBUG_libfirm
static inline firm_dbg_module_t *get_dbg_module(void)
{
static firm_dbg_module_t *dbg = NULL;
static inline firm_dbg_module_t *get_dbg_module(void)
{
static firm_dbg_module_t *dbg = NULL;
@@
-64,8
+68,8
@@
static inline firm_dbg_module_t *get_dbg_module(void)
return dbg;
}
return dbg;
}
-
#define dbg get_dbg_module()
#define dbg get_dbg_module()
+#endif
/**
* Try to read some bytes but block until a certain amount is read.
/**
* Try to read some bytes but block until a certain amount is read.
@@
-79,7
+83,7
@@
static ssize_t secure_recv(int fd, void *buf, size_t try_amount, size_t at_least
{
ssize_t res;
size_t bytes_read = 0;
{
ssize_t res;
size_t bytes_read = 0;
- char *data = buf;
+ char *data =
(char*)
buf;
do {
res = recv(fd, &data[bytes_read], try_amount - bytes_read, 0);
do {
res = recv(fd, &data[bytes_read], try_amount - bytes_read, 0);
@@
-100,7
+104,7
@@
static ssize_t secure_send(int fd, const void *buf, size_t n)
{
ssize_t res;
size_t bytes_written = 0;
{
ssize_t res;
size_t bytes_written = 0;
- const char *data = buf;
+ const char *data =
(const char*)
buf;
do {
res = send(fd, &data[bytes_written], n - bytes_written, 0);
do {
res = send(fd, &data[bytes_written], n - bytes_written, 0);
@@
-117,7
+121,7
@@
static ssize_t secure_send(int fd, const void *buf, size_t n)
return n;
}
return n;
}
-s
size_t lpp_flush
(lpp_comm_t *comm)
+s
tatic ssize_t lpp_flush_
(lpp_comm_t *comm)
{
ssize_t res = 0;
if(comm->w_pos - comm->w_buf > 0) {
{
ssize_t res = 0;
if(comm->w_pos - comm->w_buf > 0) {
@@
-131,6
+135,11
@@
ssize_t lpp_flush(lpp_comm_t *comm)
return res;
}
return res;
}
+void lpp_flush(lpp_comm_t *comm)
+{
+ lpp_flush_(comm);
+}
+
static ssize_t lpp_write(lpp_comm_t *comm, const void *buf, size_t len)
{
assert(comm->w_pos - comm->w_buf >= 0);
static ssize_t lpp_write(lpp_comm_t *comm, const void *buf, size_t len)
{
assert(comm->w_pos - comm->w_buf >= 0);
@@
-140,7
+149,7
@@
static ssize_t lpp_write(lpp_comm_t *comm, const void *buf, size_t len)
size_t free = (comm->w_buf + comm->buf_size) - comm->w_pos;
size_t copy = MIN(free, len);
size_t rest = len - copy;
size_t free = (comm->w_buf + comm->buf_size) - comm->w_pos;
size_t copy = MIN(free, len);
size_t rest = len - copy;
- const char *pos
=
buf;
+ const char *pos
= (const char*)
buf;
DBG((dbg, LEVEL_1, "\tfree = %d, copy = %d, rest = %d\n", free, copy, rest));
if(copy > 0) {
DBG((dbg, LEVEL_1, "\tfree = %d, copy = %d, rest = %d\n", free, copy, rest));
if(copy > 0) {
@@
-158,7
+167,7
@@
static ssize_t lpp_write(lpp_comm_t *comm, const void *buf, size_t len)
size_t n_direct = rest / comm->buf_size;
size_t last_rest;
size_t n_direct = rest / comm->buf_size;
size_t last_rest;
- if(lpp_flush(comm) < 0)
+ if(lpp_flush
_
(comm) < 0)
return -1;
for(i = 0; i < n_direct; ++i) {
return -1;
for(i = 0; i < n_direct; ++i) {
@@
-189,7
+198,7
@@
static ssize_t lpp_read(lpp_comm_t *comm, void *buf, size_t len)
size_t left = comm->r_max - comm->r_pos;
size_t copy = MIN(left, len);
size_t rest = len - copy;
size_t left = comm->r_max - comm->r_pos;
size_t copy = MIN(left, len);
size_t rest = len - copy;
- char *pos
=
buf;
+ char *pos
= (char*)
buf;
DBG((dbg, LEVEL_1, "\tleft = %d, copy = %d, rest = %d\n", left, copy, rest));
if(copy > 0) {
DBG((dbg, LEVEL_1, "\tleft = %d, copy = %d, rest = %d\n", left, copy, rest));
if(copy > 0) {
@@
-243,12
+252,12
@@
static ssize_t lpp_read(lpp_comm_t *comm, void *buf, size_t len)
lpp_comm_t *lpp_comm_new(int fd, size_t buf_size)
{
lpp_comm_t *lpp_comm_new(int fd, size_t buf_size)
{
- lpp_comm_t *res =
malloc(sizeof(res[0])
);
+ lpp_comm_t *res =
XMALLOCZ(lpp_comm_t
);
res->fd = fd;
res->fd = fd;
- res->w_buf =
malloc(
buf_size);
+ res->w_buf =
XMALLOCN(char,
buf_size);
res->w_pos = res->w_buf;
res->w_pos = res->w_buf;
- res->r_buf =
malloc(
buf_size);
+ res->r_buf =
XMALLOCN(char,
buf_size);
res->r_pos = res->r_buf;
res->r_max = res->r_buf;
res->buf_size = buf_size;
res->r_pos = res->r_buf;
res->r_max = res->r_buf;
res->buf_size = buf_size;
@@
-332,7
+341,7
@@
double lpp_readd(lpp_comm_t *comm)
char *lpp_reads(lpp_comm_t *comm)
{
size_t len = lpp_readl(comm);
char *lpp_reads(lpp_comm_t *comm)
{
size_t len = lpp_readl(comm);
- char *res =
malloc(sizeof(char) * (len + 1)
);
+ char *res =
XMALLOCN(char, len+1
);
ERRNO_CHECK(lpp_read(comm, res, len), !=, (ssize_t) len);
res[len] = '\0';
ERRNO_CHECK(lpp_read(comm, res, len), !=, (ssize_t) len);
res[len] = '\0';