1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
|
/*
Copyright (c) 1991, 1993
The Regents of the University of California. All rights reserved.
c) UNIX System Laboratories, Inc.
All or some portions of this file are derived from material licensed
to the University of California by American Telephone and Telegraph
Co. or Unix System Laboratories, Inc. and are reproduced herein with
the permission of UNIX System Laboratories, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/*
* time.h
*
* Struct and function declarations for dealing with time.
*/
#ifndef _TIME_H_
#define _TIME_H_
#include "_ansi.h"
#include <sys/cdefs.h>
#define __need_size_t
#define __need_NULL
#include <stddef.h>
/* Get _CLOCKS_PER_SEC_ */
#include <machine/time.h>
#ifndef _CLOCKS_PER_SEC_
#ifdef CLK_TCK
#define _CLOCKS_PER_SEC_ CLK_TCK
#else
#ifdef CLOCKS_PER_SEC
#define _CLOCKS_PER_SEC_ CLOCKS_PER_SEC
#else
#define _CLOCKS_PER_SEC_ 1000
#endif
#endif
#endif
#ifndef CLOCKS_PER_SEC
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
#endif
#ifndef CLK_TCK
#define CLK_TCK CLOCKS_PER_SEC
#endif
#include <sys/types.h>
#include <sys/timespec.h>
#if __POSIX_VISIBLE >= 200809
#include <sys/_locale.h>
#endif
_BEGIN_STD_C
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
#ifdef __TM_GMTOFF
long __TM_GMTOFF;
#endif
#ifdef __TM_ZONE
const char *__TM_ZONE;
#endif
};
clock_t clock (void);
double difftime (time_t _time2, time_t _time1);
time_t mktime (struct tm *_timeptr);
#if __BSD_VISIBLE || __SVID_VISIBLE || __GNU_VISIBLE
time_t timegm (struct tm *_timeptr);
#endif
time_t time (time_t *_timer);
#ifndef _REENT_ONLY
char *asctime (const struct tm *_tblock);
char *ctime (const time_t *_time);
struct tm *gmtime (const time_t *_timer);
struct tm *localtime (const time_t *_timer);
#endif
size_t strftime (char *__restrict _s,
size_t _maxsize, const char *__restrict _fmt,
const struct tm *__restrict _t);
#if __POSIX_VISIBLE >= 200809
extern size_t strftime_l (char *__restrict _s, size_t _maxsize,
const char *__restrict _fmt,
const struct tm *__restrict _t, locale_t _l);
#endif
char *asctime_r (const struct tm *__restrict,
char *__restrict);
char *ctime_r (const time_t *, char *);
struct tm *gmtime_r (const time_t *__restrict,
struct tm *__restrict);
struct tm *localtime_r (const time_t *__restrict,
struct tm *__restrict);
_END_STD_C
#ifdef __cplusplus
extern "C" {
#endif
#if __XSI_VISIBLE
char *strptime (const char *__restrict,
const char *__restrict,
struct tm *__restrict);
#endif
#if __GNU_VISIBLE
char *strptime_l (const char *__restrict, const char *__restrict,
struct tm *__restrict, locale_t);
#endif
#if __POSIX_VISIBLE
void tzset (void);
#endif
/* getdate functions */
#ifdef HAVE_GETDATE
#if __XSI_VISIBLE >= 4
#ifndef _REENT_ONLY
extern NEWLIB_THREAD_LOCAL int getdate_err;
struct tm * getdate (const char *);
/* getdate_err is set to one of the following values to indicate the error.
1 the DATEMSK environment variable is null or undefined,
2 the template file cannot be opened for reading,
3 failed to get file status information,
4 the template file is not a regular file,
5 an error is encountered while reading the template file,
6 memory allication failed (not enough memory available),
7 there is no line in the template that matches the input,
8 invalid input specification */
#endif /* !_REENT_ONLY */
#endif /* __XSI_VISIBLE >= 4 */
#if __GNU_VISIBLE
/* getdate_r returns the error code as above */
int getdate_r (const char *, struct tm *);
#endif /* __GNU_VISIBLE */
#endif /* HAVE_GETDATE */
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
#if __SVID_VISIBLE || __XSI_VISIBLE
extern __IMPORT long _timezone;
extern __IMPORT int _daylight;
#endif
#if __POSIX_VISIBLE
extern __IMPORT char *_tzname[2];
/* POSIX defines the external tzname being defined in time.h */
#ifndef tzname
#define tzname _tzname
#endif
#endif /* __POSIX_VISIBLE */
#ifdef __cplusplus
}
#endif
#include <sys/features.h>
#ifdef __CYGWIN__
#include <cygwin/time.h>
#endif /*__CYGWIN__*/
#if defined(_POSIX_TIMERS)
#include <signal.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Clocks, P1003.1b-1993, p. 263 */
int clock_settime (clockid_t clock_id, const struct timespec *tp);
int clock_gettime (clockid_t clock_id, struct timespec *tp);
int clock_getres (clockid_t clock_id, struct timespec *res);
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
int timer_create (clockid_t clock_id,
struct sigevent *__restrict evp,
timer_t *__restrict timerid);
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
int timer_delete (timer_t timerid);
/* Per-Process Timers, P1003.1b-1993, p. 267 */
int timer_settime (timer_t timerid, int flags,
const struct itimerspec *__restrict value,
struct itimerspec *__restrict ovalue);
int timer_gettime (timer_t timerid, struct itimerspec *value);
int timer_getoverrun (timer_t timerid);
/* High Resolution Sleep, P1003.1b-1993, p. 269 */
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp);
#ifdef __cplusplus
}
#endif
#endif /* _POSIX_TIMERS */
#if defined(_POSIX_CLOCK_SELECTION)
#ifdef __cplusplus
extern "C" {
#endif
int clock_nanosleep (clockid_t clock_id, int flags,
const struct timespec *rqtp, struct timespec *rmtp);
#ifdef __cplusplus
}
#endif
#endif /* _POSIX_CLOCK_SELECTION */
#ifdef __cplusplus
extern "C" {
#endif
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
/* values for the clock enable attribute */
#define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */
#define CLOCK_DISABLED 0 /* clock is disabled */
/* values for the pthread cputime_clock_allowed attribute */
#define CLOCK_ALLOWED 1 /* If a thread is created with this value a */
/* CPU-time clock attached to that thread */
/* shall be accessible. */
#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
/* thread shall not have a CPU-time clock */
/* accessible. */
/* Flag indicating time is "absolute" with respect to the clock
associated with a time. Value 4 is historic. */
#define TIMER_ABSTIME 4
/* Manifest Constants, P1003.1b-1993, p. 262 */
#if __GNU_VISIBLE
#define CLOCK_REALTIME_COARSE ((clockid_t) 0)
#endif
#define CLOCK_REALTIME ((clockid_t) 1)
/* Manifest Constants, P1003.4b/D8, p. 55 */
#if defined(_POSIX_CPUTIME)
/* When used in a clock or timer function call, this is interpreted as
the identifier of the CPU_time clock associated with the PROCESS
making the function call. */
#define CLOCK_PROCESS_CPUTIME_ID ((clockid_t) 2)
#endif
#if defined(_POSIX_THREAD_CPUTIME)
/* When used in a clock or timer function call, this is interpreted as
the identifier of the CPU_time clock associated with the THREAD
making the function call. */
#define CLOCK_THREAD_CPUTIME_ID ((clockid_t) 3)
#endif
#if defined(_POSIX_MONOTONIC_CLOCK)
/* The identifier for the system-wide monotonic clock, which is defined
* as a clock whose value cannot be set via clock_settime() and which
* cannot have backward clock jumps. */
#define CLOCK_MONOTONIC ((clockid_t) 4)
#endif
#if __GNU_VISIBLE
#define CLOCK_MONOTONIC_RAW ((clockid_t) 5)
#define CLOCK_MONOTONIC_COARSE ((clockid_t) 6)
#define CLOCK_BOOTTIME ((clockid_t) 7)
#define CLOCK_REALTIME_ALARM ((clockid_t) 8)
#define CLOCK_BOOTTIME_ALARM ((clockid_t) 9)
#endif
#if defined(_POSIX_CPUTIME)
/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
int clock_getcpuclockid (pid_t pid, clockid_t *clock_id);
#endif /* _POSIX_CPUTIME */
#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
int clock_setenable_attr (clockid_t clock_id, int attr);
int clock_getenable_attr (clockid_t clock_id, int *attr);
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
#ifdef __cplusplus
}
#endif
#endif /* _TIME_H_ */
|