summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
l---------[m---------]codegen1
-rw-r--r--librabbitmq/amqp_private.h48
2 files changed, 32 insertions, 17 deletions
diff --git a/codegen b/codegen
-Subproject 0a95a69f86cdc2b538f4c58241840563fe4ccf4
diff --git a/librabbitmq/amqp_private.h b/librabbitmq/amqp_private.h
index 77a8f39..cde2ebf 100644
--- a/librabbitmq/amqp_private.h
+++ b/librabbitmq/amqp_private.h
@@ -48,6 +48,20 @@
#include "amqp_framing.h"
#include <string.h>
+#ifndef _AMQP_INLINE
+# if defined(__llvm__)
+/* extern inline breaks on LLVM saying 'symbol not found'
+ * but the inline keyword is only treated as a "mild hint"
+ * to the LLVM optimizer anyway, so we'll just disable it.
+ */
+# define _AMQP_INLINE static
+# elif defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
+# define _AMQP_INLINE extern __inline
+# else
+# define _AMQP_INLINE __inline
+# endif
+#endif
+
#ifdef _WIN32
# ifndef WINVER
/* WINVER 0x0502 is WinXP SP2+, Windows Server 2003 SP1+
@@ -181,24 +195,24 @@ struct amqp_connection_state_t_ {
amqp_pool_t *amqp_get_or_create_channel_pool(amqp_connection_state_t connection, amqp_channel_t channel);
amqp_pool_t *amqp_get_channel_pool(amqp_connection_state_t state, amqp_channel_t channel);
-static inline amqp_boolean_t amqp_heartbeat_enabled(amqp_connection_state_t state)
+_AMQP_INLINE amqp_boolean_t amqp_heartbeat_enabled(amqp_connection_state_t state)
{
return (state->heartbeat > 0);
}
-static inline uint64_t amqp_calc_next_send_heartbeat(amqp_connection_state_t state, uint64_t cur)
+_AMQP_INLINE uint64_t amqp_calc_next_send_heartbeat(amqp_connection_state_t state, uint64_t cur)
{
return cur + ((uint64_t)state->heartbeat * AMQP_NS_PER_S);
}
-static inline uint64_t amqp_calc_next_recv_heartbeat(amqp_connection_state_t state, uint64_t cur)
+_AMQP_INLINE uint64_t amqp_calc_next_recv_heartbeat(amqp_connection_state_t state, uint64_t cur)
{
return cur + ((uint64_t)state->heartbeat * 2 * AMQP_NS_PER_S);
}
int amqp_try_recv(amqp_connection_state_t state, uint64_t current_time);
-static inline void *amqp_offset(void *data, size_t offset)
+_AMQP_INLINE void *amqp_offset(void *data, size_t offset)
{
return (char *)data + offset;
}
@@ -208,8 +222,8 @@ static inline void *amqp_offset(void *data, size_t offset)
#define DECLARE_CODEC_BASE_TYPE(bits, htonx, ntohx) \
\
- static inline void amqp_e##bits(void *data, size_t offset, \
- uint##bits##_t val) \
+ _AMQP_INLINE void amqp_e##bits(void *data, size_t offset, \
+ uint##bits##_t val) \
{ \
/* The AMQP data might be unaligned. So we encode and then copy the \
result into place. */ \
@@ -217,7 +231,7 @@ static inline void *amqp_offset(void *data, size_t offset)
memcpy(amqp_offset(data, offset), &res, bits/8); \
} \
\
- static inline uint##bits##_t amqp_d##bits(void *data, size_t offset) \
+ _AMQP_INLINE uint##bits##_t amqp_d##bits(void *data, size_t offset) \
{ \
/* The AMQP data might be unaligned. So we copy the source value \
into a variable and then decode it. */ \
@@ -226,8 +240,8 @@ static inline void *amqp_offset(void *data, size_t offset)
return ntohx(val); \
} \
\
- static inline int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \
- uint##bits##_t input) \
+ _AMQP_INLINE int amqp_encode_##bits(amqp_bytes_t encoded, size_t *offset, \
+ uint##bits##_t input) \
\
{ \
size_t o = *offset; \
@@ -240,8 +254,8 @@ static inline void *amqp_offset(void *data, size_t offset)
} \
} \
\
- static inline int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \
- uint##bits##_t *output) \
+ _AMQP_INLINE int amqp_decode_##bits(amqp_bytes_t encoded, size_t *offset, \
+ uint##bits##_t *output) \
\
{ \
size_t o = *offset; \
@@ -288,7 +302,7 @@ static inline void *amqp_offset(void *data, size_t offset)
#if defined(AMQP_LITTLE_ENDIAN)
#define DECLARE_XTOXLL(func) \
- static inline uint64_t func##ll(uint64_t val) \
+ _AMQP_INLINE uint64_t func##ll(uint64_t val) \
{ \
union { \
uint64_t whole; \
@@ -305,7 +319,7 @@ static inline void *amqp_offset(void *data, size_t offset)
#elif defined(AMQP_BIG_ENDIAN)
#define DECLARE_XTOXLL(func) \
- static inline uint64_t func##ll(uint64_t val) \
+ _AMQP_INLINE uint64_t func##ll(uint64_t val) \
{ \
union { \
uint64_t whole; \
@@ -331,8 +345,8 @@ DECLARE_CODEC_BASE_TYPE(16, htons, ntohs)
DECLARE_CODEC_BASE_TYPE(32, htonl, ntohl)
DECLARE_CODEC_BASE_TYPE(64, htonll, ntohll)
-static inline int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset,
- amqp_bytes_t input)
+_AMQP_INLINE int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset,
+ amqp_bytes_t input)
{
size_t o = *offset;
if ((*offset = o + input.len) <= encoded.len) {
@@ -343,8 +357,8 @@ static inline int amqp_encode_bytes(amqp_bytes_t encoded, size_t *offset,
}
}
-static inline int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset,
- amqp_bytes_t *output, size_t len)
+_AMQP_INLINE int amqp_decode_bytes(amqp_bytes_t encoded, size_t *offset,
+ amqp_bytes_t *output, size_t len)
{
size_t o = *offset;
if ((*offset = o + len) <= encoded.len) {