Annotation of embedaddon/libiconv/srclib/time.in.h, revision 1.1.1.2

1.1       misho       1: /* A more-standard <time.h>.
                      2: 
1.1.1.2 ! misho       3:    Copyright (C) 2007-2019 Free Software Foundation, Inc.
1.1       misho       4: 
                      5:    This program is free software; you can redistribute it and/or modify
                      6:    it under the terms of the GNU General Public License as published by
                      7:    the Free Software Foundation; either version 3, or (at your option)
                      8:    any later version.
                      9: 
                     10:    This program is distributed in the hope that it will be useful,
                     11:    but WITHOUT ANY WARRANTY; without even the implied warranty of
                     12:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     13:    GNU General Public License for more details.
                     14: 
                     15:    You should have received a copy of the GNU General Public License
1.1.1.2 ! misho      16:    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
1.1       misho      17: 
                     18: #if __GNUC__ >= 3
                     19: @PRAGMA_SYSTEM_HEADER@
                     20: #endif
                     21: @PRAGMA_COLUMNS@
                     22: 
                     23: /* Don't get in the way of glibc when it includes time.h merely to
                     24:    declare a few standard symbols, rather than to declare all the
1.1.1.2 ! misho      25:    symbols.  (However, skip this for MinGW as it treats __need_time_t
        !            26:    incompatibly.)  Also, Solaris 8 <time.h> eventually includes itself
1.1       misho      27:    recursively; if that is happening, just include the system <time.h>
                     28:    without adding our own declarations.  */
1.1.1.2 ! misho      29: #if (((defined __need_time_t || defined __need_clock_t \
        !            30:        || defined __need_timespec)                     \
        !            31:       && !defined __MINGW32__)                         \
1.1       misho      32:      || defined _@GUARD_PREFIX@_TIME_H)
                     33: 
                     34: # @INCLUDE_NEXT@ @NEXT_TIME_H@
                     35: 
                     36: #else
                     37: 
                     38: # define _@GUARD_PREFIX@_TIME_H
                     39: 
                     40: # @INCLUDE_NEXT@ @NEXT_TIME_H@
                     41: 
                     42: /* NetBSD 5.0 mis-defines NULL.  */
                     43: # include <stddef.h>
                     44: 
                     45: /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
                     46: 
                     47: /* The definition of _GL_ARG_NONNULL is copied here.  */
                     48: 
                     49: /* The definition of _GL_WARN_ON_USE is copied here.  */
                     50: 
1.1.1.2 ! misho      51: /* Some systems don't define struct timespec (e.g., AIX 4.1).
1.1       misho      52:    Or they define it with the wrong member names or define it in <sys/time.h>
1.1.1.2 ! misho      53:    (e.g., FreeBSD circa 1997).  Stock Mingw prior to 3.0 does not define it,
        !            54:    but the pthreads-win32 library defines it in <pthread.h>.  */
1.1       misho      55: # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
                     56: #  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
                     57: #   include <sys/time.h>
                     58: #  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
                     59: #   include <pthread.h>
1.1.1.2 ! misho      60: #  elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
        !            61: #   include <unistd.h>
1.1       misho      62: #  else
                     63: 
                     64: #   ifdef __cplusplus
                     65: extern "C" {
                     66: #   endif
                     67: 
                     68: #   if !GNULIB_defined_struct_timespec
                     69: #    undef timespec
                     70: #    define timespec rpl_timespec
                     71: struct timespec
                     72: {
                     73:   time_t tv_sec;
                     74:   long int tv_nsec;
                     75: };
                     76: #    define GNULIB_defined_struct_timespec 1
                     77: #   endif
                     78: 
                     79: #   ifdef __cplusplus
                     80: }
                     81: #   endif
                     82: 
                     83: #  endif
                     84: # endif
                     85: 
                     86: # if !GNULIB_defined_struct_time_t_must_be_integral
                     87: /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
                     88:    time_t to be an integer type, even though C99 permits floating
                     89:    point.  We don't know of any implementation that uses floating
                     90:    point, and it is much easier to write code that doesn't have to
                     91:    worry about that corner case, so we force the issue.  */
                     92: struct __time_t_must_be_integral {
                     93:   unsigned int __floating_time_t_unsupported : (time_t) 1;
                     94: };
                     95: #  define GNULIB_defined_struct_time_t_must_be_integral 1
                     96: # endif
                     97: 
                     98: /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
                     99:    return -1 and store the remaining time into RMTP.  See
                    100:    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
                    101: # if @GNULIB_NANOSLEEP@
                    102: #  if @REPLACE_NANOSLEEP@
                    103: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
                    104: #    define nanosleep rpl_nanosleep
                    105: #   endif
                    106: _GL_FUNCDECL_RPL (nanosleep, int,
                    107:                   (struct timespec const *__rqtp, struct timespec *__rmtp)
                    108:                   _GL_ARG_NONNULL ((1)));
                    109: _GL_CXXALIAS_RPL (nanosleep, int,
                    110:                   (struct timespec const *__rqtp, struct timespec *__rmtp));
                    111: #  else
                    112: #   if ! @HAVE_NANOSLEEP@
                    113: _GL_FUNCDECL_SYS (nanosleep, int,
                    114:                   (struct timespec const *__rqtp, struct timespec *__rmtp)
                    115:                   _GL_ARG_NONNULL ((1)));
                    116: #   endif
                    117: _GL_CXXALIAS_SYS (nanosleep, int,
                    118:                   (struct timespec const *__rqtp, struct timespec *__rmtp));
                    119: #  endif
                    120: _GL_CXXALIASWARN (nanosleep);
                    121: # endif
                    122: 
