1#pragma once 2 3#ifdef __cplusplus 4extern "C" { 5#endif 6 7#include <features.h> 8#include <bits/null.h> 9 10#define __NEED_size_t 11#define __NEED_time_t 12#define __NEED_clock_t 13#define __NEED_struct_timespec 14 15#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 16 defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 17#define __NEED_clockid_t 18#define __NEED_timer_t 19#define __NEED_pid_t 20#endif 21 22#include <bits/alltypes.h> 23 24#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 25#define __tm_gmtoff tm_gmtoff 26#define __tm_zone tm_zone 27#endif 28 29struct tm { 30 int tm_sec; 31 int tm_min; 32 int tm_hour; 33 int tm_mday; 34 int tm_mon; 35 int tm_year; 36 int tm_wday; 37 int tm_yday; 38 int tm_isdst; 39 long __tm_gmtoff; 40 const char* __tm_zone; 41}; 42 43clock_t clock(void); 44time_t time(time_t*); 45double difftime(time_t, time_t); 46time_t mktime(struct tm*); 47size_t strftime(char* __restrict, size_t, const char* __restrict, const struct tm* __restrict); 48struct tm* gmtime(const time_t*); 49struct tm* localtime(const time_t*); 50char* asctime(const struct tm*); 51char* ctime(const time_t*); 52int timespec_get(struct timespec*, int); 53 54#define CLOCKS_PER_SEC 1000000L 55 56#define TIME_UTC 1 57 58#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 59 defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 60 61struct tm* gmtime_r(const time_t* __restrict, struct tm* __restrict); 62struct tm* localtime_r(const time_t* __restrict, struct tm* __restrict); 63char* asctime_r(const struct tm* __restrict, char* __restrict); 64char* ctime_r(const time_t*, char*); 65 66void tzset(void); 67 68struct itimerspec { 69 struct timespec it_interval; 70 struct timespec it_value; 71}; 72 73#define CLOCK_REALTIME 0 74#define CLOCK_MONOTONIC 1 75#define CLOCK_PROCESS_CPUTIME_ID 2 76#define CLOCK_THREAD_CPUTIME_ID 3 77#define CLOCK_MONOTONIC_RAW 4 78#define CLOCK_REALTIME_COARSE 5 79#define CLOCK_MONOTONIC_COARSE 6 80#define CLOCK_BOOTTIME 7 81#define CLOCK_REALTIME_ALARM 8 82#define CLOCK_BOOTTIME_ALARM 9 83#define CLOCK_SGI_CYCLE 10 84#define CLOCK_TAI 11 85 86#define TIMER_ABSTIME 1 87 88int nanosleep(const struct timespec*, struct timespec*); 89int clock_getres(clockid_t, struct timespec*); 90int clock_gettime(clockid_t, struct timespec*); 91int clock_settime(clockid_t, const struct timespec*); 92int clock_nanosleep(clockid_t, int, const struct timespec*, struct timespec*); 93int clock_getcpuclockid(pid_t, clockid_t*); 94 95struct sigevent; 96int timer_create(clockid_t, struct sigevent* __restrict, timer_t* __restrict); 97int timer_delete(timer_t); 98int timer_settime(timer_t, int, const struct itimerspec* __restrict, struct itimerspec* __restrict); 99int timer_gettime(timer_t, struct itimerspec*); 100int timer_getoverrun(timer_t); 101 102#endif 103 104#if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 105char* strptime(const char* __restrict, const char* __restrict, struct tm* __restrict); 106extern int daylight; 107extern long timezone; 108extern char* tzname[2]; 109extern int getdate_err; 110struct tm* getdate(const char*); 111#endif 112 113#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 114int stime(const time_t*); 115time_t timegm(struct tm*); 116#endif 117 118#ifdef __cplusplus 119} 120#endif 121