Merge pull request #1885 from franzs/feature_proxy_protocol_for_check_smtp
[monitoring-plugins.git] / gl / mktime-internal.h
blob709c36bdf56c8abc522fdfd24e10556df2be4222
1 /* Internals of mktime and related functions
2 Copyright 2016-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@cs.ucla.edu>.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
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
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
20 #ifndef _LIBC
21 # include <time.h>
22 #endif
24 /* mktime_offset_t is a signed type wide enough to hold a UTC offset
25 in seconds, and used as part of the type of the offset-guess
26 argument to mktime_internal. In Glibc, it is always long int.
27 When in Gnulib, use time_t on platforms where time_t
28 is signed, to be compatible with platforms like BeOS that export
29 this implementation detail of mktime. On platforms where time_t is
30 unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
31 which is wide enough for a UTC offset. */
32 #ifdef _LIBC
33 typedef long int mktime_offset_t;
34 #elif defined TIME_T_IS_SIGNED
35 typedef time_t mktime_offset_t;
36 #else
37 typedef int mktime_offset_t;
38 #endif
40 /* The source code uses identifiers like __time64_t for glibc
41 timestamps that can contain 64-bit values even when time_t is only
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
53 #ifndef _LIBC
55 /* Although glibc source code uses leading underscores, Gnulib wants
56 ordinary names.
58 Portable standalone applications should supply a <time.h> that
59 declares a POSIX-compliant localtime_r, for the benefit of older
60 implementations that lack localtime_r or have a nonstandard one.
61 Similarly for gmtime_r. See the gnulib time_r module for one way
62 to implement this. */
64 # undef __gmtime_r
65 # undef __localtime_r
66 # define __gmtime_r gmtime_r
67 # define __localtime_r localtime_r
69 # define __mktime_internal mktime_internal
71 #endif
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. */
76 extern __time64_t __mktime_internal (struct tm *tp,
77 struct tm *(*func) (__time64_t const *,
78 struct tm *),
79 mktime_offset_t *offset) attribute_hidden;