We've been using gettimeofday() on VxWorks, because configury didn't
state clock_gettime was available. It has been since at least
vxworks6.9, possibly earlier. Indeed, it's been available for longer
than gettimeofday(), so this enables libstdc++'s chrono.cc to work
with earlier 6.9 releases.
We've used clock_gettime unconditionally in __gthread_cond_timedwait
for a very long time, so it's not like this brings in a new
dependency, but it allows clocks and deadlines to work with the same
precision. Before this change, we'd use gettimeofday's coarser
clocks, and finer timed waits, which makes room for imprecisions.
Regstrapped on x86_64-linux-gnu. Also tested with gcc-15 on
aarch64-wrs-vxworks7.2, and with a much older gcc on ppc-vxworks6.9.2.2.
Ok to install?
for libstdc++-v3/ChangeLog
* acinclude.m4 (GLIBXX_ENABLE_LIBSTDCXX_TIME) [vxworks*]:
Enable monotonic and realtime clocks.
* configure: Rebuilt.
---
libstdc++-v3/acinclude.m4 | 2 ++
libstdc++-v3/configure | 2 ++
2 files changed, 4 insertions(+)
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 8dc9e17b214cd..e7bc4fbf90c77 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1785,6 +1785,8 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
# VxWorks has nanosleep as soon as the kernel is configured with
# INCLUDE_POSIX_TIMERS, which is normally/most-often the case.
vxworks*)
+ ac_has_clock_monotonic=yes
+ ac_has_clock_realtime=yes
ac_has_nanosleep=yes
;;
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6713e4504b1cd..3785ad94f3302 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -21473,6 +21473,8 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# VxWorks has nanosleep as soon as the kernel is configured with
# INCLUDE_POSIX_TIMERS, which is normally/most-often the case.
vxworks*)
+ ac_has_clock_monotonic=yes
+ ac_has_clock_realtime=yes
ac_has_nanosleep=yes
;;
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
--
Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/
Free Software Activist FSFLA co-founder GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!