summaryrefslogtreecommitdiffstats
path: root/gl/timegm.c
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-02-10 10:43:20 (GMT)
committerGitHub <noreply@github.com>2023-02-10 10:43:20 (GMT)
commitc07206f2ccc2356aa74bc6813a94c2190017d44e (patch)
tree1677e5fdca5c3ce544e92c5484e16a0b68df1cc9 /gl/timegm.c
parente92046f810658016b7c373677efefda3b21400e4 (diff)
parentd2fcf49ad4afc15f37d082d7bc96a808369ec2d4 (diff)
downloadmonitoring-plugins-c07206f2ccc2356aa74bc6813a94c2190017d44e.tar.gz
Merge pull request #1832 from RincewindsHat/gnulib_update_2023
Gnulib update 2023 and attendant fixes
Diffstat (limited to 'gl/timegm.c')
-rw-r--r--gl/timegm.c62
1 files changed, 41 insertions, 21 deletions
diff --git a/gl/timegm.c b/gl/timegm.c
index 6338baa..b47025a 100644
--- a/gl/timegm.c
+++ b/gl/timegm.c
@@ -1,38 +1,58 @@
1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. 1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
2 2
3 Copyright (C) 1994, 1997, 2003-2004, 2006-2007, 2009-2013 Free Software 3 Copyright (C) 1994-2023 Free Software Foundation, Inc.
4 Foundation, Inc. This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
9 any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 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,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifndef _LIBC 20#ifndef _LIBC
20# include <config.h> 21# include <libc-config.h>
21#endif 22#endif
22 23
23#include <time.h> 24#include <time.h>
25#include <errno.h>
24 26
25#ifndef _LIBC 27#include "mktime-internal.h"
26# undef __gmtime_r 28
27# define __gmtime_r gmtime_r 29__time64_t
28# define __mktime_internal mktime_internal 30__timegm64 (struct tm *tmp)
29# include "mktime-internal.h" 31{
30#endif 32 static mktime_offset_t gmtime_offset;
33 tmp->tm_isdst = 0;
34 return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset);
35}
36
37#if defined _LIBC && __TIMESIZE != 64
38
39libc_hidden_def (__timegm64)
31 40
32time_t 41time_t
33timegm (struct tm *tmp) 42timegm (struct tm *tmp)
34{ 43{
35 static time_t gmtime_offset; 44 struct tm tm = *tmp;
36 tmp->tm_isdst = 0; 45 __time64_t t = __timegm64 (&tm);
37 return __mktime_internal (tmp, __gmtime_r, &gmtime_offset); 46 if (in_time_t_range (t))
47 {
48 *tmp = tm;
49 return t;
50 }
51 else
52 {
53 __set_errno (EOVERFLOW);
54 return -1;
55 }
38} 56}
57
58#endif