Fix up and namespace clock_gettime and clock_getres for MacOS
authorMichael Lee <mzlee@fb.com>
Sat, 24 Jun 2017 03:11:14 +0000 (20:11 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 24 Jun 2017 03:28:03 +0000 (20:28 -0700)
commit8a7112c6839b8087ad663212a8d13c0e961dee52
treead684866d50fe56aa9c8b2e0d61621a3385760f6
parent4c7a736d6529f22451a0ec965e093e7e318695e3
Fix up and namespace clock_gettime and clock_getres for MacOS

Summary:
Resolve two issues with folly's clock_gettime() shim on Apple platforms (iOS, macOS, etc.):

When detecting whether folly should define clock_gettime() on Apple platforms, don't assume clock_gettime() is declared in Apple's headers just because MAC_OS_X_VERSION_10_12/__IPHONE_10_0 is defined. Someone might use a newer macOS or iOS SDK (which defines MAC_OS_X_VERSION_10_12/__IPHONE_10_0), but not have clock_gettime() (because _DARWIN_FEATURE_CLOCK_GETTIME isn't set).

When defining a shim for clock_gettime(), don't rely on Apple's clock_gettime() declaration. Instead, shadow Apple's declaration with our own. This prevents folly from inheriting Apple's availability and visibility attributes for clock_gettime().

Reviewed By: yfeldblum

Differential Revision: D5312574

fbshipit-source-id: f16634ce92ee6c299613d3db22f0537bd31ac14d
folly/portability/Time.cpp
folly/portability/Time.h