diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2017-02-14 23:51:48 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2017-02-14 23:51:48 +0200 |
| commit | 8fe0a3b672802ecbd75bdbcec4fed6a993f2af89 (patch) | |
| tree | 6d8522007d5e1be0b452baad275fa4e3d15ab4f1 | |
| parent | 7e0ff295f158e13b57462b00a24b79cc064b3e45 (diff) | |
| download | mqtt-8fe0a3b672802ecbd75bdbcec4fed6a993f2af89.tar.gz mqtt-8fe0a3b672802ecbd75bdbcec4fed6a993f2af89.zip | |
Include config.h initially with MQTT_INLINE definition
| -rw-r--r-- | src/client.c | 5 | ||||
| -rw-r--r-- | src/config.h | 10 | ||||
| -rw-r--r-- | src/deserialize.h | 2 | ||||
| -rw-r--r-- | src/log.h | 4 | ||||
| -rw-r--r-- | src/misc.h | 2 | ||||
| -rw-r--r-- | src/packet.c | 2 | ||||
| -rw-r--r-- | src/packet.h | 2 | ||||
| -rw-r--r-- | src/serialize.c | 2 | ||||
| -rw-r--r-- | src/serialize.h | 2 | ||||
| -rw-r--r-- | src/socket.h | 2 | ||||
| -rw-r--r-- | src/stream.h | 2 | ||||
| -rw-r--r-- | tools/amalgamate.py | 1 |
12 files changed, 31 insertions, 5 deletions
diff --git a/src/client.c b/src/client.c index 9002c0d..9fe9dee 100644 --- a/src/client.c +++ b/src/client.c @@ -1,3 +1,4 @@ +#include "config.h" #include "mqtt.h" #include "packet.h" #include "stream.h" @@ -94,7 +95,7 @@ static int MqttClientRecvPacket(MqttClient *client); static uint16_t MqttClientNextPacketId(MqttClient *client); static void MqttClientProcessMessageQueue(MqttClient *client); -static inline int MqttClientInflightMessageCount(MqttClient *client) +static MQTT_INLINE int MqttClientInflightMessageCount(MqttClient *client) { MqttPacket *packet; int queued = 0; @@ -455,7 +456,7 @@ int MqttClientUnsubscribe(MqttClient *client, const char *topicFilter) return MqttPacketId(packet); } -static inline int MqttClientOutMessagesLen(MqttClient *client) +static MQTT_INLINE int MqttClientOutMessagesLen(MqttClient *client) { MqttPacket *packet; int count = 0; diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..984e260 --- /dev/null +++ b/src/config.h @@ -0,0 +1,10 @@ +#ifndef MQTT_CONFIG_H +#define MQTT_CONFIG_H + +#if __STDC_VERSION__ < 199901L +#define MQTT_INLINE __inline +#else +#define MQTT_INLINE inline +#endif + +#endif diff --git a/src/deserialize.h b/src/deserialize.h index 826e42a..8c29b3d 100644 --- a/src/deserialize.h +++ b/src/deserialize.h @@ -1,6 +1,8 @@ #ifndef DESERIALIZE_H #define DESERIALIZE_H +#include "config.h" + typedef struct MqttPacket MqttPacket; typedef struct Stream Stream; @@ -1,6 +1,8 @@ #ifndef LOG_H #define LOG_H +#include "config.h" + #define LOG_LEVEL_DEBUG 0 #define LOG_LEVEL_INFO 1 #define LOG_LEVEL_WARNING 2 @@ -11,7 +13,7 @@ #else #include <stdio.h> #include <string.h> -static inline const char *log_basename(const char *s) +static MQTT_INLINE const char *log_basename(const char *s) { #if !defined(_WIN32) const char *p = strrchr(s, '/'); @@ -1,6 +1,8 @@ #ifndef MISC_H #define MISC_H +#include "config.h" + #include <stdint.h> #include <stdlib.h> diff --git a/src/packet.c b/src/packet.c index 84dd399..5de7d97 100644 --- a/src/packet.c +++ b/src/packet.c @@ -28,7 +28,7 @@ const char *MqttPacketName(int type) } } -static inline size_t MqttPacketStructSize(int type) +static MQTT_INLINE size_t MqttPacketStructSize(int type) { switch (type) { diff --git a/src/packet.h b/src/packet.h index 0d02498..4fe7b74 100644 --- a/src/packet.h +++ b/src/packet.h @@ -1,6 +1,8 @@ #ifndef PACKET_H #define PACKET_H +#include "config.h" + #include <stdlib.h> #include <stdint.h> #include <assert.h> diff --git a/src/serialize.c b/src/serialize.c index a4e4803..b6c8cbc 100644 --- a/src/serialize.c +++ b/src/serialize.c @@ -14,7 +14,7 @@ typedef int (*MqttPacketSerializeFunc)(const MqttPacket *packet, static const struct tagbstring MqttProtocolId = bsStatic("MQTT"); static const char MqttProtocolLevel = 0x04; -static inline size_t MqttStringLengthSerialized(const_bstring s) +static MQTT_INLINE size_t MqttStringLengthSerialized(const_bstring s) { return 2 + blength(s); } diff --git a/src/serialize.h b/src/serialize.h index ac8d38f..7eb988f 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1,6 +1,8 @@ #ifndef SERIALIZE_H #define SERIALIZE_H +#include "config.h" + typedef struct MqttPacket MqttPacket; typedef struct Stream Stream; diff --git a/src/socket.h b/src/socket.h index 344fbc5..ba90843 100644 --- a/src/socket.h +++ b/src/socket.h @@ -1,6 +1,8 @@ #ifndef SOCKET_H #define SOCKET_H +#include "config.h" + #include <stdlib.h> int SocketConnect(const char *host, short port); diff --git a/src/stream.h b/src/stream.h index 6a3732e..166233f 100644 --- a/src/stream.h +++ b/src/stream.h @@ -1,6 +1,8 @@ #ifndef STREAM_H #define STREAM_H +#include "config.h" + #include <stdlib.h> #include <stdint.h> diff --git a/tools/amalgamate.py b/tools/amalgamate.py index 3337823..03d2a14 100644 --- a/tools/amalgamate.py +++ b/tools/amalgamate.py @@ -7,6 +7,7 @@ this_dir = os.path.dirname(os.path.abspath(__file__)) src_dir = os.path.join(this_dir, '..', 'src') sources = ( + 'config.h', 'queue.h', 'log.h', 'misc.c', |
