annotate lib/gettimeofday.c @ 40235:5a52ef2d4772

all: Update URLs to msdn.microsoft.com. * lib/stat-w32.c et al.: Update URLs after most of msdn.microsoft.com was moved to docs.microsoft.com.
author Bruno Haible <bruno@clisp.org>
date Thu, 14 Mar 2019 09:49:24 +0100
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7897
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
1 /* Provide gettimeofday for systems that don't have it or for which it's broken.
7302
8a1a9361108c * _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents: 6259
diff changeset
2
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 39795
diff changeset
3 Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
4
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
8 any later version.
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
9
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
13 GNU General Public License for more details.
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
14
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18890
diff changeset
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
17
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
18 /* written by Jim Meyering */
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
19
7302
8a1a9361108c * _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents: 6259
diff changeset
20 #include <config.h>
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
21
7891
83934c71372e Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents: 7890
diff changeset
22 /* Specification. */
7897
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
23 #include <sys/time.h>
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
24
7897
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
25 #include <time.h>
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
26
19595
beb2ad957aca Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
27 #if defined _WIN32 && ! defined __CYGWIN__
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
28 # define WINDOWS_NATIVE
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
29 # include <windows.h>
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
30 #endif
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
31
18846
661c3fb8962f New module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible <bruno@clisp.org>
parents: 18835
diff changeset
32 #include "localtime-buffer.h"
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
33
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
34 #ifdef WINDOWS_NATIVE
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
35
39795
ecc02d9772ef Avoid -Wcast-function-type warnings from casts after GetProcAddress.
Bruno Haible <bruno@clisp.org>
parents: 39722
diff changeset
36 /* Avoid warnings from gcc -Wcast-function-type. */
ecc02d9772ef Avoid -Wcast-function-type warnings from casts after GetProcAddress.
Bruno Haible <bruno@clisp.org>
parents: 39722
diff changeset
37 # define GetProcAddress \
ecc02d9772ef Avoid -Wcast-function-type warnings from casts after GetProcAddress.
Bruno Haible <bruno@clisp.org>
parents: 39722
diff changeset
38 (void *) GetProcAddress
ecc02d9772ef Avoid -Wcast-function-type warnings from casts after GetProcAddress.
Bruno Haible <bruno@clisp.org>
parents: 39722
diff changeset
39
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
40 /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8. */
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
41 typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
42 static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
43 static BOOL initialized = FALSE;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
44
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
45 static void
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
46 initialize (void)
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
47 {
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
48 HMODULE kernel32 = LoadLibrary ("kernel32.dll");
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
49 if (kernel32 != NULL)
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
50 {
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
51 GetSystemTimePreciseAsFileTimeFunc =
39722
f7fc45eece35 Continue to use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 19595
diff changeset
52 (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime");
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
53 }
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
54 initialized = TRUE;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
55 }
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
56
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
57 #endif
4540
fa39e8b4a0c2 Add wrappers for gmtime and tzset, too.
Paul Eggert <eggert@cs.ucla.edu>
parents: 3854
diff changeset
58
7897
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
59 /* This is a wrapper for gettimeofday. It is used only on systems
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
60 that lack this function, or whose implementation of this function
18846
661c3fb8962f New module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible <bruno@clisp.org>
parents: 18835
diff changeset
61 causes problems.
661c3fb8962f New module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible <bruno@clisp.org>
parents: 18835
diff changeset
62 Work around the bug in some systems whereby gettimeofday clobbers
661c3fb8962f New module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible <bruno@clisp.org>
parents: 18835
diff changeset
63 the static buffer that localtime uses for its return value. The
661c3fb8962f New module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible <bruno@clisp.org>
parents: 18835
diff changeset
64 gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
661c3fb8962f New module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible <bruno@clisp.org>
parents: 18835
diff changeset
65 this problem. */
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
66
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
67 int
12898
719f4dba68a8 gettimeofday: provide correct function
Eric Blake <eblake@redhat.com>
parents: 12559
diff changeset
68 gettimeofday (struct timeval *restrict tv, void *restrict tz)
7897
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
69 {
7891
83934c71372e Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents: 7890
diff changeset
70 #undef gettimeofday
18890
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
71 #ifdef WINDOWS_NATIVE
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
72
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
73 /* On native Windows, there are two ways to get the current time:
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
74 GetSystemTimeAsFileTime
40235
5a52ef2d4772 all: Update URLs to msdn.microsoft.com.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
75 <https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime>
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
76 or
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
77 GetSystemTimePreciseAsFileTime
40235
5a52ef2d4772 all: Update URLs to msdn.microsoft.com.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
78 <https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime>.
18890
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
79 GetSystemTimeAsFileTime produces values that jump by increments of
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
80 15.627 milliseconds (!) on average.
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
81 Whereas GetSystemTimePreciseAsFileTime values usually jump by 1 or 2
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
82 microseconds.
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
83 More discussion on this topic:
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
84 <http://www.windowstimestamp.com/description>. */
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
85 FILETIME current_time;
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
86
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
87 if (!initialized)
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
88 initialize ();
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
89 if (GetSystemTimePreciseAsFileTimeFunc != NULL)
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
90 GetSystemTimePreciseAsFileTimeFunc (&current_time);
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
91 else
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
92 GetSystemTimeAsFileTime (&current_time);
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
93
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
94 /* Convert from FILETIME to 'struct timeval'. */
40235
5a52ef2d4772 all: Update URLs to msdn.microsoft.com.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
95 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */
18835
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
96 ULONGLONG since_1601 =
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
97 ((ULONGLONG) current_time.dwHighDateTime << 32)
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
98 | (ULONGLONG) current_time.dwLowDateTime;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
99 /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89 leap
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
100 years, in total 134774 days. */
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
101 ULONGLONG since_1970 =
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
102 since_1601 - (ULONGLONG) 134774 * (ULONGLONG) 86400 * (ULONGLONG) 10000000;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
103 ULONGLONG microseconds_since_1970 = since_1970 / (ULONGLONG) 10;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
104 tv->tv_sec = microseconds_since_1970 / (ULONGLONG) 1000000;
f3281c8c7365 gettimeofday: Provide higher resolution on native Windows.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
105 tv->tv_usec = microseconds_since_1970 % (ULONGLONG) 1000000;
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
106
18890
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
107 return 0;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
108
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
109 #else
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
110
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
111 # if HAVE_GETTIMEOFDAY
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
112 # if GETTIMEOFDAY_CLOBBERS_LOCALTIME
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
113 /* Save and restore the contents of the buffer used for localtime's
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
114 result around the call to gettimeofday. */
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
115 struct tm save = *localtime_buffer_addr;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
116 # endif
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
117
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
118 # if defined timeval /* 'struct timeval' overridden by gnulib? */
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
119 # undef timeval
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
120 struct timeval otv;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
121 int result = gettimeofday (&otv, (struct timezone *) tz);
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
122 if (result == 0)
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
123 {
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
124 tv->tv_sec = otv.tv_sec;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
125 tv->tv_usec = otv.tv_usec;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
126 }
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
127 # else
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
128 int result = gettimeofday (tv, (struct timezone *) tz);
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
129 # endif
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
130
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
131 # if GETTIMEOFDAY_CLOBBERS_LOCALTIME
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
132 *localtime_buffer_addr = save;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
133 # endif
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
134
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
135 return result;
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
136
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
137 # else
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
138
7897
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
139 # if !defined OK_TO_USE_1S_CLOCK
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
140 # error "Only 1-second nominal clock resolution found. Is that intended?" \
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
141 "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
142 # endif
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
143 tv->tv_sec = time (NULL);
b7a83a69ac23 * MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents: 7893
diff changeset
144 tv->tv_usec = 0;
7893
195d3304eb97 Two more fixes to revised gettimeofday module.
Bruno Haible <bruno@clisp.org>
parents: 7891
diff changeset
145
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
146 return 0;
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
147
18890
6ae0ec61aeac gettimeofday: Increase precision on mingw.
Bruno Haible <bruno@clisp.org>
parents: 18846
diff changeset
148 # endif
7890
99d5ec1dbe15 Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents: 7302
diff changeset
149 #endif
3334
d13cd36d8756 *** empty log message ***
Jim Meyering <jim@meyering.net>
parents:
diff changeset
150 }