Blame gnulib/lib/time.in.h

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