d5d3d6e5146e7e1e7fc5c24f0e585489df11717e
[libc-test] / src / api / time.c
1 #include <time.h>
2 #define T(t) (t*)0;
3 #define F(t,n) {t *y = &x.n;}
4 #define C(n) switch(n){case n:;}
5 static void f()
6 {
7 T(clock_t)
8 T(size_t)
9 T(time_t)
10 #ifdef _POSIX_C_SOURCE
11 T(clockid_t)
12 T(timer_t)
13 T(locale_t)
14 T(pid_t)
15 T(struct sigevent)
16 {
17 struct timespec x;
18 F(time_t,tv_sec)
19 F(long,tv_nsec)
20 }
21 {
22 struct itimerspec x;
23 F(struct timespec,it_interval)
24 F(struct timespec,it_value)
25 }
26 C(CLOCK_MONOTONIC)
27 C(CLOCK_PROCESS_CPUTIME_ID)
28 C(CLOCK_REALTIME)
29 C(CLOCK_THREAD_CPUTIME_ID)
30 #endif
31 {
32 struct tm x;
33 F(int,tm_sec)
34 F(int,tm_min)
35 F(int,tm_hour)
36 F(int,tm_mday)
37 F(int,tm_mon)
38 F(int,tm_year)
39 F(int,tm_wday)
40 F(int,tm_yday)
41 F(int,tm_isdst)
42 }
43 {void *x = NULL;}
44 {int x = CLOCKS_PER_SEC;}
45 C(TIMER_ABSTIME)
46 char*(*p_asctime)(const struct tm*) = asctime;
47 clock_t(*p_clock)(void) = clock;
48 char*(*p_ctime)(const time_t*) = ctime;
49 {int i = daylight;}
50 double(*p_difftime)(time_t,time_t) = difftime;
51 struct tm*(*p_gmtime)(const time_t*) = gmtime;
52 struct tm*(*p_localtime)(const time_t*) = localtime;
53 time_t(*p_mktime)(struct tm*) = mktime;
54 size_t(*p_strftime)(char*restrict,size_t,const char*restrict,const struct tm*restrict) = strftime;
55 time_t(*p_time)(time_t*) = time;
56 #ifdef _POSIX_C_SOURCE
57 char*(*p_asctime_r)(const struct tm*restrict,char*restrict) = asctime_r;
58 int(*p_clock_getcpuclockid)(pid_t,clockid_t*) = clock_getcpuclockid;
59 int(*p_clock_getres)(clockid_t,struct timespec*) = clock_getres;
60 int(*p_clock_gettime)(clockid_t,struct timespec*) = clock_gettime;
61 int(*p_clock_nanosleep)(clockid_t,int,const struct timespec*,struct timespec*) = clock_nanosleep;
62 int(*p_clock_settime)(clockid_t,const struct timespec*) = clock_settime;
63 char*(*p_ctime_r)(const time_t*,char*) = ctime_r;
64 struct tm*(*p_gmtime_r)(const time_t*restrict,struct tm*restrict) = gmtime_r;
65 struct tm*(*p_localtime_r)(const time_t*restrict,struct tm*restrict) = localtime_r;
66 int(*p_nanosleep)(const struct timespec*,struct timespec*) = nanosleep;
67 size_t(*p_strftime_l)(char*restrict,size_t,const char*restrict,const struct tm*restrict,locale_t) = strftime_l;
68 int(*p_timer_delete)(timer_t) = timer_delete;
69 int(*p_timer_getoverrun)(timer_t) = timer_getoverrun;
70 int(*p_timer_gettime)(timer_t,struct itimerspec*) = timer_gettime;
71 int(*p_timer_settime)(timer_t,int,const struct itimerspec*restrict,struct itimerspec*restrict) = timer_settime;
72 {char **x = tzname;}
73 void(*p_tzset)(void) = tzset;
74 #endif
75 #ifdef _XOPEN_SOURCE
76 struct tm*(*p_getdate)(const char*) = getdate;
77 {int i = getdate_err;}
78 char*(*p_strptime)(const char*restrict,const char*restrict,struct tm*restrict) = strptime;
79 {long i = timezone;}
80 #endif
81 }
82 #ifdef _POSIX_C_SOURCE
83 #include <signal.h>
84 static void g()
85 {
86 int(*p_timer_create)(clockid_t,struct sigevent*restrict,timer_t*restrict) = timer_create;
87 }
88 #endif