root/src/noit_defines.h

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

compiles on linux -- still no eventer, refs #12

  • 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 static inline void add_timeval(struct timeval a, struct timeval b,
32                                struct timeval *out)
33 {
34   out->tv_usec = a.tv_usec + b.tv_usec;
35   if (out->tv_usec > 1000000L) {
36     a.tv_sec++;
37     out->tv_usec -= 1000000L;
38   }
39   out->tv_sec = a.tv_sec + b.tv_sec;
40 }
41
42 #ifndef HAVE_UUID_UNPARSE_LOWER
43 /* Sigh, need to implement out own */
44 #include <uuid/uuid.h>
45 #include <ctype.h>
46 static inline void uuid_unparse_lower(uuid_t in, char *out) {
47   int i;
48   uuid_unparse(in, out);
49   for(i=0;i<36;i++) out[i] = tolower(out[i]);
50 }
51 #endif
52
53 #ifdef HAVE_TERMIO_H
54 #define USE_TERMIO
55 #endif
56
57 #endif
Note: See TracBrowser for help on using the browser.