Use winpthreads clock_gettime implementations
authorElizabeth Smith <elizabeths@fb.com>
Tue, 6 May 2014 18:39:21 +0000 (11:39 -0700)
committerDave Watson <davejwatson@fb.com>
Tue, 20 May 2014 19:53:57 +0000 (12:53 -0700)
Summary:
No need to reinvent the wheel - winpthreads has the appropriate posix layer in place for time functionality
and we're already using it for pthreads on windows - so just include the right headers to make sure defines are set up when using time functionality

@override-unit-failures

Test Plan: fbconfig -r folly && fbmake runtests

Reviewed By: delong.j@fb.com

FB internal diff: D1313600

folly/detail/Clock.cpp
folly/detail/Clock.h

index 00e28b7928a093706e2375bc46ebf6f75b6b569d..834efbcc386edd876f843b8ad10d86707a4d5203 100644 (file)
@@ -48,6 +48,10 @@ int clock_getres(clockid_t clk_id, struct timespec* ts) {
 
   return 0;
 }
+#elif _MSC_VER
+// using winpthreads from mingw-w64
+// <pthreads_time.h> has clock_gettime and friends
+// make sure to include <pthread.h> as well for typedefs of timespec/etc
 #else
 #error No clock_gettime(2) compatibility wrapper available for this platform.
 #endif
index dff740e5579e75265f0e262db911a7356dc4ea58..c95e7b8ada9b179f46ebbbd784bf76ad554690c7 100644 (file)
           that do not support clock_gettime(2).
 #endif
 
+/* For windows, we'll use pthread's time implementations */
+#ifdef _MSC_VER
+#include <pthread.h>
+#include <pthread_time.h>
+#else
 typedef uint8_t clockid_t;
 #define CLOCK_REALTIME 0
 
 int clock_gettime(clockid_t clk_id, struct timespec* ts);
 int clock_getres(clockid_t clk_id, struct timespec* ts);
+#endif
 
 #endif /* FOLLY_DETAIL_CLOCK_H_ */