diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-01 18:36:38 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-01 18:37:01 -0700 |
commit | 3707f609cb8017371610a5e2233bd8478416217c (patch) | |
tree | fc9ecf2d9754bf95cc33bd9319871d5ebd866fa1 /m4/mktime.m4 | |
parent | 13f4efb0fd5573255c694607552532788ba31c95 (diff) | |
download | emacs-3707f609cb8017371610a5e2233bd8478416217c.tar.gz |
Sync from gnulib
This incorporates:
2016-05-01 mktime: port to stricter signed overflow checking
2016-05-01 mktime: speed up DEBUG_MKTIME benchmarks
2016-05-01 mktime: resurrect DEBUG_MKTIME testing
2016-05-01 mktime: simplify DEBUG_MKTIME
2016-05-01 Port mktime_internal offset to unsigned time_t
2016-04-27 xstrtol: prohibit monstrosities like "1bB"
2016-04-13 mktime: improve integer overflow checking
2016-04-13 intprops: check two's complement assumption
2016-04-13 intprops, mktime, strtol: assume two's complement
* lib/intprops.h, lib/mktime-internal.h, lib/mktime.c:
* lib/strtol.c, lib/timegm.c, m4/mktime.m4, m4/std-gnu11.m4:
Copy from gnulib.
Diffstat (limited to 'm4/mktime.m4')
-rw-r--r-- | m4/mktime.m4 | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 78f16ba66ae..5a0f2d88ab0 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 25 +# serial 26 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2016 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,9 +7,24 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Jim Meyering. +AC_DEFUN([gl_TIME_T_IS_SIGNED], +[ + AC_CACHE_CHECK([whether time_t is signed], + [gl_cv_time_t_is_signed], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <time.h> + char time_t_signed[(time_t) -1 < 0 ? 1 : -1];]])], + [gl_cv_time_t_is_signed=yes], + [gl_cv_time_t_is_signed=no])]) + if test $gl_cv_time_t_is_signed = yes; then + AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed.]) + fi +]) + AC_DEFUN([gl_FUNC_MKTIME], [ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + AC_REQUIRE([gl_TIME_T_IS_SIGNED]) dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained dnl in Autoconf and because it invokes AC_LIBOBJ. @@ -169,7 +184,6 @@ main () time_t t, delta; int i, j; int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; - int time_t_signed = ! ((time_t) 0 < (time_t) -1); #if HAVE_DECL_ALARM /* This test makes some buggy mktime implementations loop. @@ -179,11 +193,11 @@ main () alarm (60); #endif - time_t_max = (! time_t_signed + time_t_max = (! TIME_T_IS_SIGNED ? (time_t) -1 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1) * 2 + 1)); - time_t_min = (! time_t_signed + time_t_min = (! TIME_T_IS_SIGNED ? (time_t) 0 : time_t_signed_magnitude ? ~ (time_t) 0 |