Back to index

nagios-plugins  1.4.16
time.in.h
Go to the documentation of this file.
00001 /* A more-standard <time.h>.
00002 
00003    Copyright (C) 2007-2010 Free Software Foundation, Inc.
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3, or (at your option)
00008    any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software Foundation,
00017    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00018 
00019 #if __GNUC__ >= 3
00020 @PRAGMA_SYSTEM_HEADER@
00021 #endif
00022 
00023 /* Don't get in the way of glibc when it includes time.h merely to
00024    declare a few standard symbols, rather than to declare all the
00025    symbols.  Also, Solaris 8 <time.h> eventually includes itself
00026    recursively; if that is happening, just include the system <time.h>
00027    without adding our own declarations.  */
00028 #if (defined __need_time_t || defined __need_clock_t \
00029      || defined __need_timespec \
00030      || defined _GL_TIME_H)
00031 
00032 # @INCLUDE_NEXT@ @NEXT_TIME_H@
00033 
00034 #else
00035 
00036 # define _GL_TIME_H
00037 
00038 # @INCLUDE_NEXT@ @NEXT_TIME_H@
00039 
00040 /* NetBSD 5.0 mis-defines NULL.  */
00041 # include <stddef.h>
00042 
00043 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
00044 
00045 /* The definition of _GL_ARG_NONNULL is copied here.  */
00046 
00047 /* The definition of _GL_WARN_ON_USE is copied here.  */
00048 
00049 /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
00050    Or they define it with the wrong member names or define it in <sys/time.h>
00051    (e.g., FreeBSD circa 1997).  Stock Mingw does not define it, but the
00052    pthreads-win32 library defines it in <pthread.h>.  */
00053 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
00054 #  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
00055 #   include <sys/time.h>
00056 #  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
00057 #   include <pthread.h>
00058 /* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
00059 #   undef asctime_r
00060 #   undef ctime_r
00061 #   undef gmtime_r
00062 #   undef localtime_r
00063 #   undef rand_r
00064 #   undef strtok_r
00065 #  else
00066 
00067 #   ifdef __cplusplus
00068 extern "C" {
00069 #   endif
00070 
00071 #   undef timespec
00072 #   define timespec rpl_timespec
00073 struct timespec
00074 {
00075   time_t tv_sec;
00076   long int tv_nsec;
00077 };
00078 
00079 #   ifdef __cplusplus
00080 }
00081 #   endif
00082 
00083 #  endif
00084 # endif
00085 
00086 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
00087    return -1 and store the remaining time into RMTP.  See
00088    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
00089 # if @GNULIB_NANOSLEEP@
00090 #  if @REPLACE_NANOSLEEP@
00091 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00092 #    define nanosleep rpl_nanosleep
00093 #   endif
00094 _GL_FUNCDECL_RPL (nanosleep, int,
00095                   (struct timespec const *__rqtp, struct timespec *__rmtp)
00096                   _GL_ARG_NONNULL ((1)));
00097 _GL_CXXALIAS_RPL (nanosleep, int,
00098                   (struct timespec const *__rqtp, struct timespec *__rmtp));
00099 #  else
00100 #   if ! @HAVE_NANOSLEEP@
00101 _GL_FUNCDECL_SYS (nanosleep, int,
00102                   (struct timespec const *__rqtp, struct timespec *__rmtp)
00103                   _GL_ARG_NONNULL ((1)));
00104 #   endif
00105 _GL_CXXALIAS_SYS (nanosleep, int,
00106                   (struct timespec const *__rqtp, struct timespec *__rmtp));
00107 #  endif
00108 _GL_CXXALIASWARN (nanosleep);
00109 # endif
00110 
00111 /* Return the 'time_t' representation of TP and normalize TP.  */
00112 # if @GNULIB_MKTIME@
00113 #  if @REPLACE_MKTIME@
00114 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00115 #    define mktime rpl_mktime
00116 #   endif
00117 _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
00118 _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
00119 #  else
00120 _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
00121 #  endif
00122 _GL_CXXALIASWARN (mktime);
00123 # endif
00124 
00125 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
00126    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
00127    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
00128 # if @GNULIB_TIME_R@
00129 #  if @REPLACE_LOCALTIME_R@
00130 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00131 #    undef localtime_r
00132 #    define localtime_r rpl_localtime_r
00133 #   endif
00134 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
00135                                              struct tm *restrict __result)
00136                                             _GL_ARG_NONNULL ((1, 2)));
00137 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
00138                                              struct tm *restrict __result));
00139 #  else
00140 #   if ! @HAVE_LOCALTIME_R@
00141 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
00142                                              struct tm *restrict __result)
00143                                             _GL_ARG_NONNULL ((1, 2)));
00144 #   endif
00145 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
00146                                              struct tm *restrict __result));
00147 #  endif
00148 _GL_CXXALIASWARN (localtime_r);
00149 #  if @REPLACE_LOCALTIME_R@
00150 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00151 #    undef gmtime_r
00152 #    define gmtime_r rpl_gmtime_r
00153 #   endif
00154 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
00155                                           struct tm *restrict __result)
00156                                          _GL_ARG_NONNULL ((1, 2)));
00157 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
00158                                           struct tm *restrict __result));
00159 #  else
00160 #   if ! @HAVE_LOCALTIME_R@
00161 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
00162                                           struct tm *restrict __result)
00163                                          _GL_ARG_NONNULL ((1, 2)));
00164 #   endif
00165 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
00166                                           struct tm *restrict __result));
00167 #  endif
00168 _GL_CXXALIASWARN (gmtime_r);
00169 # endif
00170 
00171 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
00172    the resulting broken-down time into TM.  See
00173    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
00174 # if @GNULIB_STRPTIME@
00175 #  if ! @HAVE_STRPTIME@
00176 _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
00177                                      char const *restrict __format,
00178                                      struct tm *restrict __tm)
00179                                     _GL_ARG_NONNULL ((1, 2, 3)));
00180 #  endif
00181 _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
00182                                      char const *restrict __format,
00183                                      struct tm *restrict __tm));
00184 _GL_CXXALIASWARN (strptime);
00185 # endif
00186 
00187 /* Convert TM to a time_t value, assuming UTC.  */
00188 # if @GNULIB_TIMEGM@
00189 #  if @REPLACE_TIMEGM@
00190 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
00191 #    undef timegm
00192 #    define timegm rpl_timegm
00193 #   endif
00194 _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
00195 _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
00196 #  else
00197 #   if ! @HAVE_TIMEGM@
00198 _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
00199 #   endif
00200 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
00201 #  endif
00202 _GL_CXXALIASWARN (timegm);
00203 # endif
00204 
00205 /* Encourage applications to avoid unsafe functions that can overrun
00206    buffers when given outlandish struct tm values.  Portable
00207    applications should use strftime (or even sprintf) instead.  */
00208 # if defined GNULIB_POSIXCHECK
00209 #  undef asctime
00210 _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
00211                  "better use strftime (or even sprintf) instead");
00212 # endif
00213 # if defined GNULIB_POSIXCHECK
00214 #  undef asctime_r
00215 _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
00216                  "better use strftime (or even sprintf) instead");
00217 # endif
00218 # if defined GNULIB_POSIXCHECK
00219 #  undef ctime
00220 _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
00221                  "better use strftime (or even sprintf) instead");
00222 # endif
00223 # if defined GNULIB_POSIXCHECK
00224 #  undef ctime_r
00225 _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
00226                  "better use strftime (or even sprintf) instead");
00227 # endif
00228 
00229 #endif