Blame src/gl/mktime-internal.h

Packit Service 4684c1
/* Internals of mktime and related functions
Packit Service 4684c1
   Copyright 2016-2020 Free Software Foundation, Inc.
Packit Service 4684c1
   This file is part of the GNU C Library.
Packit Service 4684c1
   Contributed by Paul Eggert <eggert@cs.ucla.edu>.
Packit Service 4684c1
Packit Service 4684c1
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 4684c1
   modify it under the terms of the GNU General Public
Packit Service 4684c1
   License as published by the Free Software Foundation; either
Packit Service 4684c1
   version 3 of the License, or (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 4684c1
   General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public
Packit Service 4684c1
   License along with the GNU C Library; if not, see
Packit Service 4684c1
   <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
#ifndef _LIBC
Packit Service 4684c1
# include <time.h>
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* mktime_offset_t is a signed type wide enough to hold a UTC offset
Packit Service 4684c1
   in seconds, and used as part of the type of the offset-guess
Packit Service 4684c1
   argument to mktime_internal.  In Glibc, it is always long int.
Packit Service 4684c1
   When in Gnulib, use time_t on platforms where time_t
Packit Service 4684c1
   is signed, to be compatible with platforms like BeOS that export
Packit Service 4684c1
   this implementation detail of mktime.  On platforms where time_t is
Packit Service 4684c1
   unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
Packit Service 4684c1
   which is wide enough for a UTC offset.  */
Packit Service 4684c1
#ifdef _LIBC
Packit Service 4684c1
typedef long int mktime_offset_t;
Packit Service 4684c1
#elif defined TIME_T_IS_SIGNED
Packit Service 4684c1
typedef time_t mktime_offset_t;
Packit Service 4684c1
#else
Packit Service 4684c1
typedef int mktime_offset_t;
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* The source code uses identifiers like __time64_t for glibc
Packit Service 4684c1
   timestamps that can contain 64-bit values even when time_t is only
Packit Service 4684c1
   32 bits.  These are just macros for the ordinary identifiers unless
Packit Service 4684c1
   compiling within glibc when time_t is 32 bits.  */
Packit Service 4684c1
#if ! (defined _LIBC && __TIMESIZE != 64)
Packit Service 4684c1
# undef __time64_t
Packit Service 4684c1
# define __time64_t time_t
Packit Service 4684c1
# define __gmtime64_r __gmtime_r
Packit Service 4684c1
# define __localtime64_r __localtime_r
Packit Service 4684c1
# define __mktime64 mktime
Packit Service 4684c1
# define __timegm64 timegm
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#ifndef _LIBC
Packit Service 4684c1
Packit Service 4684c1
/* Although glibc source code uses leading underscores, Gnulib wants
Packit Service 4684c1
   ordinary names.
Packit Service 4684c1
Packit Service 4684c1
   Portable standalone applications should supply a <time.h> that
Packit Service 4684c1
   declares a POSIX-compliant localtime_r, for the benefit of older
Packit Service 4684c1
   implementations that lack localtime_r or have a nonstandard one.
Packit Service 4684c1
   Similarly for gmtime_r.  See the gnulib time_r module for one way
Packit Service 4684c1
   to implement this.  */
Packit Service 4684c1
Packit Service 4684c1
# undef __gmtime_r
Packit Service 4684c1
# undef __localtime_r
Packit Service 4684c1
# define __gmtime_r gmtime_r
Packit Service 4684c1
# define __localtime_r localtime_r
Packit Service 4684c1
Packit Service 4684c1
# define __mktime_internal mktime_internal
Packit Service 4684c1
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* Subroutine of mktime.  Return the time_t representation of TP and
Packit Service 4684c1
   normalize TP, given that a struct tm * maps to a time_t as performed
Packit Service 4684c1
   by FUNC.  Record next guess for localtime-gmtime offset in *OFFSET.  */
Packit Service 4684c1
extern __time64_t __mktime_internal (struct tm *tp,
Packit Service 4684c1
                                     struct tm *(*func) (__time64_t const *,
Packit Service 4684c1
                                                         struct tm *),
Packit Service 4684c1
                                     mktime_offset_t *offset) attribute_hidden;