Time.h portability for iOS 10.
authorMichael Lee <mzlee@fb.com>
Tue, 14 Jun 2016 00:05:24 +0000 (17:05 -0700)
committerFacebook Github Bot 9 <facebook-github-bot-9-bot@fb.com>
Tue, 14 Jun 2016 00:08:28 +0000 (17:08 -0700)
Summary: The iOS sdk adds `clock_gettime` support.

Reviewed By: clementgenzmer

Differential Revision: D3427621

fbshipit-source-id: fcd3022c5ea05ceb8e289fbeb1ae845155d2dea9

folly/portability/Time.cpp
folly/portability/Time.h

index a9160356f33fb7983b1dc76e8cb48a513a115de1..ea6d4ef05fc057f58a687a2b18384162c1651762 100755 (executable)
@@ -17,7 +17,7 @@
 #include <folly/portability/Time.h>
 
 #if !FOLLY_HAVE_CLOCK_GETTIME
 #include <folly/portability/Time.h>
 
 #if !FOLLY_HAVE_CLOCK_GETTIME
-#if __MACH__
+#if __MACH__ && !defined(__CLOCK_AVAILABILITY)
 #include <errno.h>
 #include <mach/mach_time.h>
 
 #include <errno.h>
 #include <mach/mach_time.h>
 
index 642a95de59e06365b01dbde8c9fe18987865014d..b3dfa68840f24a3ab731782134023e60e3ed0130 100755 (executable)
 
 #include <folly/portability/Config.h>
 
 
 #include <folly/portability/Config.h>
 
-// These aren't generic implementations, so we can only declare them on
-// platforms we support.
-#if !FOLLY_HAVE_CLOCK_GETTIME && (defined(__MACH__) || defined(_WIN32))
+// These aren't generic implementations, so we can only declare them
+// on platforms we support.  Apple started defining clock_gettime in
+// iOS 10 / OSX 12 and is gated via __CLOCK_AVAILABILITY.
+#if !FOLLY_HAVE_CLOCK_GETTIME && \
+    (defined(_WIN32) || (defined(__MACH__) && !defined(__CLOCK_AVAILABILITY)))
 #define CLOCK_REALTIME 0
 // The Windows implementation supports a few other
 // clock types as well.
 #define CLOCK_REALTIME 0
 // The Windows implementation supports a few other
 // clock types as well.