summaryrefslogtreecommitdiff
path: root/m4/time.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-03-08 17:00:48 +0100
committerBruno Haible <bruno@clisp.org>2023-03-08 17:01:54 +0100
commitcbc0c1cda32bbcfab3ed0391cb9cfde444323571 (patch)
treee0a312f54ebc5cfad764e3a869fcf4b23f4563bc /m4/time.m4
parent3ef8e9910ae8f0e5d63cff8f37e22bb5aa9109ae (diff)
downloadgnulib-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/time.m4')
-rw-r--r--m4/time.m443
1 files changed, 43 insertions, 0 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],
+[
+ :
+])