]> arthur.barton.de Git - netdata.git/blob - src/common.h
added -ch option to set container host prefix for /proc and /sys #10
[netdata.git] / src / common.h
1 #include <inttypes.h>
2
3 #ifndef NETDATA_COMMON_H
4 #define NETDATA_COMMON_H 1
5
6 #define abs(x) ((x < 0)? -x : x)
7 #define usecdiff(now, last) (((((now)->tv_sec * 1000000ULL) + (now)->tv_usec) - (((last)->tv_sec * 1000000ULL) + (last)->tv_usec)))
8
9 extern uint32_t simple_hash(const char *name);
10 extern void strreverse(char* begin, char* end);
11 extern char *mystrsep(char **ptr, char *s);
12 extern char *trim(char *s);
13
14 extern void *mymmap(const char *filename, unsigned long size, int flags);
15 extern int savememory(const char *filename, void *mem, unsigned long size);
16
17 extern int fd_is_valid(int fd);
18
19 extern char *global_host_prefix;
20
21 #ifdef __GNUC__
22 // gcc branch optimization
23 // #warning "Using GCC branch optimizations"
24 #define likely(x)       __builtin_expect(!!(x), 1)
25 #define unlikely(x)     __builtin_expect(!!(x), 0)
26 #else
27 #define likely(x)       (x)
28 #define unlikely(x)     (x)
29 #endif
30
31 #endif /* NETDATA_COMMON_H */