[libc++] Check _LIBCPP_USE_CLOCK_GETTIME before using clock_gettime
authorHafiz Abid Qadeer <abidh@codesourcery.com>
Mon, 5 Oct 2020 21:28:25 +0000 (17:28 -0400)
committerLouis Dionne <ldionne@apple.com>
Tue, 6 Oct 2020 15:56:54 +0000 (11:56 -0400)
commitf78bb4d84eee55c5d3bb1f3322c1e346e3388572
tree01c620bbba8558a43f1c23e56b6a472d9610c68a
parent53bf28b80cf9fec53c807922b19e0af2832dfeba
[libc++] Check _LIBCPP_USE_CLOCK_GETTIME before using clock_gettime

The clock_gettime function is available when _POSIX_TIMERS is defined.
We check for this and set _LIBCPP_USE_CLOCK_GETTIME accordingly since
59b3102739c. But check for _LIBCPP_USE_CLOCK_GETTIME was removed in
babd3aefc91. As a result, code is now trying to use clock_gettime even
on platforms where it is not available and it is causing build failure
with newlib.

This patch restores the checks to fix this.

Differential Revision: https://reviews.llvm.org/D88825
libcxx/src/chrono.cpp