summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2018-08-15 21:19:08 +0000
committerMarshall Clow <mclow.lists@gmail.com>2018-08-15 21:19:08 +0000
commitd9f4c1828e272b5eec10eab29a3b3bc7bbc7ba6b (patch)
treed3ac030659cab1316c8b498025e58c5d7cbb596f
parentfd6cf3debc335809914abfe697ac34db39b0c3e4 (diff)
Selectively import timespec_get into namespace std, since some C libraries don't have it. Reviewed as https://reviews.llvm.org/D50799
-rw-r--r--libcxx/include/__config3
-rw-r--r--libcxx/include/cstdlib4
-rw-r--r--libcxx/include/ctime2
-rw-r--r--libcxx/test/std/language.support/support.runtime/ctime.pass.cpp2
-rw-r--r--libcxx/test/std/utilities/time/date.time/ctime.pass.cpp2
-rw-r--r--libcxx/test/support/test_macros.h7
6 files changed, 15 insertions, 5 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index cd2a1354157..06af4dc61a3 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -334,6 +334,7 @@
# define _LIBCPP_HAS_C11_FEATURES
# elif defined(__Fuchsia__)
# define _LIBCPP_HAS_QUICK_EXIT
+# define _LIBCPP_HAS_TIMESPEC_GET
# define _LIBCPP_HAS_C11_FEATURES
# elif defined(__linux__)
# if !defined(_LIBCPP_HAS_MUSL_LIBC)
@@ -342,9 +343,11 @@
# endif
# if _LIBCPP_GLIBC_PREREQ(2, 17)
# define _LIBCPP_HAS_C11_FEATURES
+# define _LIBCPP_HAS_TIMESPEC_GET
# endif
# else // defined(_LIBCPP_HAS_MUSL_LIBC)
# define _LIBCPP_HAS_QUICK_EXIT
+# define _LIBCPP_HAS_TIMESPEC_GET
# define _LIBCPP_HAS_C11_FEATURES
# endif
# endif // __linux__
diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib
index 78c428403c3..00c604e6762 100644
--- a/libcxx/include/cstdlib
+++ b/libcxx/include/cstdlib
@@ -151,11 +151,11 @@ using ::mbtowc;
using ::wctomb;
using ::mbstowcs;
using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
using ::at_quick_exit;
using ::quick_exit;
#endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
using ::aligned_alloc;
#endif
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index 81cf11a466c..8264fe33b96 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -73,7 +73,7 @@ using ::gmtime;
using ::localtime;
#endif
using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
using ::timespec_get;
#endif
diff --git a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
index 908dc480884..d80bc198293 100644
--- a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@ int main()
static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
static_assert((std::is_same<decltype(std::timespec_get(nullptr, 0)), int>::value), "");
#endif
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
diff --git a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
index fe9f38daa3f..cd1f32be2bc 100644
--- a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
+++ b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@ int main()
static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
static_assert((std::is_same<decltype(std::timespec_get(nullptr, 0)), int>::value), "");
#endif
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index d774fc0384d..e008b532300 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -124,22 +124,29 @@
// Sniff out to see if the underling C library has C11 features
// Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
# if defined(__FreeBSD__)
+// Specifically, FreeBSD does NOT have timespec_get, even though they have all
+// the rest of C11 - this is PR#38495
# define TEST_HAS_C11_FEATURES
# elif defined(__Fuchsia__)
# define TEST_HAS_C11_FEATURES
+# define TEST_HAS_TIMESPEC_GET
# elif defined(__linux__)
# if !defined(_LIBCPP_HAS_MUSL_LIBC)
# if _LIBCPP_GLIBC_PREREQ(2, 17)
+# define TEST_HAS_TIMESPEC_GET
# define TEST_HAS_C11_FEATURES
# endif
# else // defined(_LIBCPP_HAS_MUSL_LIBC)
# define TEST_HAS_C11_FEATURES
+# define TEST_HAS_TIMESPEC_GET
# endif
# elif defined(_WIN32)
# if defined(_MSC_VER) && !defined(__MINGW32__)
# define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+# define TEST_HAS_TIMESPEC_GET
# endif
# endif
#endif