aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mktime-internal.h
diff options
context:
space:
mode:
authorPaul Eggert2019-04-30 09:44:38 -0700
committerPaul Eggert2019-04-30 09:45:08 -0700
commit46b434a62cea06bdcb3c8d9ee18284ab59e9b012 (patch)
treeb14b9963adc009ecbf2f380630bf443a57f2ee87 /lib/mktime-internal.h
parent826f1e260121edc5185e0ed3fa20a781fbddc9a2 (diff)
downloademacs-46b434a62cea06bdcb3c8d9ee18284ab59e9b012.tar.gz
emacs-46b434a62cea06bdcb3c8d9ee18284ab59e9b012.zip
Update from Gnulib
* build-aux/config.guess, doc/misc/texinfo.tex: * lib/mktime-internal.h, lib/mktime.c, lib/timegm.c: Copy from Gnulib. * lib/gnulib.mk.in: Regenerate.
Diffstat (limited to 'lib/mktime-internal.h')
-rw-r--r--lib/mktime-internal.h60
1 files changed, 43 insertions, 17 deletions
diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h
index d13d89cfae7..52ab7814429 100644
--- a/lib/mktime-internal.h
+++ b/lib/mktime-internal.h
@@ -1,40 +1,56 @@
1/* mktime variant that also uses an offset guess 1/* Internals of mktime and related functions
2
3 Copyright 2016-2019 Free Software Foundation, Inc. 2 Copyright 2016-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@cs.ucla.edu>.
4 5
5 This program is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
8 version 3 of the License, or (at your option) any later version. 9 version 3 of the License, or (at your option) any later version.
9 10
10 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 14 General Public License for more details.
14 15
15 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU General Public
16 License along with this program; if not, see 17 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
18 19
19#include <time.h> 20#ifndef _LIBC
21# include <time.h>
22#endif
20 23
21/* mktime_offset_t is a signed type wide enough to hold a UTC offset 24/* mktime_offset_t is a signed type wide enough to hold a UTC offset
22 in seconds, and used as part of the type of the offset-guess 25 in seconds, and used as part of the type of the offset-guess
23 argument to mktime_internal. Use time_t on platforms where time_t 26 argument to mktime_internal. In Glibc, it is always long int.
27 When in Gnulib, use time_t on platforms where time_t
24 is signed, to be compatible with platforms like BeOS that export 28 is signed, to be compatible with platforms like BeOS that export
25 this implementation detail of mktime. On platforms where time_t is 29 this implementation detail of mktime. On platforms where time_t is
26 unsigned, GNU and POSIX code can assume 'int' is at least 32 bits 30 unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
27 which is wide enough for a UTC offset. */ 31 which is wide enough for a UTC offset. */
28 32#ifdef _LIBC
29#if TIME_T_IS_SIGNED 33typedef long int mktime_offset_t;
34#elif defined TIME_T_IS_SIGNED
30typedef time_t mktime_offset_t; 35typedef time_t mktime_offset_t;
31#else 36#else
32typedef int mktime_offset_t; 37typedef int mktime_offset_t;
33#endif 38#endif
34 39
35time_t mktime_internal (struct tm *, 40/* The source code uses identifiers like __time64_t for glibc
36 struct tm * (*) (time_t const *, struct tm *), 41 timestamps that can contain 64-bit values even when time_t is only
37 mktime_offset_t *); 42 32 bits. These are just macros for the ordinary identifiers unless
43 compiling within glibc when time_t is 32 bits. */
44#if ! (defined _LIBC && __TIMESIZE != 64)
45# undef __time64_t
46# define __time64_t time_t
47# define __gmtime64_r __gmtime_r
48# define __localtime64_r __localtime_r
49# define __mktime64 mktime
50# define __timegm64 timegm
51#endif
52
53#ifndef _LIBC
38 54
39/* Although glibc source code uses leading underscores, Gnulib wants 55/* Although glibc source code uses leading underscores, Gnulib wants
40 ordinary names. 56 ordinary names.
@@ -45,9 +61,19 @@ time_t mktime_internal (struct tm *,
45 Similarly for gmtime_r. See the gnulib time_r module for one way 61 Similarly for gmtime_r. See the gnulib time_r module for one way
46 to implement this. */ 62 to implement this. */
47 63
48#undef __gmtime_r 64# undef __gmtime_r
49#undef __localtime_r 65# undef __localtime_r
50#define __gmtime_r gmtime_r 66# define __gmtime_r gmtime_r
51#define __localtime_r localtime_r 67# define __localtime_r localtime_r
68
69# define __mktime_internal mktime_internal
70
71#endif
52 72
53#define __mktime_internal mktime_internal 73/* Subroutine of mktime. Return the time_t representation of TP and
74 normalize TP, given that a struct tm * maps to a time_t as performed
75 by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */
76extern __time64_t __mktime_internal (struct tm *tp,
77 struct tm *(*func) (__time64_t const *,
78 struct tm *),
79 mktime_offset_t *offset) attribute_hidden;