aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/anyrpc/mingw.patch
blob: e2a8e5428b685bad024c1401d933431e96286ad7 (plain)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
diff --color -ur a/cmake/FindLog4cplus.cmake b/cmake/FindLog4cplus.cmake
--- a/cmake/FindLog4cplus.cmake	2020-01-13 18:31:55.000000000 +0100
+++ b/cmake/FindLog4cplus.cmake	2022-07-19 19:35:41.701935383 +0200
@@ -61,12 +61,12 @@
 
 endif ()
 
+# needed to use find_package_handle_standard_args
+include(FindPackageHandleStandardArgs)
+
 if (LOG4CPLUS_INCLUDE_DIR)
 	# set the correct variable name for the header directories         
 	set(LOG4CPLUS_INCLUDE_DIRS ${LOG4CPLUS_INCLUDE_DIR})
-
-	# needed to use find_package_handle_standard_args
-	include(FindPackageHandleStandardArgs)
 	
     if (LOG4CPLUS_LIBRARY_RELEASE AND LOG4CPLUS_LIBRARY_DEBUG)
     	# set the libaries varible to use the release and debug versions
diff --color -ur a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake
--- a/cmake/FindMsgpack.cmake	2020-01-13 18:31:55.000000000 +0100
+++ b/cmake/FindMsgpack.cmake	2022-07-19 19:35:41.702935385 +0200
@@ -61,13 +61,13 @@
 
 endif ()
 
+# needed to use find_package_handle_standard_args
+include(FindPackageHandleStandardArgs)
+	
 if (MSGPACK_INCLUDE_DIR)
 	# set the correct variable name for the header directories         
 	set(MSGPACK_INCLUDE_DIRS ${MSGPACK_INCLUDE_DIR})
 
-	# needed to use find_package_handle_standard_args
-	include(FindPackageHandleStandardArgs)
-	
     if (MSGPACK_LIBRARY_RELEASE AND MSGPACK_LIBRARY_DEBUG)
     	# set the libaries varible to use the release and debug versions
     	find_package_handle_standard_args(MSGPACK DEFAULT_MSG MSGPACK_INCLUDE_DIR MSGPACK_LIBRARY_RELEASE MSGPACK_LIBRARY_DEBUG)
diff --color -ur a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt	2020-01-13 18:31:55.000000000 +0100
+++ b/CMakeLists.txt	2022-07-19 19:36:01.112980511 +0200
@@ -63,6 +63,7 @@
     set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" )
 elseif (MINGW)
     SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -U__STRICT_ANSI__" )
