libstc++, configure: Check for timing APIs even if _POSIX_TIMERS is -1.
Configure script now correctly detects timing APIs like clock_gettime on systems where POSIX timers are not strictly advertised.
The GCC configure script previously guarded checks for timing APIs like nanosleep and clock_gettime based on the _POSIX_TIMERS macro. This commit modifies the check to test for the APIs directly, even if _POSIX_TIMERS is set to -1, which indicates a non-compliant implementation rather than absent APIs. This allows detection of these APIs on systems like Darwin where they are available but not POSIX-compliant.
In Details
The configure script's autoconf tests for POSIX timing APIs (clock_gettime, nanosleep) were incorrectly gated by the _POSIX_TIMERS and _POSIX_MONOTONIC_CLOCK preprocessor macros. On systems like Darwin, these macros might be defined as -1 to indicate non-compliance, but the underlying APIs are still present. This commit adjusts acinclude.m4 to perform direct API tests rather than relying solely on the macro definitions, ensuring ac_has_clock_monotonic and ac_has_clock_realtime are correctly set for such platforms.
- libstdc++
- The C++ standard library implementation used by GCC. It provides fundamental C++ functionalities like containers, algorithms, and I/O streams.
- configure script
- A script generated by Autoconf that checks the build environment (system, libraries, headers) and generates a
Makefiletailored for that environment. - _POSIX_TIMERS
- A POSIX standard macro that, when defined and greater than zero, indicates that the system supports timers (like
clock_gettime). A value of -1 typically means the implementation does not claim POSIX compliance, but may still offer the functionality. - nanosleep
- A POSIX system call that suspends the calling thread for a specified interval, expressed in nanoseconds.
- clock_gettime
- A POSIX system call that retrieves the time from a specified clock, offering high resolution and different clock sources like real-time or monotonic.
- Darwin
- The name of Apple's Unix-like operating system, serving as the foundation for macOS, iOS, and other Apple platforms. GCC builds for these platforms use Darwin-specific configurations.
- SFINAE
- Substitution Failure Is Not An Error. A C++ template metaprogramming technique where a failing template substitution is treated as a valid overload resolution path, allowing for compile-time selection of functions or classes based on type properties.