2005-03-02 19:39:50 +03:00
|
|
|
/*
|
2011-06-12 04:00:23 +04:00
|
|
|
* Copyright 2005-2011, Haiku, Inc. All Rights Reserved.
|
2005-03-03 13:25:24 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-09-23 06:33:02 +04:00
|
|
|
#ifndef _TIME_H_
|
|
|
|
#define _TIME_H_
|
|
|
|
|
2002-10-23 20:06:53 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
struct sigevent; /* defined in <signal.h> */
|
|
|
|
|
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
typedef __haiku_int32 clock_t;
|
|
|
|
typedef __haiku_int32 time_t;
|
|
|
|
typedef __haiku_int32 suseconds_t;
|
|
|
|
typedef __haiku_uint32 useconds_t;
|
2002-09-23 06:33:02 +04:00
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
|
|
|
|
#define CLOCKS_PER_SEC 1000000
|
2002-09-23 06:33:02 +04:00
|
|
|
#define CLK_TCK CLOCKS_PER_SEC
|
|
|
|
|
2002-10-23 19:27:44 +04:00
|
|
|
#define MAX_TIMESTR 70
|
|
|
|
/* maximum length of a string returned by asctime(), and ctime() */
|
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
#define CLOCK_MONOTONIC ((clockid_t)0)
|
|
|
|
/* system-wide monotonic clock (aka system time) */
|
|
|
|
#define CLOCK_REALTIME ((clockid_t)-1)
|
|
|
|
/* system-wide real time clock */
|
|
|
|
#define CLOCK_PROCESS_CPUTIME_ID ((clockid_t)-2)
|
|
|
|
/* clock measuring the used CPU time of the current process */
|
|
|
|
#define CLOCK_THREAD_CPUTIME_ID ((clockid_t)-3)
|
|
|
|
/* clock measuring the used CPU time of the current thread */
|
|
|
|
|
|
|
|
#define TIMER_ABSTIME 1 /* absolute timer flag */
|
|
|
|
|
|
|
|
|
2002-10-28 21:36:26 +03:00
|
|
|
struct timespec {
|
|
|
|
time_t tv_sec; /* seconds */
|
|
|
|
long tv_nsec; /* and nanoseconds */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct itimerspec {
|
|
|
|
struct timespec it_interval;
|
|
|
|
struct timespec it_value;
|
|
|
|
};
|
|
|
|
|
2002-10-23 19:27:44 +04:00
|
|
|
struct tm {
|
|
|
|
int tm_sec;
|
|
|
|
int tm_min;
|
|
|
|
int tm_hour;
|
|
|
|
int tm_mday; /* day of month (1 to 31) */
|
|
|
|
int tm_mon; /* months since January (0 to 11) */
|
|
|
|
int tm_year; /* years since 1900 */
|
|
|
|
int tm_wday; /* days since Sunday (0 to 6, Sunday = 0, ...) */
|
|
|
|
int tm_yday; /* days since January 1 (0 to 365) */
|
|
|
|
int tm_isdst; /* daylight savings time (0 == no, >0 == yes, <0 == has to be calculated */
|
|
|
|
int tm_gmtoff; /* timezone offset to GMT */
|
|
|
|
char *tm_zone; /* timezone name */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* special timezone support */
|
|
|
|
extern char *tzname[2];
|
|
|
|
extern int daylight;
|
|
|
|
extern long timezone;
|
|
|
|
|
|
|
|
|
2002-09-23 06:33:02 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-10-23 19:27:44 +04:00
|
|
|
extern clock_t clock(void);
|
|
|
|
extern double difftime(time_t time1, time_t time2);
|
|
|
|
extern time_t mktime(struct tm *tm);
|
|
|
|
extern time_t time(time_t *timer);
|
|
|
|
extern char *asctime(const struct tm *tm);
|
|
|
|
extern char *asctime_r(const struct tm *timep, char *buffer);
|
|
|
|
extern char *ctime(const time_t *timer);
|
|
|
|
extern char *ctime_r(const time_t *timer, char *buffer);
|
|
|
|
extern struct tm *gmtime(const time_t *timer);
|
2009-11-24 22:44:07 +03:00
|
|
|
extern struct tm *gmtime_r(const time_t *timer, struct tm *tm);
|
2002-10-23 19:27:44 +04:00
|
|
|
extern struct tm *localtime(const time_t *timer);
|
|
|
|
extern struct tm *localtime_r(const time_t *timer, struct tm *tm);
|
2007-09-25 23:18:27 +04:00
|
|
|
extern int nanosleep(const struct timespec *, struct timespec *);
|
2002-10-23 19:27:44 +04:00
|
|
|
extern size_t strftime(char *buffer, size_t maxSize, const char *format,
|
|
|
|
const struct tm *tm);
|
2005-03-02 19:39:50 +03:00
|
|
|
extern char *strptime(const char *buf, const char *format, struct tm *tm);
|
2002-10-23 19:27:44 +04:00
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
/* clock functions */
|
|
|
|
int clock_getres(clockid_t clockID, struct timespec* resolution);
|
|
|
|
int clock_gettime(clockid_t clockID, struct timespec* time);
|
|
|
|
int clock_settime(clockid_t clockID, const struct timespec* time);
|
|
|
|
int clock_nanosleep(clockid_t clockID, int flags,
|
|
|
|
const struct timespec* time, struct timespec* remainingTime);
|
|
|
|
int clock_getcpuclockid(pid_t pid, clockid_t* _clockID);
|
|
|
|
|
|
|
|
/* timer functions */
|
|
|
|
int timer_create(clockid_t clockID, struct sigevent* event,
|
|
|
|
timer_t* timerID);
|
|
|
|
int timer_delete(timer_t timerID);
|
|
|
|
int timer_gettime(timer_t timerID, struct itimerspec* value);
|
|
|
|
int timer_settime(timer_t timerID, int flags,
|
|
|
|
const struct itimerspec* value, struct itimerspec* oldValue);
|
|
|
|
int timer_getoverrun(timer_t timerID);
|
|
|
|
|
2002-10-23 19:27:44 +04:00
|
|
|
/* special timezone support */
|
|
|
|
extern void tzset(void);
|
2010-08-06 01:42:56 +04:00
|
|
|
|
|
|
|
/* non-POSIX */
|
2002-10-23 19:27:44 +04:00
|
|
|
extern int stime(const time_t *t);
|
2002-09-23 06:33:02 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-08-06 01:42:56 +04:00
|
|
|
|
2002-09-23 06:33:02 +04:00
|
|
|
#endif /* _TIME_H_ */
|