* configure.ac: Check for C11 timespec_get function. * crossconfig.m4 (freebsd, linux, gnu, cygwin, solaris, netbsd) (openbsd): Likewise * config.h.in: Regenerate. * configure: Regenerate. * include/c_global/ctime (timespec, timespec_get): Add to namespace std for C++17 and up.
Tested powerpc64le-linux (and bootstrapped on aarch64-linux-gnu cross compiler), committed to trunk.
commit 9c433c582ce9ca7a12a61a1e674ca7b3885318d8 Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Feb 14 11:06:46 2019 +0000 Add std::timespec and std::timespec_get for C++17 * configure.ac: Check for C11 timespec_get function. * crossconfig.m4 (freebsd, linux, gnu, cygwin, solaris, netbsd) (openbsd): Likewise * config.h.in: Regenerate. * configure: Regenerate. * include/c_global/ctime (timespec, timespec_get): Add to namespace std for C++17 and up. diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index ad5b4117cfd..6c98f270441 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -265,6 +265,9 @@ if $GLIBCXX_IS_NATIVE; then AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) AC_CHECK_FUNCS(_wfopen) + # C11 functions for C++17 library + AC_CHECK_FUNCS(timespec_get) + # For iconv support. AM_ICONV diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 index 3de40dc138b..4a303008053 100644 --- a/libstdc++-v3/crossconfig.m4 +++ b/libstdc++-v3/crossconfig.m4 @@ -135,6 +135,7 @@ case "${host}" in fi AC_CHECK_FUNCS(__cxa_thread_atexit) AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) + AC_CHECK_FUNCS(timespec_get) ;; *-fuchsia*) @@ -194,6 +195,7 @@ case "${host}" in GCC_CHECK_TLS AC_CHECK_FUNCS(__cxa_thread_atexit_impl) AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) + AC_CHECK_FUNCS(timespec_get) AM_ICONV ;; *-mingw32*) @@ -221,6 +223,7 @@ case "${host}" in AC_DEFINE(HAVE_ISNANL) fi AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) + AC_CHECK_FUNCS(timespec_get) ;; *-qnx6.1* | *-qnx6.2*) SECTION_FLAGS='-ffunction-sections -fdata-sections' diff --git a/libstdc++-v3/include/c_global/ctime b/libstdc++-v3/include/c_global/ctime index cdd3d8d7171..685c821b577 100644 --- a/libstdc++-v3/include/c_global/ctime +++ b/libstdc++-v3/include/c_global/ctime @@ -72,4 +72,13 @@ namespace std using ::strftime; } // namespace +#if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_TIMESPEC_GET) +#undef timespec_get +namespace std +{ + using ::timespec; + using ::timespec_get; +} // namespace std +#endif + #endif