+    add_definitions( -D _POSIX_THREAD_SAFE_FUNCTIONS )
 elseif (BUILD_WITH_ADDRESS_SANITIZE)
     SET( CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
     SET( ASAN_LIBRARY asan )
diff --color -ur a/example/CMakeLists.txt b/example/CMakeLists.txt
--- a/example/CMakeLists.txt	2020-01-13 18:31:55.000000000 +0100
+++ b/example/CMakeLists.txt	2022-07-19 19:35:41.696935371 +0200
@@ -48,5 +48,13 @@
 
     # Add the necessary external library references
     target_link_libraries( ${SOURCEFILE} anyrpc ${ASAN_LIBRARY} ${LOG4CPLUS_LIBRARIES} ${MSGPACK_LIBRARIES})
+    
+    if (WIN32)
+        target_compile_definitions(${SOURCEFILE}
+            PRIVATE
+                WINVER=0x0A00
+                _WIN32_WINNT=0x0A00
+        )
+    endif ()
 endforeach ()
 
diff --color -ur a/include/anyrpc/connection.h b/include/anyrpc/connection.h
--- a/include/anyrpc/connection.h	2020-01-13 18:31:55.000000000 +0100
+++ b/include/anyrpc/connection.h	2022-07-19 19:35:41.698935376 +0200
@@ -22,11 +22,7 @@
 #define ANYRPC_CONNECTION_H_
 
 #if defined(ANYRPC_THREADING)
-# if defined(__MINGW32__)
-#  include "internal/mingw.thread.h"
-# else
-#  include <thread>
-# endif // defined(__MINGW32__)
+# include <thread>
 #endif // defined(ANYRPC_THREADING)
 
 #if defined(ANYRPC_REGEX)
diff --color -ur a/include/anyrpc/internal/time.h b/include/anyrpc/internal/time.h
--- a/include/anyrpc/internal/time.h	2020-01-13 18:31:55.000000000 +0100
+++ b/include/anyrpc/internal/time.h	2022-07-19 19:35:41.698935376 +0200
@@ -32,10 +32,6 @@
 int gettimeofday(struct timeval * tp, struct timezone * tzp);
 #endif
 
-#if defined(__MINGW32__)
-struct tm* localtime_r(const time_t *timep, struct tm *result);
-#endif
-
 //! Compute the difference between the two times in milliseconds
 ANYRPC_API int MilliTimeDiff(struct timeval &time1, struct timeval &time2);
 
diff --color -ur a/include/anyrpc/server.h b/include/anyrpc/server.h
--- a/include/anyrpc/server.h	2020-01-13 18:31:55.000000000 +0100
+++ b/include/anyrpc/server.h	2022-07-19 19:35:41.699935378 +0200
@@ -22,24 +22,9 @@
 #define ANYRPC_SERVER_H_
 
 #if defined(ANYRPC_THREADING)
-# if defined(__MINGW32__)
-// These constants are not defined for mingw but are needed in the following libraries
-#  ifndef EOWNERDEAD
-#   define EOWNERDEAD       133    /* File too big */
-#  endif
-#  ifndef EPROTO
-#   define EPROTO    134    /* Protocol error */
-#  endif
-
-#  include "internal/mingw.thread.h"
-#  include <mutex>
-#  include "internal/mingw.mutex.h"
-#  include "internal/mingw.condition_variable.h"
-# else
-#  include <thread>
-#  include <condition_variable>
-#  include <mutex>
-# endif //defined(__MINGW32__)
+# include <thread>
+# include <condition_variable>
+# include <mutex>
 #endif //defined(ANYRPC_THREADING)
 
 namespace anyrpc
diff --color -ur a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt	2020-01-13 18:31:55.000000000 +0100
+++ b/src/CMakeLists.txt	2022-07-19 19:35:41.697935374 +0200
@@ -57,6 +57,12 @@
 # Need the winsock library for Windows
 if (WIN32)
     target_link_libraries(anyrpc ws2_32)
+
+    target_compile_definitions(anyrpc 
+        PRIVATE
+            WINVER=0x0A00
+            _WIN32_WINNT=0x0A00
+    )
 endif ()
 
 set_target_properties( anyrpc PROPERTIES VERSION ${ANYRPC_VERSION} SOVERSION ${ANYRPC_VERSION_MAJOR} )
diff --color -ur a/src/internal/time.cpp b/src/internal/time.cpp
--- a/src/internal/time.cpp	2020-01-13 18:31:55.000000000 +0100
+++ b/src/internal/time.cpp	2022-07-19 19:35:41.699935378 +0200
@@ -26,11 +26,8 @@
 #include <chrono>
 #endif
 
-#if defined(_MSC_VER)
-#elif defined(__MINGW32__)
-#include <unistd.h>
-#else
-#include <time.h>
+#if !defined(_MSC_VER)
+# include <time.h>
 #endif
 
 namespace anyrpc
@@ -57,16 +54,6 @@
 }
 #endif
 
-#if defined(__MINGW32__)
-struct tm* localtime_r(const time_t *timep, struct tm *result)
-{
-	// with Windows localtime is threadsafe since the pointer is to thread local storage
-	struct tm *t=localtime(timep);
-	memcpy(result,t,sizeof(struct tm));
-	return result;
-}
-#endif
-
 int MilliTimeDiff( struct timeval &time1, struct timeval &time2 )
 {
     return (time1.tv_sec - time2.tv_sec) * 1000 + (time1.tv_usec - time2.tv_usec)/1000;
diff --color -ur a/src/socket.cpp b/src/socket.cpp
--- a/src/socket.cpp	2020-01-13 18:31:55.000000000 +0100
+++ b/src/socket.cpp	2022-07-19 19:35:41.701935383 +0200
@@ -98,7 +98,7 @@
 int Socket::SetKeepAliveInterval(int startTime, int interval, int probeCount)
 {
     log_debug( "SetKeepAliveInterval: startTime=" << startTime << ", interval=" << interval << ", probeCount=" << probeCount);
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__MINGW32__)
     DWORD outBytes;
     tcp_keepalive tcp_ka;
     tcp_ka.onoff = 1;
@@ -109,7 +109,7 @@
     if (result < 0)
         log_debug( "SetKeepAliveInterval: result = " << result );
     return result;
-#elif defined(__MINGW32__) || defined(__CYGWIN__)
+#elif defined(__CYGWIN__)
     // don't see how this can be performed right now
 #elif (__APPLE__)
     int result = setsockopt( fd_, IPPROTO_TCP, TCP_KEEPALIVE, (char*)&startTime, sizeof(startTime) );
@@ -554,15 +554,11 @@
 
     port = ntohs(receiveAddr.sin_port);
 
-#if defined(__MINGW32__)
-    // should be thread-safe since it would use the Windows call
-    ipAddress = inet_ntoa(receiveAddr.sin_addr);
-#else
     // Only need this buffer to perform the address conversion in a thread-safe call
     const unsigned bufferLength = 100;
     char addrBuffer[bufferLength];
     ipAddress = inet_ntop(AF_INET,&receiveAddr.sin_addr, addrBuffer, bufferLength);
-#endif
+
     log_debug("Udp Receive: address=" << ipAddress << ", port=" << port);
 
     eof = (numBytes == 0);