Blame gl/time.in.h

Packit 549fdc
/* A more-standard <time.h>.
Packit 549fdc
Packit 549fdc
   Copyright (C) 2007-2016 Free Software Foundation, Inc.
Packit 549fdc
Packit 549fdc
   This program is free software; you can redistribute it and/or modify
Packit 549fdc
   it under the terms of the GNU Lesser General Public License as published by
Packit 549fdc
   the Free Software Foundation; either version 2.1, or (at your option)
Packit 549fdc
   any later version.
Packit 549fdc
Packit 549fdc
   This program is distributed in the hope that it will be useful,
Packit 549fdc
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 549fdc
   GNU Lesser General Public License for more details.
Packit 549fdc
Packit 549fdc
   You should have received a copy of the GNU Lesser General Public License
Packit 549fdc
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 549fdc
Packit 549fdc
#if __GNUC__ >= 3
Packit 549fdc
@PRAGMA_SYSTEM_HEADER@
Packit 549fdc
#endif
Packit 549fdc
@PRAGMA_COLUMNS@
Packit 549fdc
Packit 549fdc
/* Don't get in the way of glibc when it includes time.h merely to
Packit 549fdc
   declare a few standard symbols, rather than to declare all the
Packit 549fdc
   symbols.  (However, skip this for MinGW as it treats __need_time_t
Packit 549fdc
   incompatibly.)  Also, Solaris 8 <time.h> eventually includes itself
Packit 549fdc
   recursively; if that is happening, just include the system <time.h>
Packit 549fdc
   without adding our own declarations.  */
Packit 549fdc
#if (((defined __need_time_t || defined __need_clock_t \
Packit 549fdc
       || defined __need_timespec)                     \
Packit 549fdc
      && !defined __MINGW32__)                         \
Packit 549fdc
     || defined _@GUARD_PREFIX@_TIME_H)
Packit 549fdc
Packit 549fdc
# @INCLUDE_NEXT@ @NEXT_TIME_H@
Packit 549fdc
Packit 549fdc
#else
Packit 549fdc
Packit 549fdc
# define _@GUARD_PREFIX@_TIME_H
Packit 549fdc
Packit 549fdc
# @INCLUDE_NEXT@ @NEXT_TIME_H@
Packit 549fdc
Packit 549fdc
/* NetBSD 5.0 mis-defines NULL.  */
Packit 549fdc
# include <stddef.h>
Packit 549fdc
Packit 549fdc
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit 549fdc
Packit 549fdc
/* The definition of _GL_ARG_NONNULL is copied here.  */
Packit 549fdc
Packit 549fdc
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit 549fdc
Packit 549fdc
/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
Packit 549fdc
   Or they define it with the wrong member names or define it in <sys/time.h>
