From: Christopher Dykes Date: Mon, 26 Jun 2017 17:25:00 +0000 (-0700) Subject: Revert D5312574: [folly] Fix up and namespace clock_gettime and clock_getres for... X-Git-Tag: v2017.06.26.01 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5de2b2828599520c64bfb9749259c796f074df59;p=folly.git Revert D5312574: [folly] Fix up and namespace clock_gettime and clock_getres for MacOS Summary: This reverts commit f16634ce92ee6c299613d3db22f0537bd31ac14d Differential Revision: D5312574 fbshipit-source-id: 1557ac17f79fb8e3530a09d69fa978ddd38e5093 --- diff --git a/folly/portability/Time.cpp b/folly/portability/Time.cpp index e54286fe..54b3d0a1 100644 --- a/folly/portability/Time.cpp +++ b/folly/portability/Time.cpp @@ -43,10 +43,6 @@ static void duration_to_ts( #include #include -namespace folly { -namespace portability { -namespace time { - static std::chrono::nanoseconds time_value_to_ns(time_value_t t) { return std::chrono::seconds(t.seconds) + std::chrono::microseconds(t.microseconds); @@ -140,10 +136,6 @@ int clock_getres(clockid_t clk_id, struct timespec* ts) { return 0; } - -} // namespace time -} // namespace portability -} // namespace folly #elif defined(_WIN32) #include #include @@ -152,10 +144,6 @@ int clock_getres(clockid_t clk_id, struct timespec* ts) { #include -namespace folly { -namespace portability { -namespace time { - using unsigned_nanos = std::chrono::duration; static unsigned_nanos filetimeToUnsignedNanos(FILETIME ft) { @@ -284,10 +272,6 @@ extern "C" int clock_gettime(clockid_t clock_id, struct timespec* tp) { return -1; } } - -} // namespace time -} // namespace portability -} // namespace folly #else #error No clock_gettime(3) compatibility wrapper available for this platform. #endif diff --git a/folly/portability/Time.h b/folly/portability/Time.h index a7e5cf2d..eb6c7941 100644 --- a/folly/portability/Time.h +++ b/folly/portability/Time.h @@ -20,7 +20,6 @@ #include #include -#include // OSX is a pain. The XCode 8 SDK always declares clock_gettime // even if the target OS version doesn't support it, so you get @@ -28,10 +27,15 @@ // solve that by pretending we have it here in the header and // then enable our implementation on the source side so that // gets linked in instead. -#if __MACH__ && FOLLY_HAVE_CLOCK_GETTIME && \ +#if __MACH__ && \ (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 || \ __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) +#ifdef FOLLY_HAVE_CLOCK_GETTIME +#undef FOLLY_HAVE_CLOCK_GETTIME +#endif + +#define FOLLY_HAVE_CLOCK_GETTIME 1 #define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1 #endif @@ -43,25 +47,10 @@ #define CLOCK_MONOTONIC 1 #define CLOCK_PROCESS_CPUTIME_ID 2 #define CLOCK_THREAD_CPUTIME_ID 3 -#endif -#if (!FOLLY_HAVE_CLOCK_GETTIME || FOLLY_FORCE_CLOCK_GETTIME_DEFINITION) && (defined(__MACH__) || defined(_WIN32)) -namespace folly { -namespace portability { -namespace time { typedef uint8_t clockid_t; -int clock_gettime(clockid_t clk_id, struct timespec* ts); -int clock_getres(clockid_t clk_id, struct timespec* ts); -} -} -} - -FOLLY_PUSH_WARNING -#if __CLANG_PREREQ(3, 0) -FOLLY_GCC_DISABLE_WARNING("-Wheader-hygiene") -#endif -/* using override */ using namespace folly::portability::time; -FOLLY_POP_WARNING +extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts); +extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts); #endif #ifdef _WIN32