Blame lib/time.in.h

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