2 * Copyright 2005-2011, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
12 struct sigevent
; /* defined in <signal.h> */
15 typedef __haiku_int32
clock_t;
16 typedef __haiku_int32
time_t;
17 typedef __haiku_int32 suseconds_t
;
18 typedef __haiku_uint32 useconds_t
;
21 #define CLOCKS_PER_SEC 1000000
22 #define CLK_TCK CLOCKS_PER_SEC
24 #define MAX_TIMESTR 70
25 /* maximum length of a string returned by asctime(), and ctime() */
27 #define CLOCK_MONOTONIC ((clockid_t)0)
28 /* system-wide monotonic clock (aka system time) */
29 #define CLOCK_REALTIME ((clockid_t)-1)
30 /* system-wide real time clock */
31 #define CLOCK_PROCESS_CPUTIME_ID ((clockid_t)-2)
32 /* clock measuring the used CPU time of the current process */
33 #define CLOCK_THREAD_CPUTIME_ID ((clockid_t)-3)
34 /* clock measuring the used CPU time of the current thread */
36 #define TIMER_ABSTIME 1 /* absolute timer flag */
40 time_t tv_sec
; /* seconds */
41 long tv_nsec
; /* and nanoseconds */
45 struct timespec it_interval
;
46 struct timespec it_value
;
53 int tm_mday
; /* day of month (1 to 31) */
54 int tm_mon
; /* months since January (0 to 11) */
55 int tm_year
; /* years since 1900 */
56 int tm_wday
; /* days since Sunday (0 to 6, Sunday = 0, ...) */
57 int tm_yday
; /* days since January 1 (0 to 365) */
58 int tm_isdst
; /* daylight savings time (0 == no, >0 == yes, <0 == has to be calculated */
59 int tm_gmtoff
; /* timezone offset to GMT */
60 char *tm_zone
; /* timezone name */
64 /* special timezone support */
65 extern char *tzname
[2];
74 extern clock_t clock(void);
75 extern double difftime(time_t time1
, time_t time2
);
76 extern time_t mktime(struct tm
*tm
);
77 extern time_t time(time_t *timer
);
78 extern char *asctime(const struct tm
*tm
);
79 extern char *asctime_r(const struct tm
*timep
, char *buffer
);
80 extern char *ctime(const time_t *timer
);
81 extern char *ctime_r(const time_t *timer
, char *buffer
);
82 extern struct tm
*gmtime(const time_t *timer
);
83 extern struct tm
*gmtime_r(const time_t *timer
, struct tm
*tm
);
84 extern struct tm
*localtime(const time_t *timer
);
85 extern struct tm
*localtime_r(const time_t *timer
, struct tm
*tm
);
86 extern int nanosleep(const struct timespec
*, struct timespec
*);
87 extern size_t strftime(char *buffer
, size_t maxSize
, const char *format
,
89 extern char *strptime(const char *buf
, const char *format
, struct tm
*tm
);
92 int clock_getres(clockid_t clockID
, struct timespec
* resolution
);
93 int clock_gettime(clockid_t clockID
, struct timespec
* _time
);
94 int clock_settime(clockid_t clockID
, const struct timespec
* _time
);
95 int clock_nanosleep(clockid_t clockID
, int flags
,
96 const struct timespec
* _time
, struct timespec
* remainingTime
);
97 int clock_getcpuclockid(pid_t pid
, clockid_t
* _clockID
);
100 int timer_create(clockid_t clockID
, struct sigevent
* event
,
102 int timer_delete(timer_t timerID
);
103 int timer_gettime(timer_t timerID
, struct itimerspec
* value
);
104 int timer_settime(timer_t timerID
, int flags
,
105 const struct itimerspec
* value
, struct itimerspec
* oldValue
);
106 int timer_getoverrun(timer_t timerID
);
108 /* special timezone support */
109 extern void tzset(void);
112 extern int stime(const time_t *t
);
119 #endif /* _TIME_H_ */