From: Elizabeth Smith Date: Tue, 6 May 2014 18:39:21 +0000 (-0700) Subject: Use winpthreads clock_gettime implementations X-Git-Tag: v0.22.0~561 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9a56c3159ac79583466e9e0cdb9819f65263aa3d;p=folly.git Use winpthreads clock_gettime implementations 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 --- diff --git a/folly/detail/Clock.cpp b/folly/detail/Clock.cpp index 00e28b79..834efbcc 100644 --- a/folly/detail/Clock.cpp +++ b/folly/detail/Clock.cpp @@ -48,6 +48,10 @@ int clock_getres(clockid_t clk_id, struct timespec* ts) { return 0; } +#elif _MSC_VER +// using winpthreads from mingw-w64 +// has clock_gettime and friends +// make sure to include as well for typedefs of timespec/etc #else #error No clock_gettime(2) compatibility wrapper available for this platform. #endif diff --git a/folly/detail/Clock.h b/folly/detail/Clock.h index dff740e5..c95e7b8a 100644 --- a/folly/detail/Clock.h +++ b/folly/detail/Clock.h @@ -29,10 +29,16 @@ that do not support clock_gettime(2). #endif +/* For windows, we'll use pthread's time implementations */ +#ifdef _MSC_VER +#include +#include +#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_ */