about summary refs log tree commit diff
path: root/include/sys
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-04-10 22:46:46 -0400
committerRich Felker <dalias@aerifal.cx>2011-04-10 22:46:46 -0400
commit691b20bec013c7a2758a38bafd21b7649c2cc920 (patch)
tree75212a72f2054d4a11c702a9c40f57cec7c4fa6c /include/sys
parent4a19634f07821cf4ef0e9a1d060e148dd2a429fd (diff)
downloadmusl-691b20bec013c7a2758a38bafd21b7649c2cc920.tar.gz
musl-691b20bec013c7a2758a38bafd21b7649c2cc920.tar.xz
musl-691b20bec013c7a2758a38bafd21b7649c2cc920.zip
add legacy BSD-style timer*() macros in sys/time.h
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/time.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/sys/time.h b/include/sys/time.h
index 766ac728..70fd5687 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -42,6 +42,16 @@ struct timezone {
 	int tz_minuteswest;
 	int tz_dsttime;
 };
+#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
+#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
+#define timercmp(s,t,op) ((s)->tv_sec == (t)->tv_sec ? \
+	(s)->tv_usec op (t)->tv_usec : (s)->tv_sec op (t)->tv_sec)
+#define timeradd(s,t,a) ( (a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
+	((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
+	((a)->tv_usec -= 1000000, (a)->tv_sec++) )
+#define timersub(s,t,a) ( (a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
+	((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
+	((a)->tv_usec += 1000000, (a)->tv_sec--) )
 #endif
 
 #ifdef __cplusplus