1.1.1.2 ! misho     123: /* Initialize time conversion information.  */
        !           124: # if @GNULIB_TZSET@
        !           125: #  if @REPLACE_TZSET@
        !           126: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
        !           127: #    undef tzset
        !           128: #    define tzset rpl_tzset
        !           129: #   endif
        !           130: _GL_FUNCDECL_RPL (tzset, void, (void));
        !           131: _GL_CXXALIAS_RPL (tzset, void, (void));
        !           132: #  else
        !           133: #   if ! @HAVE_TZSET@
        !           134: _GL_FUNCDECL_SYS (tzset, void, (void));
        !           135: #   endif
        !           136: _GL_CXXALIAS_SYS (tzset, void, (void));
        !           137: #  endif
        !           138: _GL_CXXALIASWARN (tzset);
        !           139: # endif
        !           140: 
1.1       misho     141: /* Return the 'time_t' representation of TP and normalize TP.  */
                    142: # if @GNULIB_MKTIME@
                    143: #  if @REPLACE_MKTIME@
                    144: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
                    145: #    define mktime rpl_mktime
                    146: #   endif
                    147: _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
                    148: _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
                    149: #  else
                    150: _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
                    151: #  endif
                    152: _GL_CXXALIASWARN (mktime);
                    153: # endif
                    154: 
                    155: /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
                    156:    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
                    157:    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
                    158: # if @GNULIB_TIME_R@
                    159: #  if @REPLACE_LOCALTIME_R@
                    160: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
                    161: #    undef localtime_r
                    162: #    define localtime_r rpl_localtime_r
                    163: #   endif
                    164: _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
                    165:                                              struct tm *restrict __result)
                    166:                                             _GL_ARG_NONNULL ((1, 2)));
                    167: _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
                    168:                                              struct tm *restrict __result));
                    169: #  else
                    170: #   if ! @HAVE_DECL_LOCALTIME_R@
                    171: _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
                    172:                                              struct tm *restrict __result)
                    173:                                             _GL_ARG_NONNULL ((1, 2)));
                    174: #   endif
                    175: _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
                    176:                                              struct tm *restrict __result));
                    177: #  endif
                    178: #  if @HAVE_DECL_LOCALTIME_R@
                    179: _GL_CXXALIASWARN (localtime_r);
                    180: #  endif
                    181: #  if @REPLACE_LOCALTIME_R@
                    182: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
                    183: #    undef gmtime_r
                    184: #    define gmtime_r rpl_gmtime_r
                    185: #   endif
                    186: _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
                    187:                                           struct tm *restrict __result)
                    188:                                          _GL_ARG_NONNULL ((1, 2)));
                    189: _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
                    190:                                           struct tm *restrict __result));
                    191: #  else
                    192: #   if ! @HAVE_DECL_LOCALTIME_R@
                    193: _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
                    194:                                           struct tm *restrict __result)
                    195:                                          _GL_ARG_NONNULL ((1, 2)));
                    196: #   endif
                    197: _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
                    198:                                           struct tm *restrict __result));
                    199: #  endif
                    200: #  if @HAVE_DECL_LOCALTIME_R@
                    201: _GL_CXXALIASWARN (gmtime_r);
                    202: #  endif
                    203: # endif
                    204: 
