+2023-07-29 Bruno Haible <bruno@clisp.org>
+
+ time-h: Obey GNULIB_POSIXCHECK, not GNULIB_PORTCHECK.
+ * lib/time.in.h (timespec_get, timespec_getres, nanosleep, tzset,
+ mktime, localtime_r, gmtime_r, localtime, strptime, ctime, strftime,
+ timegm): Add _GL_WARN_ON_USE invocation.
+ (asctime, ctime): Don't assume that these functions are declared, since
+ POSIX obsoletes them.
+ * m4/time_h.m4 (gl_TIME_H): Test for the declarations of asctime, ctime,
+ gmtime_r, localtime, localtime_r, mktime, nanosleep, strftime, strptime,
+ time, timegm, timespec_get, timespec_getres, tzset.
+ (gl_TIME_H_DEFAULTS): Initialize REPLACE_CTIME, REPLACE_LOCALTIME_R,
+ REPLACE_MKTIME, REPLACE_NANOSLEEP, REPLACE_STRFTIME, REPLACE_TIMEGM,
+ REPLACE_TZSET with 0 instead of GNULIB_PORTCHECK.
+ * m4/ctime.m4 (gl_FUNC_CTIME): Don't re-initialize REPLACE_CTIME.
+ * m4/time_r.m4 (gl_TIME_R): Don't re-initialize REPLACE_LOCALTIME_R.
+ * m4/mktime.m4 (gl_FUNC_MKTIME): Don't re-initialize REPLACE_MKTIME.
+ * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Don't re-initialize
+ REPLACE_NANOSLEEP.
+ * m4/strftime-fixes.m4 (gl_FUNC_STRFTIME): Don't re-initialize
+ REPLACE_STRFTIME.
+ * m4/timegm.m4 (gl_FUNC_TIMEGM): Don't re-initialize REPLACE_TIMEGM.
+ * m4/tzset.m4 (gl_FUNC_TZSET: Don't re-initialize REPLACE_TZSET.
+
2023-07-28 Bruno Haible <bruno@clisp.org>
posixcheck: Fix dependencies.
# endif
_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
_GL_CXXALIASWARN (timespec_get);
+# elif defined GNULIB_POSIXCHECK
+# undef timespec_get
+# if HAVE_RAW_DECL_TIMESPEC_GET
+_GL_WARN_ON_USE (timespec_get, "timespec_get is unportable - "
+ "use gnulib module timespec_get for portability");
+# endif
# endif
/* Set *TS to the current time resolution, and return BASE.
# endif
_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
_GL_CXXALIASWARN (timespec_getres);
+# elif defined GNULIB_POSIXCHECK
+# undef timespec_getres
+# if HAVE_RAW_DECL_TIMESPEC_GETRES
+_GL_WARN_ON_USE (timespec_getres, "timespec_getres is unportable - "
+ "use gnulib module timespec_getres for portability");
+# endif
# endif
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# endif
_GL_CXXALIASWARN (nanosleep);
+# elif defined GNULIB_POSIXCHECK
+# undef nanosleep
+# if HAVE_RAW_DECL_NANOSLEEP
+_GL_WARN_ON_USE (nanosleep, "nanosleep is unportable - "
+ "use gnulib module nanosleep for portability");
+# endif
# endif
/* Initialize time conversion information. */
_GL_CXXALIAS_SYS (tzset, void, (void));
# endif
_GL_CXXALIASWARN (tzset);
+# elif defined GNULIB_POSIXCHECK
+# undef tzset
+# if HAVE_RAW_DECL_TZSET
+_GL_WARN_ON_USE (tzset, "tzset has portability problems - "
+ "use gnulib module tzset for portability");
+# endif
# endif
/* Return the 'time_t' representation of TP and normalize TP. */
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (mktime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef mktime
+# if HAVE_RAW_DECL_MKTIME
+_GL_WARN_ON_USE (mktime, "mktime has portability problems - "
+ "use gnulib module mktime for portability");
+# endif
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
# if @HAVE_DECL_LOCALTIME_R@
_GL_CXXALIASWARN (gmtime_r);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef localtime_r
+# if HAVE_RAW_DECL_LOCALTIME_R
+_GL_WARN_ON_USE (localtime_r, "localtime_r is unportable - "
+ "use gnulib module time_r for portability");
+# endif
+# undef gmtime_r
+# if HAVE_RAW_DECL_GMTIME_R
+_GL_WARN_ON_USE (gmtime_r, "gmtime_r is unportable - "
+ "use gnulib module time_r for portability");
+# endif
# endif
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (localtime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef localtime
+# if HAVE_RAW_DECL_LOCALTIME
+_GL_WARN_ON_USE (localtime, "localtime has portability problems - "
+ "use gnulib module localtime for portability");
+# endif
# endif
# if 0 || @REPLACE_GMTIME@
char const *restrict __format,
struct tm *restrict __tm));
_GL_CXXALIASWARN (strptime);
+# elif defined GNULIB_POSIXCHECK
+# undef strptime
+# if HAVE_RAW_DECL_STRPTIME
+_GL_WARN_ON_USE (strptime, "strptime is unportable - "
+ "use gnulib module strptime for portability");
+# endif
# endif
/* Convert *TP to a date and time string. See
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (ctime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef ctime
+# if HAVE_RAW_DECL_CTIME
+_GL_WARN_ON_USE (ctime, "ctime has portability problems - "
+ "use gnulib module ctime for portability");
+# endif
# endif
/* Convert *TP to a date and time string. See
# if __GLIBC__ >= 2
_GL_CXXALIASWARN (strftime);
# endif
+# elif defined GNULIB_POSIXCHECK
+# undef strftime
+# if HAVE_RAW_DECL_STRFTIME
+_GL_WARN_ON_USE (strftime, "strftime has portability problems - "
+ "use gnulib module strftime-fixes for portability");
+# endif
# endif
# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
# endif
_GL_CXXALIASWARN (timegm);
+# elif defined GNULIB_POSIXCHECK
+# undef timegm
+# if HAVE_RAW_DECL_TIMEGM
+_GL_WARN_ON_USE (timegm, "timegm is unportable - "
+ "use gnulib module timegm for portability");
+# endif
# endif
/* Encourage applications to avoid unsafe functions that can overrun
applications should use strftime (or even sprintf) instead. */
# if defined GNULIB_POSIXCHECK
# undef asctime
+# if HAVE_RAW_DECL_ASCTIME
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef asctime_r
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime
+# if HAVE_RAW_DECL_CTIME
_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
"better use strftime (or even sprintf) instead");
+# endif
# endif
# if defined GNULIB_POSIXCHECK
# undef ctime_r
-# ctime.m4 serial 2
+# ctime.m4 serial 3
dnl Copyright (C) 2017-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,
AC_REQUIRE([AC_CANONICAL_HOST])
case "$host_os" in
mingw*) REPLACE_CTIME=1 ;;
- *) REPLACE_CTIME=0 ;;
esac
])
-# serial 37
+# serial 38
dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
- REPLACE_MKTIME=0
if test "$gl_cv_func_working_mktime" != yes; then
REPLACE_MKTIME=1
AC_DEFINE([NEED_MKTIME_WORKING], [1],
-# serial 42
+# serial 42.1
dnl From Jim Meyering.
dnl Check for the nanosleep function.
])
])
case "$gl_cv_func_nanosleep" in
- *yes)
- REPLACE_NANOSLEEP=0
- ;;
+ *yes) ;;
*)
REPLACE_NANOSLEEP=1
case "$gl_cv_func_nanosleep" in
-# strftime-fixes.m4 serial 2
+# strftime-fixes.m4 serial 3
dnl Copyright (C) 2017-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,
AC_REQUIRE([AC_CANONICAL_HOST])
case "$host_os" in
mingw*) REPLACE_STRFTIME=1 ;;
- *) REPLACE_STRFTIME=0 ;;
esac
])
# Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
-# serial 20
+# serial 20.1
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[
#include <time.h>
- ]], [asctime_r ctime_r])
+ ]], [
+ asctime asctime_r ctime ctime_r gmtime_r localtime localtime_r mktime
+ nanosleep strftime strptime time timegm timespec_get timespec_getres tzset
+ ])
AC_REQUIRE([AC_C_RESTRICT])
HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES])
dnl Even GNU libc does not have timezone_t yet.
HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
- dnl If another module says to replace or to not replace, do that.
- dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
- dnl this lets maintainers check for portability.
- REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
- REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
- 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_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
- REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET])
+ REPLACE_CTIME=0; AC_SUBST([REPLACE_CTIME])
+ REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
+ REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
+ REPLACE_LOCALTIME_R=0; AC_SUBST([REPLACE_LOCALTIME_R])
+ REPLACE_MKTIME=0; AC_SUBST([REPLACE_MKTIME])
+ REPLACE_NANOSLEEP=0; AC_SUBST([REPLACE_NANOSLEEP])
+ REPLACE_STRFTIME=0; AC_SUBST([REPLACE_STRFTIME])
+ REPLACE_TIMEGM=0; AC_SUBST([REPLACE_TIMEGM])
+ REPLACE_TZSET=0; AC_SUBST([REPLACE_TZSET])
dnl Hack so that the time module doesn't depend on the sys_time module.
- dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
+ dnl Default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
: ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY])
- dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
- dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
- dnl is no longer a big deal.
- REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
- REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
])
[gl_cv_time_r_posix=yes],
[gl_cv_time_r_posix=no])
])
- if test $gl_cv_time_r_posix = yes; then
- REPLACE_LOCALTIME_R=0
- else
+ if test $gl_cv_time_r_posix != yes; then
REPLACE_LOCALTIME_R=1
fi
else
-# timegm.m4 serial 13
+# timegm.m4 serial 13.1
dnl Copyright (C) 2003, 2007, 2009-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,
[
AC_REQUIRE([gl_TIME_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
- REPLACE_TIMEGM=0
AC_CHECK_FUNCS_ONCE([timegm])
if test $ac_cv_func_timegm = yes; then
if test "$gl_cv_func_working_mktime" != yes; then
-# serial 16
+# serial 17
# Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
[
AC_REQUIRE([gl_TIME_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
- REPLACE_TZSET=0
case "$host_os" in
mingw*) REPLACE_TZSET=1 ;;
esac