From a4360ad1c1ce12cf7258bdb564e28d26859e3729 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 13 Jul 2012 22:02:50 +0200 Subject: [PATCH] adapt to -std=c99 --- include/libfirm/adt/xmalloc.h | 3 +++ ir/be/beprefalloc.c | 4 ++-- ir/be/bespillbelady.c | 2 +- ir/lpp/lpp_comm.c | 11 +++++++++-- ir/lpp/lpp_comm.h | 7 +------ ir/lpp/lpp_net.c | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/libfirm/adt/xmalloc.h b/include/libfirm/adt/xmalloc.h index b07d0b7a2..a4cfaa7bd 100644 --- a/include/libfirm/adt/xmalloc.h +++ b/include/libfirm/adt/xmalloc.h @@ -35,6 +35,9 @@ #ifdef _WIN32 #include #endif +#if defined(__linux__) || defined(__APPLE__) +#include +#endif #include "../begin.h" diff --git a/ir/be/beprefalloc.c b/ir/be/beprefalloc.c index 93a771c2a..3740ff797 100644 --- a/ir/be/beprefalloc.c +++ b/ir/be/beprefalloc.c @@ -119,7 +119,7 @@ struct allocation_info_t { unsigned last_uses[2]; /**< bitset indicating last uses (input pos) */ ir_node *current_value; /**< copy of the value that should be used */ ir_node *original_value; /**< for copies point to original value */ - float prefs[0]; /**< register preferences */ + float prefs[]; /**< register preferences */ }; typedef struct allocation_info_t allocation_info_t; @@ -133,7 +133,7 @@ typedef struct reg_pref_t reg_pref_t; /** per basic-block information */ struct block_info_t { bool processed; /**< indicate whether block is processed */ - ir_node *assignments[0]; /**< register assignments at end of block */ + ir_node *assignments[]; /**< register assignments at end of block */ }; typedef struct block_info_t block_info_t; diff --git a/ir/be/bespillbelady.c b/ir/be/bespillbelady.c index 360aa58ee..e14db568c 100644 --- a/ir/be/bespillbelady.c +++ b/ir/be/bespillbelady.c @@ -78,7 +78,7 @@ typedef struct loc_t { typedef struct workset_t { unsigned len; /**< current length */ - loc_t vals[0]; /**< array of the values/distances in this working set */ + loc_t vals[]; /**< array of the values/distances in this working set */ } workset_t; static struct obstack obst; diff --git a/ir/lpp/lpp_comm.c b/ir/lpp/lpp_comm.c index bcfa974c9..8d307e88b 100644 --- a/ir/lpp/lpp_comm.c +++ b/ir/lpp/lpp_comm.c @@ -33,6 +33,8 @@ #define WIN32_LEAN_AND_MEAN #include #include +#include +typedef SSIZE_T ssize_t; #else #include #include @@ -119,7 +121,7 @@ static ssize_t secure_send(int fd, const void *buf, size_t n) return n; } -ssize_t lpp_flush(lpp_comm_t *comm) +static ssize_t lpp_flush_(lpp_comm_t *comm) { ssize_t res = 0; if(comm->w_pos - comm->w_buf > 0) { @@ -133,6 +135,11 @@ ssize_t lpp_flush(lpp_comm_t *comm) 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); @@ -160,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; - if(lpp_flush(comm) < 0) + if(lpp_flush_(comm) < 0) return -1; for(i = 0; i < n_direct; ++i) { diff --git a/ir/lpp/lpp_comm.h b/ir/lpp/lpp_comm.h index e087e8e2e..193d0043b 100644 --- a/ir/lpp/lpp_comm.h +++ b/ir/lpp/lpp_comm.h @@ -28,11 +28,6 @@ #include #include -#ifdef _WIN32 -#include -typedef SSIZE_T ssize_t; -#endif - #define LPP_PORT 2175 #define LPP_BUFSIZE (1 << 20) @@ -95,7 +90,7 @@ lpp_comm_t *lpp_comm_new(int fd, size_t buf_size); int lpp_comm_fileno(const lpp_comm_t *comm); -ssize_t lpp_flush(lpp_comm_t *comm); +void lpp_flush(lpp_comm_t *comm); void lpp_comm_free(lpp_comm_t *comm); diff --git a/ir/lpp/lpp_net.c b/ir/lpp/lpp_net.c index c8799a60d..7ef72858f 100644 --- a/ir/lpp/lpp_net.c +++ b/ir/lpp/lpp_net.c @@ -110,7 +110,7 @@ static int connect_tcp(const char *host, uint16_t port) sin.sin_port = htons(port); if ((phe = gethostbyname(host))) - memcpy(&sin.sin_addr, phe->h_addr, phe->h_length); + memcpy(&sin.sin_addr, phe->h_addr_list[0], phe->h_length); else if((sin.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) { lpp_print_err("cannot get host entry for %s", host); return -1; -- 2.20.1