Implement timer* macros, and GNU's getopt_long

This commit is contained in:
jD91mZM2
2018-10-06 16:46:35 +02:00
parent baddbb98d5
commit 9d56ce42c6
13 changed files with 346 additions and 120 deletions
+23
View File
@@ -0,0 +1,23 @@
#ifndef _BITS_SYS_TIME
#define _BITS_SYS_TIME
#define timeradd(x,y,res) (void) (\
(res)->tv_sec = (x)->tv_sec + (y)->tv_sec + ((x)->tv_usec + (y)->tv_usec / 1000000), \
(res)->tv_usec = ((x)->tv_usec + (y)->tv_usec) % 1000000 \
)
#define timersub(x,y,res) (void) ( \
(res)->tv_sec = (x)->tv_sec - (y)->tv_sec, \
(res)->tv_usec = ((x)->tv_usec - (y)->tv_usec), \
((res)->tv_usec < 0) && ((res)->tv_sec -= 1, (res)->tv_usec += 1000000) \
)
#define timerclear(t) (void) ( \
(t)->tv_sec = 0, \
(t)->tv_usec = 0 \
)
#define timerisset(t) (t)->tv_sec || (t)->tv_usec
#define timercmp(x,y,op) (x)->tv_sec == (y)->tv_sec ? \
(x)->tv_usec op (y)->tv_usec \
: \
(x)->tv_sec op (y)->tv_sec
#endif