Browse Source

Another go at fixing civet web for XCode 8

Josh Engebretson 9 years ago
parent
commit
382f2c4992

+ 0 - 3
Build/CMake/Modules/AtomicMac.cmake

@@ -5,9 +5,6 @@ set (ATOMIC_NODE_JAKE Build/Mac/node/node Build/node_modules/jake/bin/cli.js  -f
 include (BundleUtilities)
 include(AtomicDesktop)
 
-# only have 32 bit mono installed, fix this
-# set (CMAKE_OSX_ARCHITECTURES i386)
-
 # for CEF3
 set(PROJECT_ARCH "x86_64")
 

+ 0 - 10
Source/Atomic/BuildInfo/CMakeLists.txt

@@ -1,10 +0,0 @@
-
-include(GetGitRevisionDescription)
-
-get_git_head_revision(GIT_REFSPEC GIT_SHA1)
-
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/AtomicGitSHA.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/AtomicGitSHA.cpp" @ONLY)
-
-set (SOURCE_FILES AtomicBuildInfo.cpp AtomicBuildInfo.h AtomicGitSHA.cpp AtomicGitSHA.h)
-
-add_library(AtomicBuildInfo ${SOURCE_FILES})

+ 1 - 1
Source/Atomic/CMakeLists.txt

@@ -96,7 +96,7 @@ GroupSources("Script")
 # Handle Git Revision
 include(GetGitRevisionDescription)
 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo/AtomicGitSHA.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/AtomicGitSHA.cpp" @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo/AtomicGitSHA.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo/AtomicGitSHA.cpp" @ONLY)
 
 set (SOURCE_FILES ${SOURCE_FILES} BuildInfo/AtomicBuildInfo.cpp BuildInfo/AtomicBuildInfo.h BuildInfo/AtomicGitSHA.cpp BuildInfo/AtomicGitSHA.h)
 

+ 45 - 33
Source/ThirdParty/Civetweb/src/civetweb.c

@@ -133,56 +133,68 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
 #include <assert.h>
 
 // ATOMIC BEGIN
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
+/* 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
+
+// TODO: Once we get to the point 10.12 is required, make sure civetweb itself has been updated!
+#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12)
+
 // ATOMIC END
 
-/* clock_gettime is not implemented on OSX */
+/* clock_gettime is not implemented on OSX prior to 10.12 */
 int clock_gettime(int clk_id, struct timespec *t);
 
-int clock_gettime(int clk_id, struct timespec *t)
+int
+clock_gettime(int clk_id, struct timespec *t)
 {
-	if (clk_id == CLOCK_REALTIME) {
-		struct timeval now;
-		int rv = gettimeofday(&now, NULL);
-		if (rv) {
-			return rv;
-		}
-		t->tv_sec = now.tv_sec;
-		t->tv_nsec = now.tv_usec * 1000;
-		return 0;
+    memset(t, 0, sizeof(*t));
+    if (clk_id == CLOCK_REALTIME) {
+        struct timeval now;
+        int rv = gettimeofday(&now, NULL);
+        if (rv) {
+            return rv;
+        }
+        t->tv_sec = now.tv_sec;
+        t->tv_nsec = now.tv_usec * 1000;
+        return 0;
 
-	} else if (clk_id == CLOCK_MONOTONIC) {
-		static uint64_t start_time = 0;
-		static mach_timebase_info_data_t timebase_ifo = {0, 0};
+    } else if (clk_id == CLOCK_MONOTONIC) {
+        static uint64_t clock_start_time = 0;
+        static mach_timebase_info_data_t timebase_ifo = {0, 0};
 
-		uint64_t now = mach_absolute_time();
+        uint64_t now = mach_absolute_time();
 
-		if (start_time == 0) {
-			kern_return_t mach_status = mach_timebase_info(&timebase_ifo);
+        if (clock_start_time == 0) {
+            kern_return_t mach_status = mach_timebase_info(&timebase_ifo);
 #if defined(DEBUG)
-			assert(mach_status == KERN_SUCCESS);
+            assert(mach_status == KERN_SUCCESS);
 #else
-			/* appease "unused variable" warning for release builds */
-			(void)mach_status;
+            /* appease "unused variable" warning for release builds */
+            (void)mach_status;
 #endif
-			start_time = now;
-		}
+            clock_start_time = now;
+        }
 
-		now =
-		    (uint64_t)((double)(now - start_time) * (double)timebase_ifo.numer /
-		               (double)timebase_ifo.denom);
+        now = (uint64_t)((double)(now - clock_start_time)
+                         * (double)timebase_ifo.numer
+                         / (double)timebase_ifo.denom);
 
-		t->tv_sec = now / 1000000000;
-		t->tv_nsec = now % 1000000000;
-		return 0;
-	}
-	return -1; /* EINVAL - Clock ID is unknown */
+        t->tv_sec = now / 1000000000;
+        t->tv_nsec = now % 1000000000;
+        return 0;
+    }
+    return -1; /* EINVAL - Clock ID is unknown */
 }
-
 #endif
-
 #endif
 
+// ATOMIC END
+
 #include <time.h>
 #include <stdlib.h>
 #include <stdarg.h>