X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=m4%2Fmktime.m4;fp=m4%2Fmktime.m4;h=faefb77009239f82ac2f77ac0c10d71d4f38af07;hb=daa269958ad8d50ef8154ccb65e58acaf7a6dd99;hp=56b2416d619302fba98577929692500717d61f3c;hpb=1a44d77d50f4fb37c0410eed04b82303624ea2ec;p=debian%2Ftar diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 56b2416d..faefb770 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,5 +1,5 @@ -# serial 19 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation, +# serial 25 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,21 +7,24 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Jim Meyering. -# Redefine AC_FUNC_MKTIME, because it is no longer maintained in Autoconf. -# AC_FUNC_MKTIME -# -------------- -AC_DEFUN([AC_FUNC_MKTIME], -[AC_CHECK_HEADERS_ONCE([unistd.h]) -AC_CHECK_FUNCS_ONCE([alarm]) -AC_REQUIRE([gl_MULTIARCH]) -if test $APPLE_UNIVERSAL_BUILD = 1; then - # A universal build on Apple MacOS X platforms. - # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. - # But we need a configuration result that is valid in both modes. - ac_cv_func_working_mktime=no -fi -AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime], -[AC_RUN_IFELSE([AC_LANG_SOURCE( +AC_DEFUN([gl_FUNC_MKTIME], +[ + AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + + 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. + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CHECK_DECLS_ONCE([alarm]) + AC_REQUIRE([gl_MULTIARCH]) + if test $APPLE_UNIVERSAL_BUILD = 1; then + # A universal build on Apple Mac OS X platforms. + # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. + # But we need a configuration result that is valid in both modes. + gl_cv_func_working_mktime=no + fi + AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE( [[/* Test program from Paul Eggert and Tony Leneis. */ #include #include @@ -31,8 +34,8 @@ AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime], # include #endif -#ifndef HAVE_ALARM -# define alarm(X) /* empty */ +#if HAVE_DECL_ALARM +# include #endif /* Work around redefinition to rpl_putenv by other config tests. */ @@ -168,10 +171,13 @@ main () 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. Give up after 60 seconds; a mktime slower than that isn't worth using anyway. */ + signal (SIGALRM, SIG_DFL); alarm (60); +#endif time_t_max = (! time_t_signed ? (time_t) -1 @@ -189,20 +195,23 @@ main () if (tz_strings[i]) putenv (tz_strings[i]); - for (t = 0; t <= time_t_max - delta; t += delta) + for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta) if (! mktime_test (t)) result |= 1; - if (! (mktime_test ((time_t) 1) - && mktime_test ((time_t) (60 * 60)) - && mktime_test ((time_t) (60 * 60 * 24)))) + if ((result & 2) == 0 + && ! (mktime_test ((time_t) 1) + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) result |= 2; - for (j = 1; ; j <<= 1) - if (! bigtime_test (j)) - result |= 4; - else if (INT_MAX / 2 < j) - break; - if (! bigtime_test (INT_MAX)) + for (j = 1; (result & 4) == 0; j <<= 1) + { + if (! bigtime_test (j)) + result |= 4; + if (INT_MAX / 2 < j) + break; + } + if ((result & 8) == 0 && ! bigtime_test (INT_MAX)) result |= 8; } if (! irix_6_4_bug ()) @@ -213,29 +222,32 @@ main () result |= 64; return result; }]])], - [ac_cv_func_working_mktime=yes], - [ac_cv_func_working_mktime=no], - [ac_cv_func_working_mktime=no])]) -if test $ac_cv_func_working_mktime = no; then - AC_LIBOBJ([mktime]) -fi -])# AC_FUNC_MKTIME + [gl_cv_func_working_mktime=yes], + [gl_cv_func_working_mktime=no], + [gl_cv_func_working_mktime=no]) + ]) -AC_DEFUN([gl_FUNC_MKTIME], -[ - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) - AC_FUNC_MKTIME - dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]). - if test $ac_cv_func_working_mktime = no; then + if test $gl_cv_func_working_mktime = no; then REPLACE_MKTIME=1 - gl_PREREQ_MKTIME else REPLACE_MKTIME=0 fi ]) -# Prerequisites of lib/mktime.c. -AC_DEFUN([gl_PREREQ_MKTIME], -[ - AC_REQUIRE([AC_C_INLINE]) +AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [ + AC_REQUIRE([gl_FUNC_MKTIME]) + if test $REPLACE_MKTIME = 0; then + dnl BeOS has __mktime_internal in libc, but other platforms don't. + AC_CHECK_FUNC([__mktime_internal], + [AC_DEFINE([mktime_internal], [__mktime_internal], + [Define to the real name of the mktime_internal function.]) + ], + [dnl mktime works but it doesn't export __mktime_internal, + dnl so we need to substitute our own mktime implementation. + REPLACE_MKTIME=1 + ]) + fi ]) + +# Prerequisites of lib/mktime.c. +AC_DEFUN([gl_PREREQ_MKTIME], [:])