Packit 549fdc
   (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
Packit 549fdc
   but the pthreads-win32 library defines it in <pthread.h>.  */
Packit 549fdc
# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
Packit 549fdc
#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
Packit 549fdc
#   include <sys/time.h>
Packit 549fdc
#  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
Packit 549fdc
#   include <pthread.h>
Packit 549fdc
#  elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
Packit 549fdc
#   include <unistd.h>
Packit 549fdc
#  else
Packit 549fdc
Packit 549fdc
#   ifdef __cplusplus
Packit 549fdc
extern "C" {
Packit 549fdc
#   endif
Packit 549fdc
Packit 549fdc
#   if !GNULIB_defined_struct_timespec
Packit 549fdc
#    undef timespec
Packit 549fdc
#    define timespec rpl_timespec
Packit 549fdc
struct timespec
Packit 549fdc
{
Packit 549fdc
  time_t tv_sec;
Packit 549fdc
  long int tv_nsec;
Packit 549fdc
};
Packit 549fdc
#    define GNULIB_defined_struct_timespec 1
Packit 549fdc
#   endif
Packit 549fdc
Packit 549fdc
#   ifdef __cplusplus
Packit 549fdc
}
Packit 549fdc
#   endif
Packit 549fdc
Packit 549fdc
#  endif
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
# if !GNULIB_defined_struct_time_t_must_be_integral
Packit 549fdc
/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
Packit 549fdc
   time_t to be an integer type, even though C99 permits floating
Packit 549fdc
   point.  We don't know of any implementation that uses floating
Packit 549fdc
   point, and it is much easier to write code that doesn't have to
Packit 549fdc
   worry about that corner case, so we force the issue.  */
Packit 549fdc
struct __time_t_must_be_integral {
Packit 549fdc
  unsigned int __floating_time_t_unsupported : (time_t) 1;
Packit 549fdc
};
Packit 549fdc
#  define GNULIB_defined_struct_time_t_must_be_integral 1
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
Packit 549fdc
   return -1 and store the remaining time into RMTP.  See
Packit 549fdc
   <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
Packit 549fdc
# if @GNULIB_NANOSLEEP@
Packit 549fdc
#  if @REPLACE_NANOSLEEP@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    define nanosleep rpl_nanosleep
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (nanosleep, int,
Packit 549fdc
                  (struct timespec const *__rqtp, struct timespec *__rmtp)
Packit 549fdc
                  _GL_ARG_NONNULL ((1)));
Packit 549fdc
_GL_CXXALIAS_RPL (nanosleep, int,
Packit 549fdc
                  (struct timespec const *__rqtp, struct timespec *__rmtp));
Packit 549fdc
#  else
Packit 549fdc
#   if ! @HAVE_NANOSLEEP@
Packit 549fdc
_GL_FUNCDECL_SYS (nanosleep, int,
Packit 549fdc
                  (struct timespec const *__rqtp, struct timespec *__rmtp)
Packit 549fdc
                  _GL_ARG_NONNULL ((1)));
Packit 549fdc
#   endif
Packit 549fdc
_GL_CXXALIAS_SYS (nanosleep, int,
Packit 549fdc
                  (struct timespec const *__rqtp, struct timespec *__rmtp));
Packit 549fdc
#  endif
Packit 549fdc
_GL_CXXALIASWARN (nanosleep);
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Return the 'time_t' representation of TP and normalize TP.  */
Packit 549fdc
# if @GNULIB_MKTIME@
Packit 549fdc
#  if @REPLACE_MKTIME@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    define mktime rpl_mktime
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
Packit 549fdc
_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
Packit 549fdc
#  else
Packit 549fdc
_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
Packit 549fdc
#  endif
Packit 549fdc
_GL_CXXALIASWARN (mktime);
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
Packit 549fdc
   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
Packit 549fdc
   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
Packit 549fdc
# if @GNULIB_TIME_R@
Packit 549fdc
#  if @REPLACE_LOCALTIME_R@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    undef localtime_r
Packit 549fdc
#    define localtime_r rpl_localtime_r
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                             struct tm *restrict __result)
Packit 549fdc
                                            _GL_ARG_NONNULL ((1, 2)));
Packit 549fdc
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                             struct tm *restrict __result));
Packit 549fdc
#  else
Packit 549fdc
#   if ! @HAVE_DECL_LOCALTIME_R@
Packit 549fdc
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                             struct tm *restrict __result)
Packit 549fdc
                                            _GL_ARG_NONNULL ((1, 2)));
Packit 549fdc
#   endif
Packit 549fdc
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                             struct tm *restrict __result));
Packit 549fdc
#  endif
Packit 549fdc
#  if @HAVE_DECL_LOCALTIME_R@
Packit 549fdc
_GL_CXXALIASWARN (localtime_r);
Packit 549fdc
#  endif
Packit 549fdc
#  if @REPLACE_LOCALTIME_R@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    undef gmtime_r
Packit 549fdc
#    define gmtime_r rpl_gmtime_r
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                          struct tm *restrict __result)
Packit 549fdc
                                         _GL_ARG_NONNULL ((1, 2)));
Packit 549fdc
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                          struct tm *restrict __result));
Packit 549fdc
#  else
Packit 549fdc
#   if ! @HAVE_DECL_LOCALTIME_R@
Packit 549fdc
_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                          struct tm *restrict __result)
Packit 549fdc
                                         _GL_ARG_NONNULL ((1, 2)));
Packit 549fdc
#   endif
Packit 549fdc
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
Packit 549fdc
                                          struct tm *restrict __result));
Packit 549fdc
#  endif
Packit 549fdc
#  if @HAVE_DECL_LOCALTIME_R@
Packit 549fdc
_GL_CXXALIASWARN (gmtime_r);
Packit 549fdc
#  endif
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
Packit 549fdc
   <http://www.opengroup.org/susv3xsh/localtime.html> and
Packit 549fdc
   <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
Packit 549fdc
# if @GNULIB_GETTIMEOFDAY@
Packit 549fdc
#  if @REPLACE_LOCALTIME@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    undef localtime
Packit 549fdc
#    define localtime rpl_localtime
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
Packit 549fdc
		                          _GL_ARG_NONNULL ((1)));
