Mercurial > hg > octave-nkf > gnulib-hg
view lib/gettimeofday.c @ 16214:ec738d6aeef5
Talk about "native Windows API", not "Win32".
* lib/classpath.c: Update comments to mention native Windows.
* lib/csharpexec.c: Likewise.
* lib/dup2.c: Likewise.
* lib/error.c: Likewise.
* lib/fcntl.c: Likewise.
* lib/filename.h: Likewise.
* lib/findprog.c: Likewise.
* lib/get-rusage-as.c: Likewise.
* lib/get-rusage-data.c: Likewise.
* lib/getpagesize.c: Likewise.
* lib/javaexec.c: Likewise.
* lib/msvc-inval.c: Likewise.
* lib/msvc-nothrow.c: Likewise.
* lib/nanosleep.c: Likewise.
* lib/nonblocking.c: Likewise.
* lib/printf-parse.c: Likewise.
* lib/setlocale.c: Likewise.
* lib/sigaction.c: Likewise.
* lib/strerror_r.c: Likewise.
* lib/tmpdir.c: Likewise.
* lib/vasnprintf.c: Likewise.
* lib/w32spawn.h: Likewise.
* lib/waitpid.c: Likewise.
* lib/stdio.in.h (fdopen, fopen, freopen): Likewise.
* m4/locale-ar.m4: Likewise.
* m4/locale-fr.m4: Likewise.
* m4/locale-ja.m4: Likewise.
* m4/locale-tr.m4: Likewise.
* m4/locale-zh.m4: Likewise.
* m4/printf.m4: Likewise.
* tests/test-cloexec.c: Likewise.
* tests/test-copy-acl.sh: Likewise.
* tests/test-copy-file.sh: Likewise.
* tests/test-file-has-acl.sh: Likewise.
* tests/test-set-mode-acl.sh: Likewise.
* tests/test-dup-safer.c: Likewise.
* tests/test-dup2.c: Likewise.
* tests/test-dup3.c: Likewise.
* tests/test-fcntl.c: Likewise.
* tests/test-nonblocking-pipe.h: Likewise.
* tests/test-nonblocking-socket.h: Likewise.
* tests/test-pipe.c: Likewise.
* tests/test-pipe2.c: Likewise.
* tests/test-spawn-pipe-child.c: Likewise.
* doc/acl-resources.txt: Likewise.
* lib/getaddrinfo.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE.
* tests/test-poll.c (WINDOWS_NATIVE): Likewise.
* tests/test-select.h (WINDOWS_NATIVE): Likewise.
* lib/localcharset.c: Update comments to mention native Windows.
(WINDOWS_NATIVE): Renamed from WIN32_NATIVE.
* lib/localename.c: Likewise.
* lib/progreloc.c: Likewise.
* lib/relocatable.c: Likewise.
* lib/poll.c (WINDOWS_NATIVE): Renamed from WIN32_NATIVE.
(windows_compute_revents): Renamed from win32_compute_revents.
(windows_compute_revents_socket): Renamed from
win32_compute_revents_socket.
* lib/select.c: Update comments to mention native Windows.
(windows_poll_handle): Renamed from win32_poll_handle.
* m4/threadlib.m4: Update comments to mention native Windows.
(gl_THREADLIB_EARLY_BODY, gl_THREADLIB_BODY): Expect
--enable-threads=windows instead of --enable-threads=win32. Set
USE_WINDOWS_THREADS, not USE_WIN32_THREADS.
* lib/glthread/lock.h: Update comments to mention native Windows.
(USE_WINDOWS_THREADS): Renamed from USE_WIN32_THREADS.
* lib/glthread/lock.c (USE_WINDOWS_THREADS): Renamed from
USE_WIN32_THREADS.
* lib/glthread/cond.h (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/cond.c (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/thread.h (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/thread.c (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/tls.h (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/tls.c (USE_WINDOWS_THREADS): Likewise.
* lib/glthread/yield.h (USE_WINDOWS_THREADS): Likewise.
* tests/test-cond.c (USE_WINDOWS_THREADS): Likewise.
* tests/test-thread_create.c (USE_WINDOWS_THREADS): Likewise.
* tests/test-lock.c (USE_WINDOWS_THREADS): Likewise.
(TEST_WINDOWS_THREADS): Renamed from TEST_WIN32_THREADS.
* tests/test-tls.c: Likewise.
Rationale:
Microsoft renamed the "Win32 API" to "Windows API", as it is available
on both 32-bit and 64-bit Windows systems.
But in gnulib, we treat Cygwin like a Unix platform, therefore the main
line of distinction is between "native Windows" on one side and Unix/
POSIX systems on the other side. More details in
<https://lists.gnu.org/archive/html/bug-gnulib/2012-01/msg00027.html>.
Suggested by Paul Eggert.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 04 Jan 2012 14:31:33 +0100 |
parents | 8250f2777afc |
children | 588e064cc6e1 |
line wrap: on
line source
/* Provide gettimeofday for systems that don't have it or for which it's broken. Copyright (C) 2001-2003, 2005-2007, 2009-2012 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 Jim Meyering */ #include <config.h> /* Specification. */ #include <sys/time.h> #include <time.h> #if HAVE_SYS_TIMEB_H # include <sys/timeb.h> #endif #if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME /* 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; # undef localtime extern struct tm *localtime (time_t const *); # undef gmtime extern struct tm *gmtime (time_t const *); /* This is a wrapper for localtime. It is used only on systems for which gettimeofday clobbers the static buffer used for localtime's result. On the first call, record the address of the static buffer that localtime uses for its result. */ struct tm * rpl_localtime (time_t const *timep) { struct tm *tm = localtime (timep); if (localtime_buffer_addr == &tm_zero_buffer) localtime_buffer_addr = tm; return tm; } /* Same as above, since gmtime and localtime use the same buffer. */ struct tm * rpl_gmtime (time_t const *timep) { struct tm *tm = gmtime (timep); if (localtime_buffer_addr == &tm_zero_buffer) localtime_buffer_addr = tm; return tm; } #endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ #if TZSET_CLOBBERS_LOCALTIME # undef tzset extern void tzset (void); /* This is a wrapper for tzset, for systems on which tzset may clobber the static buffer used for localtime's result. */ void rpl_tzset (void) { /* 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 whose implementation of this function causes problems. */ int gettimeofday (struct timeval *restrict tv, void *restrict tz) { #undef gettimeofday #if HAVE_GETTIMEOFDAY # 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 int result = gettimeofday (tv, (struct timezone *) tz); # if GETTIMEOFDAY_CLOBBERS_LOCALTIME *localtime_buffer_addr = save; # endif return result; #else # if HAVE__FTIME struct _timeb timebuf; _ftime (&timebuf); tv->tv_sec = timebuf.time; tv->tv_usec = timebuf.millitm * 1000; # else # 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; # endif return 0; #endif }