summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac12
-rw-r--r--examples/Makefile.am8
-rw-r--r--librabbitmq/Makefile.am8
-rw-r--r--librabbitmq/amqp.h2
-rw-r--r--librabbitmq/amqp_api.c6
-rw-r--r--librabbitmq/amqp_connection.c2
-rw-r--r--librabbitmq/amqp_private.h10
-rw-r--r--librabbitmq/unix/socket.c9
-rw-r--r--librabbitmq/windows/socket.c9
-rw-r--r--tests/Makefile.am8
10 files changed, 64 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index a7100a7..c7672a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,9 +15,9 @@ AM_PROG_LIBTOOL
dnl Header-file checks
AC_HEADER_STDC
-dnl Only use -Wall if we have gcc
if test "x$GCC" = "xyes"; then
- if test -z "`echo "$CFLAGS" | grep "\-Wall" 2> /dev/null`" ; then
+ dnl Only use -Wall if we have gcc
+ if ! echo "$CFLAGS" | grep "\-Wall" 2> /dev/null ; then
CFLAGS="$CFLAGS -Wall"
fi
fi
@@ -35,7 +35,15 @@ AS_IF([test "x$windows" = xyes],
[AC_DEFINE([WINDOWS], [1], [Define to 1 if on Windows.])]
)
+AM_CONDITIONAL(GCC, test "x$GCC" = xyes)
+
+# Detect how to declare inline functions. Because we will sometimes
+# use "-ansi -pedantic" with gcc, we need to make sure the result will
+# work in that context.
+orig_cflags="$CFLAGS"
+AS_IF([test "x$GCC" = "xyes"], [CFLAGS="$CFLAGS -ansi -pedantic"])
AC_C_INLINE
+CFLAGS="$orig_cflags"
dnl Decide which API abstraction layer to use
PLATFORM_DIR=unix
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 9655021..a15d38b 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -2,6 +2,14 @@ noinst_PROGRAMS = amqp_sendstring amqp_exchange_declare amqp_listen amqp_produce
amqp_unbind amqp_bind amqp_listenq
AM_CFLAGS = -I$(top_srcdir)/librabbitmq
+
+if GCC
+# Because we want to build under Microsoft's C compiler (for which
+# there is apparently no demand for C99 support), it's a good idea
+# to have gcc tell us when we stray from the old standard.
+AM_CFLAGS += -ansi -pedantic
+endif
+
AM_LDFLAGS = $(top_builddir)/librabbitmq/librabbitmq.la
noinst_HEADERS = example_utils.h
diff --git a/librabbitmq/Makefile.am b/librabbitmq/Makefile.am
index 7df78ba..06ade87 100644
--- a/librabbitmq/Makefile.am
+++ b/librabbitmq/Makefile.am
@@ -1,6 +1,14 @@
lib_LTLIBRARIES = librabbitmq.la
AM_CFLAGS = -I$(srcdir)/$(PLATFORM_DIR) -DBUILDING_LIBRABBITMQ
+
+if GCC
+# Because we want to build under Microsoft's C compiler (for which
+# there is apparently no demand for C99 support), it's a good idea
+# to have gcc tell us when we stray from the old standard.
+AM_CFLAGS += -ansi -pedantic
+endif
+
librabbitmq_la_SOURCES = amqp_mem.c amqp_table.c amqp_connection.c amqp_socket.c amqp_debug.c amqp_api.c $(PLATFORM_DIR)/socket.c
librabbitmq_la_LDFLAGS = -no-undefined
librabbitmq_la_LIBADD = $(EXTRA_LIBS)
diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h
index 297f745..c20f645 100644
--- a/librabbitmq/amqp.h
+++ b/librabbitmq/amqp.h
@@ -181,7 +181,7 @@ typedef enum {
AMQP_FIELD_KIND_TIMESTAMP = 'T',
AMQP_FIELD_KIND_TABLE = 'F',
AMQP_FIELD_KIND_VOID = 'V',
- AMQP_FIELD_KIND_BYTES = 'x',
+ AMQP_FIELD_KIND_BYTES = 'x'
} amqp_field_value_kind_t;
#define _AMQP_TEINIT(ke,ki,v) {.key = (ke), .value = {.kind = AMQP_FIELD_KIND_##ki, .value = {v}}}
diff --git a/librabbitmq/amqp_api.c b/librabbitmq/amqp_api.c
index 32253d1..d74f877 100644
--- a/librabbitmq/amqp_api.c
+++ b/librabbitmq/amqp_api.c
@@ -70,6 +70,12 @@ static const char *client_error_strings[ERROR_MAX] = {
"connection closed unexpectedly", /* ERROR_CONNECTION_CLOSED */
};
+/* strdup is not in ISO C90! */
+static inline char *strdup(const char *str)
+{
+ return strcpy(malloc(strlen(str) + 1),str);
+}
+
char *amqp_error_string(int err)
{
const char *str;
diff --git a/librabbitmq/amqp_connection.c b/librabbitmq/amqp_connection.c
index 8b9ace6..34d12f8 100644
--- a/librabbitmq/amqp_connection.c
+++ b/librabbitmq/amqp_connection.c
@@ -366,7 +366,7 @@ int amqp_send_frame(amqp_connection_state_t state,
/* For a body frame, rather than copying data around, we use
writev to compose the frame */
struct iovec iov[3];
- char frame_end_byte = AMQP_FRAME_END;
+ uint8_t frame_end_byte = AMQP_FRAME_END;
const amqp_bytes_t *body = &frame->payload.body_fragment;
amqp_e32(out_frame, 3, body->len);
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
index 61591e5..de2cd5c 100644
--- a/librabbitmq/amqp_private.h
+++ b/librabbitmq/amqp_private.h
@@ -104,7 +104,7 @@ typedef enum amqp_connection_state_enum_ {
CONNECTION_STATE_IDLE = 0,
CONNECTION_STATE_INITIAL,
CONNECTION_STATE_HEADER,
- CONNECTION_STATE_BODY,
+ CONNECTION_STATE_BODY
} amqp_connection_state_enum;
/* 7 bytes up front, then payload, then 1 byte footer */
@@ -202,8 +202,10 @@ static inline uint64_t func##ll(uint64_t val) \
union { \
uint64_t whole; \
uint32_t halves[2]; \
- } u = { val }; \
- uint32_t t = u.halves[0]; \
+ } u; \
+ uint32_t t; \
+ u.whole = val; \
+ t = u.halves[0]; \
u.halves[0] = func##l(u.halves[1]); \
u.halves[1] = func##l(t); \
return u.whole; \
@@ -212,7 +214,7 @@ static inline uint64_t func##ll(uint64_t val) \
DECLARE_XTOXLL(hton)
DECLARE_XTOXLL(ntoh)
-DECLARE_CODEC_BASE_TYPE(8,,)
+DECLARE_CODEC_BASE_TYPE(8, (uint8_t), (uint8_t))
DECLARE_CODEC_BASE_TYPE(16, htons, ntohs)
DECLARE_CODEC_BASE_TYPE(32, htonl, ntohl)
DECLARE_CODEC_BASE_TYPE(64, htonll, ntohll)
diff --git a/librabbitmq/unix/socket.c b/librabbitmq/unix/socket.c
index 9d37dfc..4f5368e 100644
--- a/librabbitmq/unix/socket.c
+++ b/librabbitmq/unix/socket.c
@@ -53,6 +53,7 @@
#include <fcntl.h>
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
#include "amqp.h"
#include "amqp_private.h"
@@ -77,7 +78,13 @@ int amqp_socket_socket(int domain, int type, int proto)
}
return s;
-}
+}
+
+/* strdup is not in ISO C90! */
+static inline char *strdup(const char *str)
+{
+ return strcpy(malloc(strlen(str) + 1),str);
+}
char *amqp_os_error_string(int err)
{
diff --git a/librabbitmq/windows/socket.c b/librabbitmq/windows/socket.c
index 3cc57ba..bef7b95 100644
--- a/librabbitmq/windows/socket.c
+++ b/librabbitmq/windows/socket.c
@@ -53,6 +53,7 @@
#include <windows.h>
#include <stdint.h>
+#include <stdlib.h>
#include "amqp.h"
#include "amqp_private.h"
@@ -67,13 +68,19 @@ int amqp_socket_init(void)
int res = WSAStartup(0x0202, &data);
if (res)
return -res;
-
+
called_wsastartup = 1;
}
return 0;
}
+/* strdup is not in ISO C90! */
+static inline char *strdup(const char *str)
+{
+ return strcpy(malloc(strlen(str) + 1),str);
+}
+
char *amqp_os_error_string(int err)
{
char *msg, *copy;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7c8a4fe..80afcfa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,12 @@
noinst_PROGRAMS = test_tables
AM_CFLAGS = -I$(top_srcdir)/librabbitmq -I$(top_srcdir)/librabbitmq/$(PLATFORM_DIR)
+
+if GCC
+# Because we want to build under Microsoft's C compiler (for which
+# there is apparently no demand for C99 support), it's a good idea
+# to have gcc tell us when we stray from the old standard.
+AM_CFLAGS += -ansi -pedantic
+endif
+
AM_LDFLAGS = $(top_builddir)/librabbitmq/librabbitmq.la