| 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 |
#endif |
|---|