aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.c5
-rw-r--r--src/config.h10
-rw-r--r--src/deserialize.h2
-rw-r--r--src/log.h4
-rw-r--r--src/misc.h2
-rw-r--r--src/packet.c2
-rw-r--r--src/packet.h2
-rw-r--r--src/serialize.c2
-rw-r--r--src/serialize.h2
-rw-r--r--src/socket.h2
-rw-r--r--src/stream.h2
-rw-r--r--tools/amalgamate.py1
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;
diff --git a/src/log.h b/src/log.h
index a9df317..c316b32 100644
--- a/src/log.h
+++ b/src/log.h
@@ -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, '/');
diff --git a/src/misc.h b/src/misc.h
index 133b7eb..8cea322 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -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',