root/src/noit_defines.h

Revision b62cf2be087943dcb29b6e068bd4262862fcb17d, 0.7 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 6 years ago)

more work... fleshing out the eventer

  • Property mode set to 100644
Line 
1 #ifndef _NOIT_DEFINES_H
2 #define _NOIT_DEFINES_H
3
4 #include "noit_config.h"
5
6 #define API_EXPORT(type) extern type
7
8 static inline int compare_timeval(struct timeval a, struct timeval b) {
9   if (a.tv_sec < b.tv_sec) return -1;
10   if (a.tv_sec > b.tv_sec) return 1;
11   if (a.tv_usec < b.tv_usec) return -1;
12   if (a.tv_usec > b.tv_usec) return 1;
13   return 0;
14 }
15
16 static inline void sub_timeval(struct timeval a, struct timeval b,
17                                struct timeval *out)
18 {
19   out->tv_usec = a.tv_usec - b.tv_usec;
20   if (out->tv_usec < 0L) {
21     a.tv_sec--;
22     out->tv_usec += 1000000L;
23   }
24   out->tv_sec = a.tv_sec - b.tv_sec;
25   if (out->tv_sec < 0L) {
26     out->tv_sec++;
27     out->tv_usec -= 1000000L;
28   }
29 }
30
31 #endif
Note: See TracBrowser for help on using the browser.