1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-27 07:37:33 +00:00
emacs/m4/time_h.m4

145 lines
6.0 KiB
Plaintext
Raw Normal View History

2011-01-09 06:57:07 +00:00
# Configure a more-standard replacement for <time.h>.
Update from gnulib This incorporates: 2019-12-23 mktime, nstrftime: tweak division performance 2019-12-22 count-leading-zeros: assume 'long long' 2019-12-22 count-one-bits: assume 'long long' 2019-12-22 count-trailing-zeros: assume 'long long' 2019-12-12 inttypes-incomplete: assume 'long long' 2019-12-22 malloca: assume 'long long' 2019-12-22 stdint: assume 'long long' 2019-12-22 strtoll, strtoimax, strtoumax: assume 'long long' 2019-12-22 prefer lib_SOURCES to unconditional AC_LIBOBJ 2019-12-19 nstrftime: avoid a shadowing warning 2019-12-18 improve port of AC_C_RESTRICT to Oracle C++ 2019-12-12 stdalign: port to xlclang 16.01 2019-12-11 stddef, unistd: fix compilation error in C++ mode on MSVC 2019-12-08 fix compilation errors in C++ mode on Haiku 2019-12-08 fix compilation errors in 32-bit C++ mode on HP-UX 11/ia64 2019-12-08 fix compilation error in C++ mode on OpenBSD * build-aux/config.guess, doc/misc/texinfo.tex: * lib/count-leading-zeros.h, lib/count-one-bits.h: * lib/count-trailing-zeros.h, lib/inttypes.in.h, lib/malloca.h: * lib/mktime.c, lib/nstrftime.c, lib/signal.in.h, lib/stdalign.in.h: * lib/stddef.in.h, lib/stdint.in.h, lib/stdio.in.h, lib/stdlib.in.h: * lib/strtoimax.c, lib/unistd.in.h, m4/gnulib-common.m4: * m4/inttypes.m4, m4/largefile.m4, m4/malloca.m4, m4/strtoimax.m4: * m4/strtoll.m4: Copy from Gnulib. Also, change copyright notices in some other Gnulib-copied files to exactly match Gnulib, as Gnulib updated them in a trivially different way. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
2020-01-01 03:11:22 +00:00
# Copyright (C) 2000-2001, 2003-2007, 2009-2020 Free Software Foundation, Inc.
2011-01-09 06:57:07 +00:00
# serial 11
2011-01-09 06:57:07 +00:00
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Written by Paul Eggert and Jim Meyering.
AC_DEFUN([gl_HEADER_TIME_H],
[
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
dnl once only, before all statements that occur in other macros.
AC_REQUIRE([gl_HEADER_TIME_H_BODY])
])
AC_DEFUN([gl_HEADER_TIME_H_BODY],
[
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
gl_NEXT_HEADERS([time.h])
2011-01-09 06:57:07 +00:00
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
])
dnl Check whether 'struct timespec' is declared
dnl in time.h, sys/time.h, pthread.h, or unistd.h.
2011-01-09 06:57:07 +00:00
AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
[
AC_CHECK_HEADERS_ONCE([sys/time.h])
AC_CACHE_CHECK([for struct timespec in <time.h>],
[gl_cv_sys_struct_timespec_in_time_h],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <time.h>
]],
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
[gl_cv_sys_struct_timespec_in_time_h=yes],
[gl_cv_sys_struct_timespec_in_time_h=no])])
TIME_H_DEFINES_STRUCT_TIMESPEC=0
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
2011-01-09 06:57:07 +00:00
if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
TIME_H_DEFINES_STRUCT_TIMESPEC=1
else
AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
[gl_cv_sys_struct_timespec_in_sys_time_h],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <sys/time.h>
]],
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
[gl_cv_sys_struct_timespec_in_sys_time_h=yes],
[gl_cv_sys_struct_timespec_in_sys_time_h=no])])
if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
else
AC_CACHE_CHECK([for struct timespec in <pthread.h>],
[gl_cv_sys_struct_timespec_in_pthread_h],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <pthread.h>
]],
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
[gl_cv_sys_struct_timespec_in_pthread_h=yes],
[gl_cv_sys_struct_timespec_in_pthread_h=no])])
if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
else
AC_CACHE_CHECK([for struct timespec in <unistd.h>],
[gl_cv_sys_struct_timespec_in_unistd_h],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <unistd.h>
]],
[[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
[gl_cv_sys_struct_timespec_in_unistd_h=yes],
[gl_cv_sys_struct_timespec_in_unistd_h=no])])
if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
fi
2011-01-09 06:57:07 +00:00
fi
fi
fi
AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
2011-01-09 06:57:07 +00:00
])
AC_DEFUN([gl_TIME_MODULE_INDICATOR],
[
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
dnl Define it also as a C macro, for the benefit of the unit tests.
gl_MODULE_INDICATOR_FOR_TESTS([$1])
])
AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
[
GNULIB_CTIME=0; AC_SUBST([GNULIB_CTIME])
2011-01-09 06:57:07 +00:00
GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
GNULIB_LOCALTIME=0; AC_SUBST([GNULIB_LOCALTIME])
2011-01-09 06:57:07 +00:00
GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
GNULIB_STRFTIME=0; AC_SUBST([GNULIB_STRFTIME])
2011-01-09 06:57:07 +00:00
GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
New optional ZONE arg for format-time-string etc. This simplifies time conversions in other time zones. It also prevents display-time-world tampering with TZ (Bug#21020). * admin/admin.el (add-release-logs): Use improved add-log-time-format API. * admin/merge-gnulib (GNULIB_MODULES): Add time_rz, timegm. (GNULIB_TOOL_FLAGS): Avoid flexmember, setenv, unsetenv. * configure.ac (tzalloc): Remove test for this, since Emacs no longer uses HAVE_TZALLOC directly. * doc/lispref/os.texi (Time of Day, Time Conversion) (Time Parsing): * etc/NEWS: Document the new behavior. Merge from gnulib, incorporating: 2015-07-25 strftime: fix newly-introduced bug on Solaris 2015-07-23 fprintftime, strftime: use timezone_t args * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * lib/strftime.c, lib/strftime.h, lib/time.in.h, m4/sys_time_h.m4: * m4/time_h.m4: Update from gnulib. * lib/time_rz.c, lib/timegm.c, m4/time_rz.m4, m4/timegm.m4: New files from gnulib. * lisp/time-stamp.el (time-stamp-string): * lisp/time.el (display-time-world-list) (display-time-world-display): Use new API, with time zone arg. * lisp/time.el (display-time-world-display): Fix race when current-time advances while we're running. * lisp/vc/add-log.el (add-log-iso8601-time-zone) (add-log-iso8601-time-string): Accept optional time zone arg. * lisp/vc/add-log.el (add-change-log-entry): * lisp/vc/log-edit.el (log-edit-changelog-ours-p): Use new arg. * nt/gnulib.mk: Propagate lib/gnulib.mk changes here. Add rules for the time module, since they're now needed for tzalloc etc. * src/conf_post.h (getenv_TZ, setenv_TZ): New macros. (emacs_getenv_TZ, emacs_setenv_TZ): New decls. * src/editfns.c: Include errno.h. (set_time_zone_rule): Omit unnecessary forward decl. (initial_tz): Remove, replacing with ... (local_tz, wall_clock_tz, utc_tz): New static vars and constants. (tzeqlen): New constant; prefer it to (sizeof "TZ=" - 1). (emacs_localtime_rz, emacs_mktime_z, xtzalloc, xtzfree) (tzlookup): New static functions. (init_editfns): New arg DUMPING. All uses changed. (init_editfns): Omit most initialization if dumping, not if !initialized. Initialize wall_clock_tz and local_tz. (emacs_nmemftime, format_time_string): Time zone argument can now be any time zone, not just a boolean for UTC or local time. All callers changed. (Fformat_time_string, Fencode_time, Fcurrent_time_string) (Fcurrent_time_zone): New optional arg ZONE. (Fdecode_time, Fset_time_zone_rule): ZONE arg can now also take the same form as with the other new additions. (decode_time_zone): Remove; no longer needed. (tzvalbuf): Now file-scope. (emacs_getenv_TZ, emacs_setenv_TZ): New functions. (syms_of_editfns): Define Qwall. * src/editfns.c (mktime_z) [!HAVE_TZALLOC]: * src/systime.h (mktime_z, timezone_t, tzalloc, tzfree) [!HAVE_TZALLOC]: Remove; now supplied by gnulib. * src/emacs.c (main): * src/lisp.h (init_editfns): Adjust to init_editfns API change.
2015-07-26 07:01:34 +00:00
GNULIB_TIME_RZ=0; AC_SUBST([GNULIB_TIME_RZ])
GNULIB_TZSET=0; AC_SUBST([GNULIB_TZSET])
2011-01-09 06:57:07 +00:00
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
HAVE_TZSET=1; AC_SUBST([HAVE_TZSET])
dnl Even GNU libc does not have timezone_t yet.
HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
2011-01-09 06:57:07 +00:00
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])
2011-01-09 06:57:07 +00:00
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])
2011-01-09 06:57:07 +00:00
REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
REPLACE_TZSET=GNULIB_PORTCHECK; 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.
: ${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])
2011-01-09 06:57:07 +00:00
])