Browse Source

Modified Civetweb patch from Josh Engebretson. Related to #1588.

Lasse Öörni 9 years ago
parent
commit
c1ad7ea5b7
1 changed files with 13 additions and 2 deletions
  1. 13 2
      Source/ThirdParty/Civetweb/src/civetweb.c

+ 13 - 2
Source/ThirdParty/Civetweb/src/civetweb.c

@@ -20,7 +20,7 @@
  * THE SOFTWARE.
  */
 
-// Modified by cosmy1, Yao Wei Tjong & Lasse Oorni for Urho3D
+// Modified by cosmy1, Yao Wei Tjong, Lasse Oorni & Josh Engebretson for Urho3D
 
 #if defined(_WIN32)
 #if !defined(_CRT_SECURE_NO_WARNINGS)
@@ -132,7 +132,17 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
 #include <mach/mach_time.h>
 #include <assert.h>
 
-/* clock_gettime is not implemented on OSX */
+/* Determine if the current OSX version supports clock_gettime */
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#ifndef MAC_OS_X_VERSION_10_12
+#define MAC_OS_X_VERSION_10_12 101200
+#endif
+#endif
+
+// Urho3D: Instead of using MAC_OS_X_VERSION_MIN_REQUIRED, which it doesn't appear time.h is guarded by, use MAC_OS_X_VERSION_MAX_ALLOWED
+#define CIVETWEB_APPLE_HAVE_CLOCK_GETTIME defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
+#if !(CIVETWEB_APPLE_HAVE_CLOCK_GETTIME)
 int clock_gettime(int clk_id, struct timespec *t);
 
 int clock_gettime(int clk_id, struct timespec *t)
@@ -175,6 +185,7 @@ int clock_gettime(int clk_id, struct timespec *t)
 	return -1; /* EINVAL - Clock ID is unknown */
 }
 #endif
+#endif
 
 // Urho3D: Prevent inclusion of pthread_time.h on MinGW, instead prefer own implementation of clock_gettime()
 // to prevent dependency on pthread library which is not needed otherwise