From: Paul Eggert Date: Thu, 18 Jan 2007 08:33:34 +0000 (+0000) Subject: * MODULES.html.sh (Support for systems lacking POSIX:2001): New X-Git-Tag: cvs-readonly~1321 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=5661ab9d49512b4cf3c19caa11bb581d8ce561ba;p=gnulib.git * MODULES.html.sh (Support for systems lacking POSIX:2001): New module sys_time. * lib/gethrxtime.c: Include , since we can no longer assume timespec.h defines struct timeval. * lib/settime.c: Likewise. * lib/utimens.c: Likewise. * lib/gettime.c (gettime): Remove test against HAVE_GETTIMEOFDAY, since we now assume the gettimeofday module. * lib/tempname.c (__gen_tempname): Likewise. * lib/gettimeofday.h: Remove. * lib/gettimeofday.c: Include instead of "gettimeofday.h". Don't include and ; shouldn't be needed. Include , for 'time()'. (localtime_buffer_addr): Also use this workaround if TZSET_CLOBBERS_LOCALTIME. Set to a dummy static variable by default, to simplify the uses. All uses changed. (localtime, gmtime, tzset, gettimeofday): Reformat slightly so that #undef is inside {}, and 'const' follows type name consistently. (tzset): Define replacement only if TZSET_CLOBBERS_LOCALTIME. (gettimeofday): Do not use the maximum possible value for tv->tv_usec, since that might break usages other than ls.c. Instead, we'll leave ls.c alone. This undoes today's patch by Bruno. Add a compile-time warning for 1s-clock resolution; we've never observed the problem but might as well keep the canary. * lib/nanosleep.c: Include timespec.h first, for interface check. * lib/nanosleep.c: Include unconditionally, since we now assume the sys_time module. * lib/tempname.c: Likewise. * lib/timespec.h: Likewise. * lib/nanosleep.c: Don't worry about TIME_WITH_SYS_TIME; no longer needed. * lib/strftime.c: Likewise. * lib/timespec.h: Likewise. * lib/posixtm.c: Include posixtm.h first, for interface check. Don't worry about TM_IN_SYS_TIME; that's wayyy obsolete. * lib/posixtm.h: Include stdbool.h and time.h, for proper interface. * lib/strftime.c: Don't include ; shouldn't be needed. * lib/sys_time_.h: New file. * lib/timespec.h (struct timespec): Use long int, not long. * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): (gl_FUNC_GETTIMEOFDAY_CLOBBER, gl_PREREQ_GETTIMEOFDAY): Remove obsolescent call to AC_HEADER_TIME. * m4/mktime.m4 (AC_FUNC_MKTIME): Likewise. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise. * m4/strftime.m4 (gl_FUNC_STRFTIME): Likewise. * m4/timespec.m4 (gl_TIMESPEC, gl_CHECK_TYPE_STRUCT_TIMESPEC): Likewise. * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Likewise. * m4/utimbuf.m4 (gl_CHECK_TYPE_STRUCT_UTIMBUF): Likewise. * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Move sys/time.h tests into the sys_time module. Check for gettimeofday just once. Prefix our variables with gl_, not with ac_ or jm_. Tighten test for gettimeofday signature to just check the signature. Merely compile it, since linking doesn't test signature. Improve test for whether gettimeofday.o is actually needed. (gl_FUNC_GETTIMEOFDAY_CLOBBER): Renamed from AC_FUNC_GETTIMEOFDAY_CLOBBER. All uses changed. Use AC_RUN_IFELSE rather than AC_TRY_RUN. If clobbering, set and define GETTIMEOFDAY_CLOBBERS_LOCALTIME. (gl_GETTIMEOFDAY_REPLACE_LOCALTIME): Don't define GETTIMEOFDAY_CLOBBERS_LOCALTIME; that's gl_FUNC_GETTIMEOFDAY_CLOBBER's job. Don't define tzset; that's gl_FUNC_TZSET_CLOBBER's job. * m4/mktime.m4 (AC_FUNC_MKTIME): Just include rather than worrying about sys/time.h. * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Don't bother worrying about TIME_WITH_SYS_TIME. * m4/stat-time.m4 (gl_STAT_TIME): Likewise. * m4/posixtm.m4 (gl_POSIXTM): Remove obsolescent call to AC_STRUCT_TM. * m4/sys_time_h.m4: New file. * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Require gl_HEADER_SYS_TIME_H. Don't include sys/time.h. Return from main rather than exiting. Define TZSET_CLOBBERS_LOCALTIME, for consistency with other names; all uses changed. * modules/gethrxtime (Depends-on): Add sys_time. * modules/gettime (Depends-on): Likewise. * modules/gettimeofday (Depends-on): Likewise. * modules/nanosleep (Depends-on): Likewise. * modules/settime (Depends-on): Likewise. * modules/tempname (Depends-on): Likewise. * modules/utimens (Depends-on): Likewise. * modules/gettimeofday (Files): Remove lib/gettimeofday.h. (Include:) Change back to . (Maintainer:) Add self. * modules/sys_time: New file. * modules/tempname (Depends-on): Add gettimeofday. * tests/test-gettimeofday.c: Include rather than gettimeofday.h. --- diff --git a/ChangeLog b/ChangeLog index 25b69a41e..d4169aa9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,94 @@ +2007-01-17 Paul Eggert + + * MODULES.html.sh (Support for systems lacking POSIX:2001): New + module sys_time. + * lib/gethrxtime.c: Include , since we can no longer + assume timespec.h defines struct timeval. + * lib/settime.c: Likewise. + * lib/utimens.c: Likewise. + * lib/gettime.c (gettime): Remove test against HAVE_GETTIMEOFDAY, + since we now assume the gettimeofday module. + * lib/tempname.c (__gen_tempname): Likewise. + * lib/gettimeofday.h: Remove. + * lib/gettimeofday.c: Include instead of "gettimeofday.h". + Don't include and ; shouldn't be needed. + Include , for 'time()'. + (localtime_buffer_addr): Also use this workaround if + TZSET_CLOBBERS_LOCALTIME. Set to a dummy static variable by default, + to simplify the uses. All uses changed. + (localtime, gmtime, tzset, gettimeofday): Reformat slightly so + that #undef is inside {}, and 'const' follows type name consistently. + (tzset): Define replacement only if TZSET_CLOBBERS_LOCALTIME. + (gettimeofday): Do not use the maximum possible value for + tv->tv_usec, since that might break usages other than ls.c. + Instead, we'll leave ls.c alone. This undoes today's patch + by Bruno. Add a compile-time warning for 1s-clock resolution; + we've never observed the problem but might as well keep the + canary. + * lib/nanosleep.c: Include timespec.h first, for interface check. + * lib/nanosleep.c: Include unconditionally, since we + now assume the sys_time module. + * lib/tempname.c: Likewise. + * lib/timespec.h: Likewise. + * lib/nanosleep.c: Don't worry about TIME_WITH_SYS_TIME; no longer + needed. + * lib/strftime.c: Likewise. + * lib/timespec.h: Likewise. + * lib/posixtm.c: Include posixtm.h first, for interface check. + Don't worry about TM_IN_SYS_TIME; that's wayyy obsolete. + * lib/posixtm.h: Include stdbool.h and time.h, for proper interface. + * lib/strftime.c: Don't include ; shouldn't be needed. + * lib/sys_time_.h: New file. + * lib/timespec.h (struct timespec): Use long int, not long. + * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): + (gl_FUNC_GETTIMEOFDAY_CLOBBER, gl_PREREQ_GETTIMEOFDAY): + Remove obsolescent call to AC_HEADER_TIME. + * m4/mktime.m4 (AC_FUNC_MKTIME): Likewise. + * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise. + * m4/strftime.m4 (gl_FUNC_STRFTIME): Likewise. + * m4/timespec.m4 (gl_TIMESPEC, gl_CHECK_TYPE_STRUCT_TIMESPEC): + Likewise. + * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Likewise. + * m4/utimbuf.m4 (gl_CHECK_TYPE_STRUCT_UTIMBUF): Likewise. + * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Move sys/time.h tests + into the sys_time module. Check for gettimeofday just once. + Prefix our variables with gl_, not with ac_ or jm_. Tighten test + for gettimeofday signature to just check the signature. Merely + compile it, since linking doesn't test signature. Improve test for + whether gettimeofday.o is actually needed. + (gl_FUNC_GETTIMEOFDAY_CLOBBER): Renamed from + AC_FUNC_GETTIMEOFDAY_CLOBBER. All uses changed. Use + AC_RUN_IFELSE rather than AC_TRY_RUN. If clobbering, set + and define GETTIMEOFDAY_CLOBBERS_LOCALTIME. + (gl_GETTIMEOFDAY_REPLACE_LOCALTIME): Don't define + GETTIMEOFDAY_CLOBBERS_LOCALTIME; that's gl_FUNC_GETTIMEOFDAY_CLOBBER's + job. Don't define tzset; that's gl_FUNC_TZSET_CLOBBER's job. + * m4/mktime.m4 (AC_FUNC_MKTIME): Just include rather + than worrying about sys/time.h. + * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): + Don't bother worrying about TIME_WITH_SYS_TIME. + * m4/stat-time.m4 (gl_STAT_TIME): Likewise. + * m4/posixtm.m4 (gl_POSIXTM): Remove obsolescent call to AC_STRUCT_TM. + * m4/sys_time_h.m4: New file. + * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Require gl_HEADER_SYS_TIME_H. + Don't include sys/time.h. Return from main rather than exiting. + Define TZSET_CLOBBERS_LOCALTIME, for consistency with other names; + all uses changed. + * modules/gethrxtime (Depends-on): Add sys_time. + * modules/gettime (Depends-on): Likewise. + * modules/gettimeofday (Depends-on): Likewise. + * modules/nanosleep (Depends-on): Likewise. + * modules/settime (Depends-on): Likewise. + * modules/tempname (Depends-on): Likewise. + * modules/utimens (Depends-on): Likewise. + * modules/gettimeofday (Files): Remove lib/gettimeofday.h. + (Include:) Change back to . + (Maintainer:) Add self. + * modules/sys_time: New file. + * modules/tempname (Depends-on): Add gettimeofday. + * tests/test-gettimeofday.c: Include + rather than gettimeofday.h. + 2007-01-17 Bruno Haible * gnulib-tool (func_get_license): Revert last patch. Instead, let diff --git a/MODULES.html.sh b/MODULES.html.sh index d1a66844a..eff713caa 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1949,6 +1949,7 @@ func_all_modules () func_module ssize_t func_module strtok_r func_module sys_stat + func_module sys_time func_module tsearch func_module unistd func_module utime diff --git a/lib/gethrxtime.c b/lib/gethrxtime.c index f3d41c7b9..2046e0607 100644 --- a/lib/gethrxtime.c +++ b/lib/gethrxtime.c @@ -1,6 +1,6 @@ /* gethrxtime -- get high resolution real time - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "gethrxtime.h" +#include #include "timespec.h" /* Get the current time, as a count of the number of nanoseconds since diff --git a/lib/gettime.c b/lib/gettime.c index abef2c41e..86bd32509 100644 --- a/lib/gettime.c +++ b/lib/gettime.c @@ -1,6 +1,6 @@ /* gettime -- get the system clock - Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,8 @@ #include "timespec.h" +#include + /* Get the system time into *TS. */ void @@ -36,23 +38,12 @@ gettime (struct timespec *ts) return; # endif -# if HAVE_GETTIMEOFDAY { struct timeval tv; gettimeofday (&tv, NULL); ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * 1000; } -# else - -# ifndef OK_TO_USE_1S_CLOCK -# error "Only 1-second nominal clock resolution found. Is that intended?" \ - "If so, compile with the -DOK_TO_USE_1S_CLOCK option." -# endif - ts->tv_sec = time (NULL); - ts->tv_nsec = 0; - -# endif #endif } diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c index 38094b039..1aee10760 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c @@ -1,12 +1,7 @@ -/* Provide gettimeofday - 1. for systems that don't have it, - 2. for some systems where gettimeofday clobbers the static buffer that - localtime uses for it's return value. The gettimeofday function from - Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem. - The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and - 2.6. +/* Provide gettimeofday for systems that don't have it or for which it's broken. - Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,18 +22,24 @@ #include /* Specification. */ -#include "gettimeofday.h" +#include -#include -#include +#include #if HAVE_SYS_TIMEB_H # include #endif -#if GETTIMEOFDAY_CLOBBERS_LOCALTIME +#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME -static struct tm *localtime_buffer_addr; +/* Work around the bug in some systems whereby gettimeofday clobbers + the static buffer that localtime uses for its return value. The + gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has + this problem. The tzset replacement is necessary for at least + Solaris 2.5, 2.5.1, and 2.6. */ + +static struct tm tm_zero_buffer; +static struct tm *localtime_buffer_addr = &tm_zero_buffer; /* This is a wrapper for localtime. It is used only on systems for which gettimeofday clobbers the static buffer used for localtime's result. @@ -47,13 +48,13 @@ static struct tm *localtime_buffer_addr; localtime uses for its result. */ struct tm * -localtime (const time_t *timep) -#undef localtime +localtime (time_t const *timep) { - extern struct tm *localtime (const time_t *); +#undef localtime + extern struct tm *localtime (time_t const *); struct tm *tm = localtime (timep); - if (! localtime_buffer_addr) + if (localtime_buffer_addr == &tm_zero_buffer) localtime_buffer_addr = tm; return tm; @@ -61,107 +62,83 @@ localtime (const time_t *timep) /* Same as above, since gmtime and localtime use the same buffer. */ struct tm * -gmtime (const time_t *timep) -#undef gmtime +gmtime (time_t const *timep) { - extern struct tm *gmtime (const time_t *); +#undef gmtime + extern struct tm *gmtime (time_t const *); struct tm *tm = gmtime (timep); - if (! localtime_buffer_addr) + if (localtime_buffer_addr == &tm_zero_buffer) localtime_buffer_addr = tm; return tm; } -/* This is a wrapper for tzset. It is used only on systems for which - tzset may clobber the static buffer used for localtime's result. - Save and restore the contents of the buffer used for localtime's - result around the call to tzset. */ +#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ + +#if TZSET_CLOBBERS_LOCALTIME +/* This is a wrapper for tzset, for systems on which tzset may clobber + the static buffer used for localtime's result. */ void tzset (void) -#undef tzset { - extern struct tm *localtime (const time_t *); +#undef tzset extern void tzset (void); - struct tm save; - - if (! localtime_buffer_addr) - { - time_t t = 0; - localtime_buffer_addr = localtime (&t); - } - save = *localtime_buffer_addr; + /* Save and restore the contents of the buffer used for localtime's + result around the call to tzset. */ + struct tm save = *localtime_buffer_addr; tzset (); *localtime_buffer_addr = save; } - #endif -/* This is a wrapper for gettimeofday. - It is used only on systems that lack this function, or for whose - implementation of this function causes problems. */ +/* This is a wrapper for gettimeofday. It is used only on systems + that lack this function, or whose implementation of this function + causes problems. */ int gettimeofday (struct timeval *restrict tv, void *restrict tz) -#undef gettimeofday { +#undef gettimeofday #if HAVE_GETTIMEOFDAY extern int gettimeofday (/* unspecified arguments */); -# if GETTIMEOFDAY_CLOBBERS_LOCALTIME - extern struct tm *localtime (const time_t *); - /* Save and restore the contents of the buffer used for localtime's result - around the call to gettimeofday. */ - struct tm save; - int result; +# if GETTIMEOFDAY_CLOBBERS_LOCALTIME + /* Save and restore the contents of the buffer used for localtime's + result around the call to gettimeofday. */ + struct tm save = *localtime_buffer_addr; +# endif - if (! localtime_buffer_addr) - { - time_t t = 0; - localtime_buffer_addr = localtime (&t); - } + int result = gettimeofday (tv, tz); - save = *localtime_buffer_addr; - result = gettimeofday (tv, tz); +# if GETTIMEOFDAY_CLOBBERS_LOCALTIME *localtime_buffer_addr = save; +# endif return result; -# else - - return gettimeofday (tv, tz); - -# endif #else - /* The clock does not have microsecond resolution, so get the maximum - possible value for the current time that is consistent with the - reported clock. That way, files are not considered to be in the - future merely because their time stamps have higher resolution - than the clock resolution. */ - # if HAVE__FTIME struct _timeb timebuf; - _ftime (&timebuf); tv->tv_sec = timebuf.time; - tv->tv_usec = timebuf.millitm * 1000 + 999; - - return 0; + tv->tv_usec = timebuf.millitm * 1000; # else - time_t t = time (NULL); +# if !defined OK_TO_USE_1S_CLOCK +# error "Only 1-second nominal clock resolution found. Is that intended?" \ + "If so, compile with the -DOK_TO_USE_1S_CLOCK option." +# endif + tv->tv_sec = time (NULL); + tv->tv_usec = 0; - if (t == (time_t) -1) - return -1; - tv->tv_sec = t; - tv->tv_usec = 999999; +# endif return 0; -# endif #endif } diff --git a/lib/gettimeofday.h b/lib/gettimeofday.h deleted file mode 100644 index d361ed1e8..000000000 --- a/lib/gettimeofday.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Provide gettimeofday - 1. for systems that don't have it, - 2. for some systems where gettimeofday clobbers the static buffer that - localtime uses for it's return value. The gettimeofday function from - Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem. - The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and - 2.6. - - Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef GETTIMEOFDAY_H -#define GETTIMEOFDAY_H - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -#if !HAVE_STRUCT_TIMEVAL -struct timeval -{ - time_t tv_sec; - suseconds_t tv_usec; -}; -#endif - -#if !HAVE_GETTIMEOFDAY_POSIX_SIGNATURE || GETTIMEOFDAY_CLOBBERS_LOCALTIME -# undef gettimeofday -# define gettimeofday rpl_gettimeofday -extern int gettimeofday (struct timeval *restrict tp, void *restrict tzp); -#endif - -#endif /* GETTIMEOFDAY_H */ diff --git a/lib/nanosleep.c b/lib/nanosleep.c index fe22a97ca..bb4726812 100644 --- a/lib/nanosleep.c +++ b/lib/nanosleep.c @@ -1,7 +1,7 @@ /* Provide a replacement for the POSIX nanosleep function. - Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006 Free Software - Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, 2007 Free + Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,8 @@ prototype for rpl_nanosleep. (they'd conflict e.g., on alpha-dec-osf3.2) */ #undef nanosleep +#include "timespec.h" + #include #include #include @@ -33,23 +35,13 @@ #endif #include -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif +#include +#include #include #include -#include "timespec.h" - enum { BILLION = 1000 * 1000 * 1000 }; #if HAVE_BUG_BIG_NANOSLEEP diff --git a/lib/posixtm.c b/lib/posixtm.c index 5a839d676..5514ba4fe 100644 --- a/lib/posixtm.c +++ b/lib/posixtm.c @@ -1,7 +1,7 @@ /* Parse dates for touch and date. Copyright (C) 1989, 1990, 1991, 1998, 2000, 2001, 2002, 2003, 2004, - 2005, 2006 Free Software Foundation Inc. + 2005, 2006, 2007 Free Software Foundation Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,21 +22,13 @@ #include -#include +#include "posixtm.h" #include #include #include #include -#ifdef TM_IN_SYS_TIME -# include -#else -# include -#endif - -#include "posixtm.h" - #if USE_UNLOCKED_IO # include "unlocked-io.h" #endif diff --git a/lib/posixtm.h b/lib/posixtm.h index c17b31851..e91749d73 100644 --- a/lib/posixtm.h +++ b/lib/posixtm.h @@ -1,6 +1,6 @@ /* Parse dates for touch and date. - Copyright (C) 1998, 2003, 2005 Free Software Foundation Inc. + Copyright (C) 1998, 2003, 2005, 2007 Free Software Foundation Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ #ifndef POSIXTM_H_ # define POSIXTM_H_ +# include +# include + /* POSIX Date Syntax flags. */ # define PDS_LEADING_YEAR 1 # define PDS_TRAILING_YEAR 2 diff --git a/lib/settime.c b/lib/settime.c index 9d48f1654..25e7e68e4 100644 --- a/lib/settime.c +++ b/lib/settime.c @@ -1,6 +1,7 @@ /* settime -- set the system clock - Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +23,7 @@ #include "timespec.h" +#include #include #include diff --git a/lib/strftime.c b/lib/strftime.c index 361a21206..3fce99bd8 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -36,18 +36,8 @@ #endif #include -#include /* Some systems define `time_t' here. */ +#include -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif #if HAVE_TZNAME && ! defined tzname extern char *tzname[]; #endif diff --git a/lib/sys_time_.h b/lib/sys_time_.h new file mode 100644 index 000000000..96291c961 --- /dev/null +++ b/lib/sys_time_.h @@ -0,0 +1,44 @@ +/* Provide a more complete sys/time.h. + + Copyright (C) 2007 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Paul Eggert. */ + +#ifndef _gl_SYS_TIME_H +#define _gl_SYS_TIME_H + +#if @HAVE_SYS_TIME_H@ +# include @ABSOLUTE_SYS_TIME_H@ +#else +# include +#endif + +#if ! @HAVE_STRUCT_TIMEVAL@ +struct timeval +{ + time_t tv_sec; + long int tv_usec; +}; +#endif + +#if ! @HAVE_GETTIMEOFDAY_POSIX_SIGNATURE@ || @GETTIMEOFDAY_CLOBBERS_LOCALTIME@ +# undef gettimeofday +# define gettimeofday rpl_gettimeofday +int gettimeofday (struct timeval *restrict, void *restrict); +#endif + +#endif /* _gl_SYS_TIME_H */ diff --git a/lib/tempname.c b/lib/tempname.c index 919badb3d..e213600e3 100644 --- a/lib/tempname.c +++ b/lib/tempname.c @@ -1,7 +1,8 @@ /* tempname.c - generate the name of a temporary file. Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. + 2000, 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, + Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -51,11 +52,7 @@ #include #include - -#if HAVE_SYS_TIME_H || _LIBC -# include -#endif - +#include #include #include @@ -242,15 +239,11 @@ __gen_tempname (char *tmpl, int kind) #ifdef RANDOM_BITS RANDOM_BITS (random_time_bits); #else -# if HAVE_GETTIMEOFDAY || _LIBC { struct timeval tv; __gettimeofday (&tv, NULL); random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; } -# else - random_time_bits = time (NULL); -# endif #endif value += random_time_bits ^ __getpid (); diff --git a/lib/timespec.h b/lib/timespec.h index 8188c208c..c65257792 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -1,6 +1,6 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2004, 2005, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,24 +19,17 @@ #if ! defined TIMESPEC_H # define TIMESPEC_H -# include -# if TIME_WITH_SYS_TIME +# if HAVE_SYS_TIME_H # include -# include -# else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif # endif +# include # if ! HAVE_STRUCT_TIMESPEC /* Some systems don't define this struct, e.g., AIX 4.1, Ultrix 4.3. */ struct timespec { time_t tv_sec; - long tv_nsec; + long int tv_nsec; }; # endif diff --git a/lib/utimens.c b/lib/utimens.c index 8f4273c80..71bc510d8 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -1,6 +1,7 @@ /* Set file access and modification times. - Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -26,6 +27,7 @@ #include #include +#include #include #if HAVE_UTIME_H diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index 51b916a81..9f70e10ef 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -1,86 +1,45 @@ -#serial 8 +#serial 9 # Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. # 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. +dnl From Jim Meyering. + AC_DEFUN([gl_FUNC_GETTIMEOFDAY], [ AC_REQUIRE([AC_C_RESTRICT]) - AC_REQUIRE([AC_HEADER_TIME]) - AC_CHECK_HEADERS_ONCE([sys/time.h]) - AC_CHECK_FUNCS([gettimeofday]) - - AC_CHECK_TYPE([suseconds_t], , - [AC_DEFINE([suseconds_t], [int], - [Define to `int' if `suseconds_t' is missing.]) - ], - [ -# if TIME_WITH_SYS_TIME -# include -# include -# else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -# endif - ]) + AC_REQUIRE([gl_HEADER_SYS_TIME_H]) + AC_CHECK_FUNCS_ONCE([gettimeofday]) - AC_CACHE_CHECK([for struct timeval], [fu_cv_sys_struct_timeval], - [AC_TRY_COMPILE( - [ -# if TIME_WITH_SYS_TIME -# include -# include -# else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -# endif - ], - [static struct timeval x; x.tv_sec = x.tv_usec;], - fu_cv_sys_struct_timeval=yes, - fu_cv_sys_struct_timeval=no) - ]) - - if test $fu_cv_sys_struct_timeval = yes; then - AC_DEFINE(HAVE_STRUCT_TIMEVAL, 1, - [Define if struct timeval is declared in or . ]) - fi - - AC_CACHE_CHECK([for gettimeofday whose signature conforms to POSIX], - [ac_cv_func_gettimeofday_posix_signature], - [AC_LINK_IFELSE( + AC_CACHE_CHECK([for gettimeofday with POSIX signature], + [gl_cv_func_gettimeofday_posix_signature], + [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include - time_t a; - suseconds_t b; + [[#include struct timeval c; ]], [[ - int x = gettimeofday (&c, 0); int (*f) (struct timeval *restrict, void *restrict) = gettimeofday; + int x = f (&c, 0); return !(x | c.tv_sec | c.tv_usec); ]])], - [ac_cv_func_gettimeofday_posix_signature=yes], - [ac_cv_func_gettimeofday_posix_signature=no])]) - if test $ac_cv_func_gettimeofday_posix_signature = yes; then - AC_DEFINE([HAVE_GETTIMEOFDAY_POSIX_SIGNATURE], 1, - [Define if gettimeofday's signature conforms to POSIX.]) - AC_FUNC_GETTIMEOFDAY_CLOBBER - else - gl_PREREQ_GETTIMEOFDAY - AC_LIBOBJ([gettimeofday]) + [gl_cv_func_gettimeofday_posix_signature=yes], + [gl_cv_func_gettimeofday_posix_signature=no])]) + + gl_FUNC_GETTIMEOFDAY_CLOBBER + + if test $gl_cv_func_gettimeofday_posix_signature != yes; then + HAVE_GETTIMEOFDAY_POSIX_SIGNATURE=0 + if test $gl_cv_func_gettimeofday_clobber != yes; then + AC_LIBOBJ(gettimeofday) + gl_PREREQ_GETTIMEOFDAY + fi fi ]) -dnl From Jim Meyering. -dnl + dnl See if gettimeofday clobbers the static buffer that localtime uses dnl for its return value. The gettimeofday function from Mac OS X 10.0.4 dnl (i.e., Darwin 1.3.7) has this problem. @@ -88,70 +47,53 @@ dnl dnl If it does, then arrange to use gettimeofday and localtime only via dnl the wrapper functions that work around the problem. -AC_DEFUN([AC_FUNC_GETTIMEOFDAY_CLOBBER], +AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER], [ - AC_REQUIRE([AC_HEADER_TIME]) - AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], - [jm_cv_func_gettimeofday_clobber], - [AC_TRY_RUN([ -#include -#include - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif + AC_REQUIRE([gl_HEADER_SYS_TIME_H]) -#include - -int -main () -{ - time_t t = 0; - struct tm *lt; - struct tm saved_lt; - struct timeval tv; - lt = localtime (&t); - saved_lt = *lt; - gettimeofday (&tv, NULL); - if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0) - exit (1); + AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer], + [gl_cv_func_gettimeofday_clobber], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + #include + ]], + [[ + time_t t = 0; + struct tm *lt; + struct tm saved_lt; + struct timeval tv; + lt = localtime (&t); + saved_lt = *lt; + gettimeofday (&tv, NULL); + return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0; + ]])], + [gl_cv_func_gettimeofday_clobber=no], + [gl_cv_func_gettimeofday_clobber=yes], + dnl When crosscompiling, assume it is broken. + [gl_cv_func_gettimeofday_clobber=yes])]) - exit (0); -} - ], - jm_cv_func_gettimeofday_clobber=no, - jm_cv_func_gettimeofday_clobber=yes, - dnl When crosscompiling, assume it is broken. - jm_cv_func_gettimeofday_clobber=yes) - ]) - if test $jm_cv_func_gettimeofday_clobber = yes; then - gl_GETTIMEOFDAY_REPLACE_LOCALTIME - fi + if test $gl_cv_func_gettimeofday_clobber = yes; then + gl_GETTIMEOFDAY_REPLACE_LOCALTIME + GETTIMEOFDAY_CLOBBERS_LOCALTIME=1 + AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1, + [Define if gettimeofday clobbers the localtime buffer.]) + fi ]) AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [ AC_LIBOBJ(gettimeofday) gl_PREREQ_GETTIMEOFDAY - AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1, - [Define if gettimeofday clobbers the localtime buffer.]) AC_DEFINE([gmtime], [rpl_gmtime], [Define to rpl_gmtime if the replacement function should be used.]) AC_DEFINE([localtime], [rpl_localtime], [Define to rpl_localtime if the replacement function should be used.]) - AC_DEFINE([tzset], [rpl_tzset], - [Define to rpl_tzset if the replacement function should be used.]) ]) # Prerequisites of lib/gettimeofday.c. AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [ - AC_REQUIRE([AC_HEADER_TIME]) AC_CHECK_HEADERS([sys/timeb.h]) AC_CHECK_FUNCS([_ftime]) ]) diff --git a/m4/mktime.m4 b/m4/mktime.m4 index a65a369b1..b0eac13ff 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,5 +1,5 @@ -#serial 9 -dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +#serial 10 +dnl Copyright (C) 2002, 2003, 2005, 2006, 2007 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. @@ -13,25 +13,14 @@ dnl From Jim Meyering. # AC_FUNC_MKTIME # -------------- AC_DEFUN([AC_FUNC_MKTIME], -[AC_REQUIRE([AC_HEADER_TIME])dnl -AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h) +[AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h) AC_CHECK_FUNCS_ONCE(alarm) AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime, [AC_RUN_IFELSE([AC_LANG_SOURCE( [[/* Test program from Paul Eggert and Tony Leneis. */ -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - #include #include +#include #ifdef HAVE_UNISTD_H # include diff --git a/m4/nanosleep.m4 b/m4/nanosleep.m4 index 9741b1528..d25295e38 100644 --- a/m4/nanosleep.m4 +++ b/m4/nanosleep.m4 @@ -1,12 +1,12 @@ -#serial 19 +#serial 20 dnl From Jim Meyering. dnl Check for the nanosleep function. dnl If not found, use the supplied replacement. dnl -# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free +# Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,6 @@ AC_DEFUN([gl_FUNC_NANOSLEEP], dnl Persuade glibc and Solaris to declare nanosleep. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([AC_HEADER_TIME]) AC_REQUIRE([gl_CLOCK_TIME]) AC_CHECK_HEADERS_ONCE(sys/time.h) @@ -34,19 +33,13 @@ AC_DEFUN([gl_FUNC_NANOSLEEP], [ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ - #if TIME_WITH_SYS_TIME - #include - #include - #else - #if HAVE_SYS_TIME_H - #include - #else - #include - #endif - #endif #include #include #include + #if HAVE_SYS_TIME_H + #include + #endif + #include #include #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) #define TYPE_MAXIMUM(t) \ diff --git a/m4/posixtm.m4 b/m4/posixtm.m4 index f0c5b287f..7ace2a965 100644 --- a/m4/posixtm.m4 +++ b/m4/posixtm.m4 @@ -1,5 +1,5 @@ -# posixtm.m4 serial 5 -dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +# posixtm.m4 serial 6 +dnl Copyright (C) 2002, 2003, 2005, 2006, 2007 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. @@ -8,6 +8,5 @@ AC_DEFUN([gl_POSIXTM], [ AC_LIBOBJ(posixtm) - dnl Prerequisites of lib/posixtm.c. - AC_STRUCT_TM + dnl No prerequisites of lib/posixtm.c. ]) diff --git a/m4/stat-time.m4 b/m4/stat-time.m4 index 1e46a09fe..353de213f 100644 --- a/m4/stat-time.m4 +++ b/m4/stat-time.m4 @@ -1,6 +1,6 @@ # Checks for stat-related time functions. -# Copyright (C) 1998, 1999, 2001, 2003, 2005, 2006 Free Software +# Copyright (C) 1998, 1999, 2001, 2003, 2005, 2006, 2007 Free Software # Foundation, Inc. # This file is free software; the Free Software Foundation @@ -19,6 +19,7 @@ AC_DEFUN([gl_STAT_TIME], [ AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_HEADERS_ONCE([sys/time.h]) AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec], [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec], @@ -26,17 +27,11 @@ AC_DEFUN([gl_STAT_TIME], [AC_TRY_COMPILE( [ #include - #if TIME_WITH_SYS_TIME + #include + #if HAVE_SYS_TIME_H # include - # include - #else - # if HAVE_SYS_TIME_H - # include - # else - # include - # endif #endif - #include + #include struct timespec ts; struct stat st; ], diff --git a/m4/strftime.m4 b/m4/strftime.m4 index 7abad56dc..ec5873adf 100644 --- a/m4/strftime.m4 +++ b/m4/strftime.m4 @@ -1,7 +1,7 @@ #serial 28 -# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 -# Free Software Foundation, Inc. +# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +# 2006, 2007 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -21,7 +21,6 @@ AC_DEFUN([gl_FUNC_STRFTIME], # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE. AC_REQUIRE([AC_STRUCT_TIMEZONE]) - AC_REQUIRE([AC_HEADER_TIME]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) AC_REQUIRE([gl_TM_GMTOFF]) diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 new file mode 100644 index 000000000..4387cd87d --- /dev/null +++ b/m4/sys_time_h.m4 @@ -0,0 +1,49 @@ +# Configure a replacement for . + +# Copyright (C) 2007 Free Software Foundation, Inc. +# 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 Martin Lambers. + +AC_DEFUN([gl_HEADER_SYS_TIME_H], +[ + AC_REQUIRE([AC_C_RESTRICT]) + AC_CHECK_HEADERS_ONCE([sys/time.h]) + + if test $ac_cv_header_sys_time_h = yes; then + gl_ABSOLUTE_HEADER([sys/time.h]) + ABSOLUTE_SYS_TIME_H=\"$gl_cv_absolute_sys_time_h\" + HAVE_SYS_TIME_H=1 + else + ABSOLUTE_SYS_TIME_H=\"no/such/file/sys/time.h\" + HAVE_SYS_TIME_H=0 + fi + AC_SUBST([ABSOLUTE_SYS_TIME_H]) + AC_SUBST([HAVE_SYS_TIME_H]) + + AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SYS_TIME_H + #include + #endif + #include + ]], + [[static struct timeval x; x.tv_sec = x.tv_usec;]])], + [gl_cv_sys_struct_timeval=yes], + [gl_cv_sys_struct_timeval=no])]) + if test $gl_cv_sys_struct_timeval = yes; then + HAVE_STRUCT_TIMEVAL=1 + else + HAVE_STRUCT_TIMEVAL=0 + fi + AC_SUBST([HAVE_STRUCT_TIMEVAL]) + + dnl Assume POSIX behavior unless another module says otherwise. + HAVE_GETTIMEOFDAY_POSIX_SIGNATURE=1 + AC_SUBST([HAVE_GETTIMEOFDAY_POSIX_SIGNATURE]) + GETTIMEOFDAY_CLOBBERS_LOCALTIME=0 + AC_SUBST([GETTIMEOFDAY_CLOBBERS_LOCALTIME]) +]) diff --git a/m4/timespec.m4 b/m4/timespec.m4 index c281128c2..3305fd731 100644 --- a/m4/timespec.m4 +++ b/m4/timespec.m4 @@ -1,6 +1,6 @@ -#serial 12 +#serial 13 -# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software +# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software # Foundation, Inc. # This file is free software; the Free Software Foundation @@ -13,7 +13,6 @@ AC_DEFUN([gl_TIMESPEC], [ dnl Prerequisites of lib/timespec.h. AC_REQUIRE([AC_C_INLINE]) - AC_REQUIRE([AC_HEADER_TIME]) AC_CHECK_HEADERS_ONCE(sys/time.h) gl_CHECK_TYPE_STRUCT_TIMESPEC @@ -31,28 +30,20 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], dnl Persuade pedantic Solaris to declare struct timespec. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([AC_HEADER_TIME]) AC_CHECK_HEADERS_ONCE(sys/time.h) - AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec, - [AC_TRY_COMPILE( - [ -# if TIME_WITH_SYS_TIME -# include -# include -# else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -# endif - ], - [static struct timespec x; x.tv_sec = x.tv_nsec;], - fu_cv_sys_struct_timespec=yes, - fu_cv_sys_struct_timespec=no) - ]) - - if test $fu_cv_sys_struct_timespec = yes; then + AC_CACHE_CHECK([for struct timespec], [gl_cv_sys_struct_timespec], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SYS_TIME_H + #include + #endif + #include + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec=yes], + [gl_cv_sys_struct_timespec=no])]) + + if test $gl_cv_sys_struct_timespec = yes; then AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [Define if struct timespec is declared in . ]) fi diff --git a/m4/tzset.m4 b/m4/tzset.m4 index 134080c54..b8c111b0f 100644 --- a/m4/tzset.m4 +++ b/m4/tzset.m4 @@ -1,6 +1,6 @@ -#serial 2 +#serial 3 -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2007 Free Software Foundation, Inc. # 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. @@ -15,21 +15,12 @@ AC_DEFUN([gl_FUNC_TZSET_CLOBBER], [ - AC_REQUIRE([AC_HEADER_TIME]) + AC_REQUIRE([gl_HEADER_SYS_TIME_H]) AC_CACHE_CHECK([whether tzset clobbers localtime buffer], gl_cv_func_tzset_clobber, [ AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif +#include #include int @@ -42,12 +33,12 @@ main () s = *p; putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"); tzset (); - exit (p->tm_year != s.tm_year - || p->tm_mon != s.tm_mon - || p->tm_mday != s.tm_mday - || p->tm_hour != s.tm_hour - || p->tm_min != s.tm_min - || p->tm_sec != s.tm_sec); + return (p->tm_year != s.tm_year + || p->tm_mon != s.tm_mon + || p->tm_mday != s.tm_mday + || p->tm_hour != s.tm_hour + || p->tm_min != s.tm_min + || p->tm_sec != s.tm_sec); } ]])], [gl_cv_func_tzset_clobber=no], @@ -62,7 +53,7 @@ main () AC_DEFINE(tzset, rpl_tzset, [Define to rpl_tzset if the wrapper function should be used.]) - AC_DEFINE(TZSET_CLOBBERS_LOCALTIME_BUFFER, 1, + AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], 1, [Define if tzset clobbers localtime's static buffer.]) fi ]) diff --git a/m4/utimbuf.m4 b/m4/utimbuf.m4 index 56f1bce66..9927908ff 100644 --- a/m4/utimbuf.m4 +++ b/m4/utimbuf.m4 @@ -1,6 +1,6 @@ -#serial 7 +#serial 8 -# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004 Free Software +# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2007 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation @@ -16,30 +16,22 @@ dnl Some systems have utime.h but don't declare the struct anywhere. AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF], [ AC_CHECK_HEADERS_ONCE(sys/time.h utime.h) - AC_REQUIRE([AC_HEADER_TIME]) - AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf, - [AC_TRY_COMPILE( - [ -#ifdef TIME_WITH_SYS_TIME -# include -# include -#else -# ifdef HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif -#ifdef HAVE_UTIME_H -# include -#endif - ], - [static struct utimbuf x; x.actime = x.modtime;], - fu_cv_sys_struct_utimbuf=yes, - fu_cv_sys_struct_utimbuf=no) - ]) + AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#if HAVE_SYS_TIME_H + #include + #endif + #include + #ifdef HAVE_UTIME_H + #include + #endif + ]], + [[static struct utimbuf x; x.actime = x.modtime;]])], + [gl_cv_sys_struct_utimbuf=yes], + [gl_cv_sys_struct_utimbuf=no])]) - if test $fu_cv_sys_struct_utimbuf = yes; then + if test $gl_cv_sys_struct_utimbuf = yes; then AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1, [Define if struct utimbuf is declared -- usually in . Some systems have utime.h but don't declare the struct anywhere. ]) diff --git a/modules/gethrxtime b/modules/gethrxtime index 2eea8b400..3de2ee495 100644 --- a/modules/gethrxtime +++ b/modules/gethrxtime @@ -10,8 +10,9 @@ m4/longlong.m4 Depends-on: clock-time -gettime extensions +gettime +sys_time configure.ac: gl_GETHRXTIME diff --git a/modules/gettime b/modules/gettime index f787a78a3..2e2c52e34 100644 --- a/modules/gettime +++ b/modules/gettime @@ -9,6 +9,7 @@ Depends-on: clock-time gettime gettimeofday +sys_time timespec extensions diff --git a/modules/gettimeofday b/modules/gettimeofday index 9b9b35a47..d9821d4b1 100644 --- a/modules/gettimeofday +++ b/modules/gettimeofday @@ -2,11 +2,11 @@ Description: gettimeofday() function: return current time. Files: -lib/gettimeofday.h lib/gettimeofday.c m4/gettimeofday.m4 Depends-on: +sys_time configure.ac: gl_FUNC_GETTIMEOFDAY @@ -14,11 +14,10 @@ gl_FUNC_GETTIMEOFDAY Makefile.am: Include: -"gettimeofday.h" + License: GPL Maintainer: -Jim Meyering - +Paul Eggert, Jim Meyering diff --git a/modules/nanosleep b/modules/nanosleep index 64cc02e47..02398d407 100644 --- a/modules/nanosleep +++ b/modules/nanosleep @@ -7,9 +7,10 @@ m4/nanosleep.m4 Depends-on: clock-time -timespec -stdbool extensions +stdbool +sys_time +timespec configure.ac: gl_FUNC_NANOSLEEP diff --git a/modules/settime b/modules/settime index 6f33653f9..9ca84a027 100644 --- a/modules/settime +++ b/modules/settime @@ -8,6 +8,7 @@ m4/settime.m4 Depends-on: clock-time extensions +sys_time timespec configure.ac: diff --git a/modules/sys_time b/modules/sys_time new file mode 100644 index 000000000..16a227eb2 --- /dev/null +++ b/modules/sys_time @@ -0,0 +1,40 @@ +Description: +A that conforms better to POSIX. + +Files: +lib/sys_time_.h +m4/sys_time_h.m4 + +Depends-on: +absolute-header + +configure.ac: +gl_HEADER_SYS_TIME_H + +Makefile.am: +BUILT_SOURCES += sys/time.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +sys/time.h: sys_time_.h + test -d sys || mkdir sys + rm -f $@-t $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ + -e 's|@''ABSOLUTE_SYS_TIME_H''@|$(ABSOLUTE_SYS_TIME_H)|g' \ + -e 's/@''GETTIMEOFDAY_CLOBBERS_LOCALTIME''@/$(GETTIMEOFDAY_CLOBBERS_LOCALTIME)/g' \ + -e 's/@''HAVE_GETTIMEOFDAY_POSIX_SIGNATURE''@/$(HAVE_GETTIMEOFDAY_POSIX_SIGNATURE)/g' \ + -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \ + < $(srcdir)/sys_time_.h; \ + } > $@-t + mv $@-t $@ +MOSTLYCLEANFILES += sys/time.h sys/time.h-t + +Include: +#include + +License: +LGPL + +Maintainer: +all diff --git a/modules/tempname b/modules/tempname index 9b619a31c..af689de6f 100644 --- a/modules/tempname +++ b/modules/tempname @@ -8,8 +8,10 @@ m4/tempname.m4 Depends-on: extensions +gettimeofday stdint sys_stat +sys_time configure.ac: gl_FUNC_GEN_TEMPNAME diff --git a/modules/utimens b/modules/utimens index 6cc5e3122..c341f6577 100644 --- a/modules/utimens +++ b/modules/utimens @@ -9,6 +9,7 @@ m4/utimens.m4 m4/utimes.m4 Depends-on: +sys_time timespec configure.ac: diff --git a/tests/test-gettimeofday.c b/tests/test-gettimeofday.c index e98266acd..f4735d6c0 100644 --- a/tests/test-gettimeofday.c +++ b/tests/test-gettimeofday.c @@ -19,11 +19,11 @@ #include +#include + #include #include -#include "gettimeofday.h" - suseconds_t dummy = 0; /* just to test if this type is available */ int