Mercurial > gnulib
annotate lib/gettime.c @ 40231:9b3c79fdfe0b
strtod: fix clash with strtold
Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817).
* lib/strtod.c (compute_minus_zero, minus_zero):
Simplify by remving the macro / external variable,
and having just a function. User changed. This avoids
the need for an external variable that might clash.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 11 Mar 2019 16:40:29 -0700 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
3768 | 1 /* gettime -- get the system clock |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6527
diff
changeset
|
2 |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
39850
diff
changeset
|
3 Copyright (C) 2002, 2004-2007, 2009-2019 Free Software Foundation, Inc. |
3768 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7897
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
3768 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7897
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7897
diff
changeset
|
8 (at your option) any later version. |
3768 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
19190 | 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
3768 | 17 |
18 /* Written by Paul Eggert. */ | |
19 | |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6527
diff
changeset
|
20 #include <config.h> |
3768 | 21 |
22 #include "timespec.h" | |
23 | |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
24 #include <sys/time.h> |
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7302
diff
changeset
|
25 |
5662
42df9db003cc
* modules/gethrxtime: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5059
diff
changeset
|
26 /* Get the system time into *TS. */ |
3768 | 27 |
5662
42df9db003cc
* modules/gethrxtime: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5059
diff
changeset
|
28 void |
3768 | 29 gettime (struct timespec *ts) |
30 { | |
39847
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
31 #if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
32 clock_gettime (CLOCK_REALTIME, ts); |
5662
42df9db003cc
* modules/gethrxtime: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5059
diff
changeset
|
33 #else |
39847
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
34 struct timeval tv; |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
35 gettimeofday (&tv, NULL); |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
36 ts->tv_sec = tv.tv_sec; |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
37 ts->tv_nsec = tv.tv_usec * 1000; |
5662
42df9db003cc
* modules/gethrxtime: New file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5059
diff
changeset
|
38 #endif |
3768 | 39 } |
39847
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
40 |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
41 /* Return the current system time as a struct timespec. */ |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
42 |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
43 struct timespec |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
44 current_timespec (void) |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
45 { |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
46 struct timespec ts; |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
47 gettime (&ts); |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
48 return ts; |
7245e73971d4
timespec: new function current_timespec
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
49 } |