]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/include/sys/time.h
9 #include <sys/select.h>
11 int gettimeofday (struct timeval
*__restrict
, void *__restrict
);
13 #ifdef __wasilibc_unmodified_upstream /* WASI has no getitimer */
15 #define ITIMER_VIRTUAL 1
19 struct timeval it_interval
;
20 struct timeval it_value
;
23 int getitimer (int, struct itimerval
*);
24 int setitimer (int, const struct itimerval
*__restrict
, struct itimerval
*__restrict
);
26 #ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
27 int utimes (const char *, const struct timeval
[2]);
30 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
35 #ifdef __wasilibc_unmodified_upstream /* WASI libc doesn't build the legacy functions */
36 int futimes(int, const struct timeval
[2]);
37 int futimesat(int, const char *, const struct timeval
[2]);
38 int lutimes(const char *, const struct timeval
[2]);
40 #ifdef __wasilibc_unmodified_upstream /* WASI has no way to set the time */
41 int settimeofday(const struct timeval
*, const struct timezone
*);
42 int adjtime (const struct timeval
*, struct timeval
*);
44 #define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
45 #define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
46 #define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
47 (s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
48 #define timeradd(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
49 ((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
50 ((a)->tv_usec -= 1000000, (a)->tv_sec++) )
51 #define timersub(s,t,a) (void) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
52 ((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
53 ((a)->tv_usec += 1000000, (a)->tv_sec--) )
56 #if defined(_GNU_SOURCE)
57 #define TIMEVAL_TO_TIMESPEC(tv, ts) ( \
58 (ts)->tv_sec = (tv)->tv_sec, \
59 (ts)->tv_nsec = (tv)->tv_usec * 1000, \
61 #define TIMESPEC_TO_TIMEVAL(tv, ts) ( \
62 (tv)->tv_sec = (ts)->tv_sec, \
63 (tv)->tv_usec = (ts)->tv_nsec / 1000, \
68 __REDIR(gettimeofday
, __gettimeofday_time64
);
69 __REDIR(getitimer
, __getitimer_time64
);
70 __REDIR(setitimer
, __setitimer_time64
);
71 __REDIR(utimes
, __utimes_time64
);
72 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
73 __REDIR(futimes
, __futimes_time64
);
74 __REDIR(futimesat
, __futimesat_time64
);
75 __REDIR(lutimes
, __lutimes_time64
);
76 __REDIR(settimeofday
, __settimeofday_time64
);
77 __REDIR(adjtime
, __adjtime64
);