modernc.org/cc@v1.0.1/v2/headers/linux_arm/usr/include/time.h (about) 1 /* Copyright (C) 1991-2016 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, see 16 <http://www.gnu.org/licenses/>. */ 17 18 /* 19 * ISO C99 Standard: 7.23 Date and time <time.h> 20 */ 21 22 #ifndef _TIME_H 23 24 #if (! defined __need_time_t && !defined __need_clock_t && \ 25 ! defined __need_timespec) 26 #define _TIME_H 1 27 #include <features.h> 28 29 __BEGIN_DECLS 30 #endif 31 #ifdef _TIME_H 32 /* Get size_t and NULL from <stddef.h>. */ 33 #define __need_size_t 34 #define __need_NULL 35 #include <stddef.h> 36 /* This defines CLOCKS_PER_SEC, which is the number of processor clock 37 ticks per second. */ 38 #include <bits/time.h> 39 /* This is the obsolete POSIX.1-1988 name for the same constant. */ 40 #if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K 41 #ifndef CLK_TCK 42 #define CLK_TCK CLOCKS_PER_SEC 43 #endif 44 #endif 45 #endif /* <time.h> included. */ 46 #if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t) 47 #define __clock_t_defined 1 48 #include <bits/types.h> 49 __BEGIN_NAMESPACE_STD 50 /* Returned by `clock'. */ 51 typedef __clock_t clock_t; 52 __END_NAMESPACE_STD 53 #if defined __USE_XOPEN || defined __USE_POSIX 54 __USING_NAMESPACE_STD(clock_t) 55 #endif 56 #endif /* clock_t not defined and <time.h> or need clock_t. */ 57 #undef __need_clock_t 58 #if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t) 59 #define __time_t_defined 1 60 #include <bits/types.h> 61 __BEGIN_NAMESPACE_STD 62 /* Returned by `time'. */ 63 typedef __time_t time_t; 64 __END_NAMESPACE_STD 65 #ifdef __USE_POSIX 66 __USING_NAMESPACE_STD(time_t) 67 #endif 68 #endif /* time_t not defined and <time.h> or need time_t. */ 69 #undef __need_time_t 70 #if !defined __clockid_t_defined && \ 71 ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_clockid_t) 72 #define __clockid_t_defined 1 73 #include <bits/types.h> 74 /* Clock ID used in clock and timer functions. */ 75 typedef __clockid_t clockid_t; 76 77 #endif /* clockid_t not defined and <time.h> or need clockid_t. */ 78 #undef __clockid_time_t 79 80 #if !defined __timer_t_defined && \ 81 ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t) 82 #define __timer_t_defined 1 83 84 #include <bits/types.h> 85 86 /* Timer ID returned by `timer_create'. */ 87 typedef __timer_t timer_t; 88 89 #endif /* timer_t not defined and <time.h> or need timer_t. */ 90 #undef __need_timer_t 91 92 #if (!defined __timespec_defined \ 93 && ((defined _TIME_H \ 94 && (defined __USE_POSIX199309 \ 95 || defined __USE_ISOC11)) \ 96 || defined __need_timespec)) 97 #define __timespec_defined 1 98 99 #include <bits/types.h> /* This defines __time_t for us. */ 100 101 /* POSIX.1b structure for a time value. This is like a `struct timeval' but 102 has nanoseconds instead of microseconds. */ 103 struct timespec { 104 __time_t tv_sec; /* Seconds. */ 105 __syscall_slong_t tv_nsec; /* Nanoseconds. */ 106 }; 107 108 #endif /* timespec not defined and <time.h> or need timespec. */ 109 #undef __need_timespec 110 111 #ifdef _TIME_H 112 __BEGIN_NAMESPACE_STD 113 /* Used by other time functions. */ 114 struct tm { 115 int tm_sec; /* Seconds. [0-60] (1 leap second) */ 116 int tm_min; /* Minutes. [0-59] */ 117 int tm_hour; /* Hours. [0-23] */ 118 int tm_mday; /* Day. [1-31] */ 119 int tm_mon; /* Month. [0-11] */ 120 int tm_year; /* Year - 1900. */ 121 int tm_wday; /* Day of week. [0-6] */ 122 int tm_yday; /* Days in year.[0-365] */ 123 int tm_isdst; /* DST. [-1/0/1] */ 124 125 #ifdef __USE_MISC 126 long int tm_gmtoff; /* Seconds east of UTC. */ 127 const char *tm_zone; /* Timezone abbreviation. */ 128 #else 129 long int __tm_gmtoff; /* Seconds east of UTC. */ 130 const char *__tm_zone; /* Timezone abbreviation. */ 131 #endif 132 }; 133 __END_NAMESPACE_STD 134 #if defined __USE_XOPEN || defined __USE_POSIX 135 __USING_NAMESPACE_STD(tm) 136 #endif 137 #ifdef __USE_POSIX199309 138 /* POSIX.1b structure for timer start values and intervals. */ 139 struct itimerspec { 140 struct timespec it_interval; 141 struct timespec it_value; 142 }; 143 144 /* We can use a simple forward declaration. */ 145 struct sigevent; 146 147 #endif /* POSIX.1b */ 148 149 #ifdef __USE_XOPEN2K 150 #ifndef __pid_t_defined 151 typedef __pid_t pid_t; 152 #define __pid_t_defined 153 #endif 154 #endif 155 156 #ifdef __USE_ISOC11 157 /* Time base values for timespec_get. */ 158 #define TIME_UTC 1 159 #endif 160 161 __BEGIN_NAMESPACE_STD 162 /* Time used by the program so far (user time + system time). 163 The result / CLOCKS_PER_SECOND is program time in seconds. */ 164 extern clock_t clock(void) __THROW; 165 166 /* Return the current time and put it in *TIMER if TIMER is not NULL. */ 167 extern time_t time(time_t * __timer) __THROW; 168 169 /* Return the difference between TIME1 and TIME0. */ 170 extern double difftime(time_t __time1, time_t __time0) 171 __THROW __attribute__ ((__const__)); 172 173 /* Return the `time_t' representation of TP and normalize TP. */ 174 extern time_t mktime(struct tm *__tp) __THROW; 175 176 /* Format TP into S according to FORMAT. 177 Write no more than MAXSIZE characters and return the number 178 of characters written, or 0 if it would exceed MAXSIZE. */ 179 extern size_t strftime(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp) __THROW; 180 __END_NAMESPACE_STD 181 #ifdef __USE_XOPEN 182 /* Parse S according to FORMAT and store binary time information in TP. 183 The return value is a pointer to the first unparsed character in S. */ 184 extern char *strptime(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp) __THROW; 185 #endif 186 187 #ifdef __USE_XOPEN2K8 188 /* Similar to the two functions above but take the information from 189 the provided locale and not the global locale. */ 190 #include <xlocale.h> 191 192 extern size_t strftime_l(char *__restrict __s, size_t __maxsize, const char *__restrict __format, const struct tm *__restrict __tp, __locale_t __loc) __THROW; 193 #endif 194 195 #ifdef __USE_GNU 196 extern char *strptime_l(const char *__restrict __s, const char *__restrict __fmt, struct tm *__tp, __locale_t __loc) __THROW; 197 #endif 198 199 __BEGIN_NAMESPACE_STD 200 /* Return the `struct tm' representation of *TIMER 201 in Universal Coordinated Time (aka Greenwich Mean Time). */ 202 extern struct tm *gmtime(const time_t * __timer) __THROW; 203 204 /* Return the `struct tm' representation 205 of *TIMER in the local timezone. */ 206 extern struct tm *localtime(const time_t * __timer) __THROW; 207 __END_NAMESPACE_STD 208 #ifdef __USE_POSIX 209 /* Return the `struct tm' representation of *TIMER in UTC, 210 using *TP to store the result. */ 211 extern struct tm *gmtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW; 212 213 /* Return the `struct tm' representation of *TIMER in local time, 214 using *TP to store the result. */ 215 extern struct tm *localtime_r(const time_t * __restrict __timer, struct tm *__restrict __tp) __THROW; 216 #endif /* POSIX */ 217 218 __BEGIN_NAMESPACE_STD 219 /* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n" 220 that is the representation of TP in this format. */ 221 extern char *asctime(const struct tm *__tp) __THROW; 222 223 /* Equivalent to `asctime (localtime (timer))'. */ 224 extern char *ctime(const time_t * __timer) __THROW; 225 __END_NAMESPACE_STD 226 #ifdef __USE_POSIX 227 /* Reentrant versions of the above functions. */ 228 /* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n" 229 that is the representation of TP in this format. */ 230 extern char *asctime_r(const struct tm *__restrict __tp, char *__restrict __buf) __THROW; 231 232 /* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */ 233 extern char *ctime_r(const time_t * __restrict __timer, char *__restrict __buf) __THROW; 234 #endif /* POSIX */ 235 236 /* Defined in localtime.c. */ 237 extern char *__tzname[2]; /* Current timezone names. */ 238 extern int __daylight; /* If daylight-saving time is ever in use. */ 239 extern long int __timezone; /* Seconds west of UTC. */ 240 241 #ifdef __USE_POSIX 242 /* Same as above. */ 243 extern char *tzname[2]; 244 245 /* Set time conversion information from the TZ environment variable. 246 If TZ is not defined, a locale-dependent default is used. */ 247 extern void tzset(void) __THROW; 248 #endif 249 250 #if defined __USE_MISC || defined __USE_XOPEN 251 extern int daylight; 252 extern long int timezone; 253 #endif 254 255 #ifdef __USE_MISC 256 /* Set the system time to *WHEN. 257 This call is restricted to the superuser. */ 258 extern int stime(const time_t * __when) __THROW; 259 #endif 260 261 /* Nonzero if YEAR is a leap year (every 4 years, 262 except every 100th isn't, and every 400th is). */ 263 #define __isleap(year) \ 264 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) 265 266 #ifdef __USE_MISC 267 /* Miscellaneous functions many Unices inherited from the public domain 268 localtime package. These are included only for compatibility. */ 269 270 /* Like `mktime', but for TP represents Universal Time, not local time. */ 271 extern time_t timegm(struct tm *__tp) __THROW; 272 273 /* Another name for `mktime'. */ 274 extern time_t timelocal(struct tm *__tp) __THROW; 275 276 /* Return the number of days in YEAR. */ 277 extern int dysize(int __year) 278 __THROW __attribute__ ((__const__)); 279 #endif 280 281 #ifdef __USE_POSIX199309 282 /* Pause execution for a number of nanoseconds. 283 284 This function is a cancellation point and therefore not marked with 285 __THROW. */ 286 extern int nanosleep(const struct timespec *__requested_time, struct timespec *__remaining); 287 288 /* Get resolution of clock CLOCK_ID. */ 289 extern int clock_getres(clockid_t __clock_id, struct timespec *__res) __THROW; 290 291 /* Get current value of clock CLOCK_ID and store it in TP. */ 292 extern int clock_gettime(clockid_t __clock_id, struct timespec *__tp) __THROW; 293 294 /* Set clock CLOCK_ID to value TP. */ 295 extern int clock_settime(clockid_t __clock_id, const struct timespec *__tp) __THROW; 296 297 #ifdef __USE_XOPEN2K 298 /* High-resolution sleep with the specified clock. 299 300 This function is a cancellation point and therefore not marked with 301 __THROW. */ 302 extern int clock_nanosleep(clockid_t __clock_id, int __flags, const struct timespec *__req, struct timespec *__rem); 303 304 /* Return clock ID for CPU-time clock. */ 305 extern int clock_getcpuclockid(pid_t __pid, clockid_t * __clock_id) __THROW; 306 #endif 307 308 /* Create new per-process timer using CLOCK_ID. */ 309 extern int timer_create(clockid_t __clock_id, struct sigevent *__restrict __evp, timer_t * __restrict __timerid) __THROW; 310 311 /* Delete timer TIMERID. */ 312 extern int timer_delete(timer_t __timerid) __THROW; 313 314 /* Set timer TIMERID to VALUE, returning old value in OVALUE. */ 315 extern int timer_settime(timer_t __timerid, int __flags, const struct itimerspec *__restrict __value, struct itimerspec *__restrict __ovalue) __THROW; 316 317 /* Get current value of timer TIMERID and store it in VALUE. */ 318 extern int timer_gettime(timer_t __timerid, struct itimerspec *__value) __THROW; 319 320 /* Get expiration overrun for timer TIMERID. */ 321 extern int timer_getoverrun(timer_t __timerid) __THROW; 322 #endif 323 324 #ifdef __USE_ISOC11 325 /* Set TS to calendar time based in time base BASE. */ 326 extern int timespec_get(struct timespec *__ts, int __base) 327 __THROW __nonnull((1)); 328 #endif 329 330 #ifdef __USE_XOPEN_EXTENDED 331 /* Set to one of the following values to indicate an error. 332 1 the DATEMSK environment variable is null or undefined, 333 2 the template file cannot be opened for reading, 334 3 failed to get file status information, 335 4 the template file is not a regular file, 336 5 an error is encountered while reading the template file, 337 6 memory allication failed (not enough memory available), 338 7 there is no line in the template that matches the input, 339 8 invalid input specification Example: February 31 or a time is 340 specified that can not be represented in a time_t (representing 341 the time in seconds since 00:00:00 UTC, January 1, 1970) */ 342 extern int getdate_err; 343 344 /* Parse the given string as a date specification and return a value 345 representing the value. The templates from the file identified by 346 the environment variable DATEMSK are used. In case of an error 347 `getdate_err' is set. 348 349 This function is a possible cancellation point and therefore not 350 marked with __THROW. */ 351 extern struct tm *getdate(const char *__string); 352 #endif 353 354 #ifdef __USE_GNU 355 /* Since `getdate' is not reentrant because of the use of `getdate_err' 356 and the static buffer to return the result in, we provide a thread-safe 357 variant. The functionality is the same. The result is returned in 358 the buffer pointed to by RESBUFP and in case of an error the return 359 value is != 0 with the same values as given above for `getdate_err'. 360 361 This function is not part of POSIX and therefore no official 362 cancellation point. But due to similarity with an POSIX interface 363 or due to the implementation it is a cancellation point and 364 therefore not marked with __THROW. */ 365 extern int getdate_r(const char *__restrict __string, struct tm *__restrict __resbufp); 366 #endif 367 368 __END_DECLS 369 #endif /* <time.h> included. */ 370 #endif /* <time.h> not already included. */