This repository has been archived by the owner on Feb 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
0001-fix-MinGW-and-OSX-builds.patch
169 lines (163 loc) · 5.24 KB
/
0001-fix-MinGW-and-OSX-builds.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b53745b..d8787d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,7 +37,7 @@ STRING(TIMESTAMP BUILD_TIMESTAMP UTC)
MESSAGE(STATUS "Timestamp is ${BUILD_TIMESTAMP}")
IF(WIN32)
- ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN -MD)
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN)
ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
ADD_DEFINITIONS(-DOSX)
ENDIF()
@@ -61,34 +61,6 @@ IF(PAHO_BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY(doc)
ENDIF()
-IF (PAHO_ENABLE_CPACK)
- ### packaging settings
- FILE(GLOB samples "src/samples/*.c")
- INSTALL(FILES ${samples} DESTINATION samples)
-
- SET(CPACK_PACKAGE_VENDOR "Eclipse Paho")
- SET(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C")
- INSTALL(FILES CONTRIBUTING.md epl-v10 edl-v10 README.md notice.html DESTINATION .)
-
- IF (WIN32)
- SET(CPACK_GENERATOR "ZIP")
- ELSEIF(PAHO_BUILD_DEB_PACKAGE)
- INSTALL(FILES CONTRIBUTING.md epl-v10 edl-v10 README.md notice.html DESTINATION .)
-
- SET(CPACK_GENERATOR "DEB")
- CONFIGURE_FILE(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in
- ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY)
- SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake)
- ADD_SUBDIRECTORY(debian)
- ELSE()
- SET(CPACK_GENERATOR "TGZ")
- ENDIF()
-ELSE()
- FILE(GLOB samples "src/samples/*.c")
- INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR})
-
-ENDIF()
-
SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b46eaca..399b37d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -55,7 +55,7 @@ SET(common_src
)
IF (WIN32)
- SET(LIBS_SYSTEM ws2_32)
+ SET(LIBS_SYSTEM ws2_32 rpcrt4 crypt32 wsock32)
ELSEIF (UNIX)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(LIBS_SYSTEM c dl pthread)
diff --git a/src/MQTTAsync.c b/src/MQTTAsync.c
index a5813b4..4f209ec 100644
--- a/src/MQTTAsync.c
+++ b/src/MQTTAsync.c
@@ -205,6 +205,14 @@ START_TIME_TYPE MQTTAsync_start_clock(void)
clock_gettime(CLOCK_MONOTONIC, &start);
return start;
}
+#elif defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+#define START_TIME_TYPE struct timeval
+START_TIME_TYPE MQTTAsync_start_clock(void)
+{
+ static struct timeval start;
+ gettimeofday(&start, NULL);
+ return start;
+}
#else
#define START_TIME_TYPE struct timeval
START_TIME_TYPE MQTTAsync_start_clock(void)
@@ -235,6 +243,16 @@ long MQTTAsync_elapsed(struct timespec start)
ntimersub(now, start, res);
return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
}
+#elif defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+
+long MQTTAsync_elapsed(struct timeval start)
+{
+ struct timeval now, res;
+
+ gettimeofday(&now, NULL);
+ timersub(&now, &start, &res);
+ return (res.tv_sec)*1000 + (res.tv_usec)/1000;
+}
#else
long MQTTAsync_elapsed(struct timeval start)
{
diff --git a/src/MQTTClient.c b/src/MQTTClient.c
index 2069ff9..faee1ae 100644
--- a/src/MQTTClient.c
+++ b/src/MQTTClient.c
@@ -258,6 +258,14 @@ START_TIME_TYPE MQTTClient_start_clock(void)
clock_gettime(CLOCK_MONOTONIC, &start);
return start;
}
+#elif defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+#define START_TIME_TYPE struct timeval
+START_TIME_TYPE MQTTClient_start_clock(void)
+{
+ static struct timeval start;
+ gettimeofday(&start, NULL);
+ return start;
+}
#else
#define START_TIME_TYPE struct timeval
START_TIME_TYPE MQTTClient_start_clock(void)
@@ -288,6 +296,15 @@ long MQTTClient_elapsed(struct timespec start)
ntimersub(now, start, res);
return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
}
+#elif defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+long MQTTClient_elapsed(struct timeval start)
+{
+ struct timeval now, res;
+
+ gettimeofday(&now, NULL);
+ timersub(&now, &start, &res);
+ return (res.tv_sec)*1000 + (res.tv_usec)/1000;
+}
#else
long MQTTClient_elapsed(struct timeval start)
{
diff --git a/src/Thread.c b/src/Thread.c
index 4cb2f16..40ce8dc 100644
--- a/src/Thread.c
+++ b/src/Thread.c
@@ -409,9 +409,16 @@ int Thread_wait_cond(cond_type condvar, int timeout)
struct timespec cond_timeout;
FUNC_ENTRY;
+#if defined(__APPLE__) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+ struct timeval cur_time;
+ gettimeofday(&cur_time, NULL);
+ cond_timeout.tv_sec = cur_time.tv_sec + timeout;
+ cond_timeout.tv_nsec = cur_time.tv_usec * 1000;
+#else
clock_gettime(CLOCK_REALTIME, &cond_timeout);
cond_timeout.tv_sec += timeout;
+#endif
pthread_mutex_lock(&condvar->mutex);
rc = pthread_cond_timedwait(&condvar->cond, &condvar->mutex, &cond_timeout);
pthread_mutex_unlock(&condvar->mutex);
diff --git a/src/WebSocket.c b/src/WebSocket.c
index 47b1dad..3f96dac 100644
--- a/src/WebSocket.c
+++ b/src/WebSocket.c
@@ -28,6 +28,11 @@
#include "MQTTProtocolOut.h"
#include "StackTrace.h"
+#ifdef __MINGW32__
+#define htonll __builtin_bswap64
+#define ntohll __builtin_bswap64
+#endif
+
#if defined(__linux__)
# include <endian.h>
#elif defined(__APPLE__)