Packit 549fdc
_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
Packit 549fdc
#  else
Packit 549fdc
_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
Packit 549fdc
#  endif
Packit 549fdc
_GL_CXXALIASWARN (localtime);
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
# if @GNULIB_GETTIMEOFDAY@
Packit 549fdc
#  if @REPLACE_GMTIME@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    undef gmtime
Packit 549fdc
#    define gmtime rpl_gmtime
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
Packit 549fdc
                                       _GL_ARG_NONNULL ((1)));
Packit 549fdc
_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
Packit 549fdc
#  else
Packit 549fdc
_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
Packit 549fdc
#  endif
Packit 549fdc
_GL_CXXALIASWARN (gmtime);
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
Packit 549fdc
   the resulting broken-down time into TM.  See
Packit 549fdc
   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
Packit 549fdc
# if @GNULIB_STRPTIME@
Packit 549fdc
#  if ! @HAVE_STRPTIME@
Packit 549fdc
_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
Packit 549fdc
                                     char const *restrict __format,
Packit 549fdc
                                     struct tm *restrict __tm)
Packit 549fdc
                                    _GL_ARG_NONNULL ((1, 2, 3)));
Packit 549fdc
#  endif
Packit 549fdc
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
Packit 549fdc
                                     char const *restrict __format,
Packit 549fdc
                                     struct tm *restrict __tm));
Packit 549fdc
_GL_CXXALIASWARN (strptime);
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
Packit 549fdc
typedef struct tm_zone *timezone_t;
Packit 549fdc
_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
Packit 549fdc
_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
Packit 549fdc
_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
Packit 549fdc
_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
Packit 549fdc
_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
Packit 549fdc
                  (timezone_t __tz, time_t const *restrict __timer,
Packit 549fdc
                   struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
Packit 549fdc
_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
Packit 549fdc
                  (timezone_t __tz, time_t const *restrict __timer,
Packit 549fdc
                   struct tm *restrict __result));
Packit 549fdc
_GL_FUNCDECL_SYS (mktime_z, time_t,
Packit 549fdc
                  (timezone_t __tz, struct tm *restrict __result)
Packit 549fdc
                  _GL_ARG_NONNULL ((2)));
Packit 549fdc
_GL_CXXALIAS_SYS (mktime_z, time_t,
Packit 549fdc
                  (timezone_t __tz, struct tm *restrict __result));
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Convert TM to a time_t value, assuming UTC.  */
Packit 549fdc
# if @GNULIB_TIMEGM@
Packit 549fdc
#  if @REPLACE_TIMEGM@
Packit 549fdc
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit 549fdc
#    undef timegm
Packit 549fdc
#    define timegm rpl_timegm
Packit 549fdc
#   endif
Packit 549fdc
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
Packit 549fdc
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
Packit 549fdc
#  else
Packit 549fdc
#   if ! @HAVE_TIMEGM@
Packit 549fdc
_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
Packit 549fdc
#   endif
Packit 549fdc
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
Packit 549fdc
#  endif
Packit 549fdc
_GL_CXXALIASWARN (timegm);
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
/* Encourage applications to avoid unsafe functions that can overrun
Packit 549fdc
   buffers when given outlandish struct tm values.  Portable
Packit 549fdc
   applications should use strftime (or even sprintf) instead.  */
Packit 549fdc
# if defined GNULIB_POSIXCHECK
Packit 549fdc
#  undef asctime
Packit 549fdc
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
Packit 549fdc
                 "better use strftime (or even sprintf) instead");
Packit 549fdc
# endif
Packit 549fdc
# if defined GNULIB_POSIXCHECK
Packit 549fdc
#  undef asctime_r
Packit 549fdc
_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
Packit 549fdc
                 "better use strftime (or even sprintf) instead");
Packit 549fdc
# endif
Packit 549fdc
# if defined GNULIB_POSIXCHECK
Packit 549fdc
#  undef ctime
Packit 549fdc
_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
Packit 549fdc
                 "better use strftime (or even sprintf) instead");
Packit 549fdc
# endif
Packit 549fdc
# if defined GNULIB_POSIXCHECK
Packit 549fdc
#  undef ctime_r
Packit 549fdc
_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
Packit 549fdc
                 "better use strftime (or even sprintf) instead");
Packit 549fdc
# endif
Packit 549fdc
Packit 549fdc
#endif