1.1.1.2 ! misho     205: /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
        !           206:    <http://www.opengroup.org/susv3xsh/localtime.html> and
        !           207:    <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
        !           208: # if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
        !           209: #  if @REPLACE_LOCALTIME@
        !           210: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
        !           211: #    undef localtime
        !           212: #    define localtime rpl_localtime
        !           213: #   endif
        !           214: _GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
        !           215:                                           _GL_ARG_NONNULL ((1)));
        !           216: _GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
        !           217: #  else
        !           218: _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
        !           219: #  endif
        !           220: _GL_CXXALIASWARN (localtime);
        !           221: # endif
        !           222: 
        !           223: # if 0 || @REPLACE_GMTIME@
        !           224: #  if @REPLACE_GMTIME@
        !           225: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
        !           226: #    undef gmtime
        !           227: #    define gmtime rpl_gmtime
        !           228: #   endif
        !           229: _GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
        !           230:                                        _GL_ARG_NONNULL ((1)));
        !           231: _GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
        !           232: #  else
        !           233: _GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
        !           234: #  endif
        !           235: _GL_CXXALIASWARN (gmtime);
        !           236: # endif
        !           237: 
        !           238: /* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
1.1       misho     239:    the resulting broken-down time into TM.  See
                    240:    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
                    241: # if @GNULIB_STRPTIME@
                    242: #  if ! @HAVE_STRPTIME@
                    243: _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
                    244:                                      char const *restrict __format,
                    245:                                      struct tm *restrict __tm)
                    246:                                     _GL_ARG_NONNULL ((1, 2, 3)));
                    247: #  endif
                    248: _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
                    249:                                      char const *restrict __format,
                    250:                                      struct tm *restrict __tm));
                    251: _GL_CXXALIASWARN (strptime);
                    252: # endif
                    253: 
1.1.1.2 ! misho     254: /* Convert *TP to a date and time string.  See
        !           255:    <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>.  */
        !           256: # if @GNULIB_CTIME@
        !           257: #  if @REPLACE_CTIME@
        !           258: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
        !           259: #    define ctime rpl_ctime
        !           260: #   endif
        !           261: _GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
        !           262:                                  _GL_ARG_NONNULL ((1)));
        !           263: _GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
        !           264: #  else
        !           265: _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
        !           266: #  endif
        !           267: _GL_CXXALIASWARN (ctime);
        !           268: # endif
        !           269: 
        !           270: /* Convert *TP to a date and time string.  See
        !           271:    <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>.  */
        !           272: # if @GNULIB_STRFTIME@
        !           273: #  if @REPLACE_STRFTIME@
        !           274: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
        !           275: #    define strftime rpl_strftime
        !           276: #   endif
        !           277: _GL_FUNCDECL_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
        !           278:                                      const char *__fmt, const struct tm *__tp)
        !           279:                                     _GL_ARG_NONNULL ((1, 3, 4)));
        !           280: _GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
        !           281:                                      const char *__fmt, const struct tm *__tp));
        !           282: #  else
        !           283: _GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize,
        !           284:                                      const char *__fmt, const struct tm *__tp));
        !           285: #  endif
        !           286: _GL_CXXALIASWARN (strftime);
        !           287: # endif
        !           288: 
        !           289: # if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
        !           290: typedef struct tm_zone *timezone_t;
        !           291: _GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
        !           292: _GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
        !           293: _GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
        !           294: _GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
        !           295: _GL_FUNCDECL_SYS (localtime_rz, struct tm *,
        !           296:                   (timezone_t __tz, time_t const *restrict __timer,
        !           297:                    struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
        !           298: _GL_CXXALIAS_SYS (localtime_rz, struct tm *,
        !           299:                   (timezone_t __tz, time_t const *restrict __timer,
        !           300:                    struct tm *restrict __result));
        !           301: _GL_FUNCDECL_SYS (mktime_z, time_t,
        !           302:                   (timezone_t __tz, struct tm *restrict __result)
        !           303:                   _GL_ARG_NONNULL ((2)));
        !           304: _GL_CXXALIAS_SYS (mktime_z, time_t,
        !           305:                   (timezone_t __tz, struct tm *restrict __result));
        !           306: # endif
        !           307: 
1.1       misho     308: /* Convert TM to a time_t value, assuming UTC.  */
                    309: # if @GNULIB_TIMEGM@
                    310: #  if @REPLACE_TIMEGM@
                    311: #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
                    312: #    undef timegm
                    313: #    define timegm rpl_timegm
                    314: #   endif
                    315: _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
                    316: _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
                    317: #  else
                    318: #   if ! @HAVE_TIMEGM@
                    319: _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
                    320: #   endif
                    321: _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
                    322: #  endif
                    323: _GL_CXXALIASWARN (timegm);
                    324: # endif
                    325: 
                    326: /* Encourage applications to avoid unsafe functions that can overrun
                    327:    buffers when given outlandish struct tm values.  Portable
                    328:    applications should use strftime (or even sprintf) instead.  */
                    329: # if defined GNULIB_POSIXCHECK
                    330: #  undef asctime
                    331: _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
                    332:                  "better use strftime (or even sprintf) instead");
                    333: # endif
                    334: # if defined GNULIB_POSIXCHECK
                    335: #  undef asctime_r
                    336: _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
                    337:                  "better use strftime (or even sprintf) instead");
                    338: # endif
                    339: # if defined GNULIB_POSIXCHECK
                    340: #  undef ctime
                    341: _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
                    342:                  "better use strftime (or even sprintf) instead");
                    343: # endif
                    344: # if defined GNULIB_POSIXCHECK
                    345: #  undef ctime_r
                    346: _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
                    347:                  "better use strftime (or even sprintf) instead");
                    348: # endif
                    349: 
                    350: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>