diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-08 17:00:48 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-08 17:01:54 +0100 |
commit | cbc0c1cda32bbcfab3ed0391cb9cfde444323571 (patch) | |
tree | e0a312f54ebc5cfad764e3a869fcf4b23f4563bc /m4 | |
parent | 3ef8e9910ae8f0e5d63cff8f37e22bb5aa9109ae (diff) | |
download | gnulib-cbc0c1cda32bbcfab3ed0391cb9cfde444323571.tar.gz |
time: New module.
* lib/time.in.h (time): New declaration.
* lib/time.c: New file.
* m4/time_h.m4 (gl_TIME_H_REQUIRE_DEFAULTS): Initialize GNULIB_TIME.
(gl_TIME_H_DEFAULTS): Initialize REPLACE_TIME.
* m4/time.m4: New file.
* modules/time-h (Makefile.am): Substitute GNULIB_TIME, REPLACE_TIME.
* modules/time: New file.
* tests/test-time-h-c++.cc: Check the signature of
GNULIB_NAMESPACE::time.
* doc/posix-functions/time.texi: Mention the glibc problem and the
'time' module.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/time.m4 | 43 | ||||
-rw-r--r-- | m4/time_h.m4 | 4 |
2 files changed, 46 insertions, 1 deletions
diff --git a/m4/time.m4 b/m4/time.m4 new file mode 100644 index 0000000000..0dbb6011ed --- /dev/null +++ b/m4/time.m4 @@ -0,0 +1,43 @@ +# time.m4 serial 1 +dnl Copyright (C) 2023 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_FUNC_TIME], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + dnl glibc has the bug https://sourceware.org/bugzilla/show_bug.cgi?id=30200 . + AC_CACHE_CHECK([whether time() works], + [gl_cv_func_time_works], + [dnl Guess that it works except on glibc >= 2.31 with Linux. + dnl And binaries produced on glibc < 2.31 need to run fine on newer + dnl glibc versions as well; therefore ignore __GLIBC_MINOR__. + case "$host_os" in + linux*-gnu*) + AC_EGREP_CPP([Unlucky], [ + #include <features.h> + #ifdef __GNU_LIBRARY__ + #if __GLIBC__ == 2 + Unlucky GNU user + #endif + #endif + ], + [gl_cv_func_time_works="guessing no"], + [gl_cv_func_time_works="guessing yes"]) + ;; + *) gl_cv_func_time_works="guessing yes";; + esac + ]) + case "$gl_cv_func_time_works" in + *no) REPLACE_TIME=1 ;; + esac +]) + +# Prerequisites of lib/time.c. +AC_DEFUN([gl_PREREQ_TIME], +[ + : +]) diff --git a/m4/time_h.m4 b/m4/time_h.m4 index b74870c3d0..51d553a2f1 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -2,7 +2,7 @@ # Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc. -# serial 21 +# serial 22 # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -137,6 +137,7 @@ AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS], gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) + gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) @@ -169,6 +170,7 @@ AC_DEFUN([gl_TIME_H_DEFAULTS], REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME]) + REPLACE_TIME=0; AC_SUBST([REPLACE_TIME]) REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) REPLACE_TIMESPEC_GET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMESPEC_GET]) REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET]) |