5 #ifndef NETDATA_COMMON_H
6 #define NETDATA_COMMON_H 1
8 #define abs(x) ((x < 0)? -x : x)
9 #define usecdiff(now, last) (((((now)->tv_sec * 1000000ULL) + (now)->tv_usec) - (((last)->tv_sec * 1000000ULL) + (last)->tv_usec)))
11 extern uint32_t simple_hash(const char *name);
12 extern void strreverse(char* begin, char* end);
13 extern char *mystrsep(char **ptr, char *s);
14 extern char *trim(char *s);
16 extern void *mymmap(const char *filename, unsigned long size, int flags);
17 extern int savememory(const char *filename, void *mem, unsigned long size);
19 extern int fd_is_valid(int fd);
21 extern char *global_host_prefix;
24 // gcc branch optimization
25 // #warning "Using GCC branch optimizations"
26 #define likely(x) __builtin_expect(!!(x), 1)
27 #define unlikely(x) __builtin_expect(!!(x), 0)
30 #define unlikely(x) (x)
34 /* Number of ticks per second */
36 extern unsigned int hz;
37 extern void get_HZ(void);
39 extern pid_t gettid(void);
41 #endif /* NETDATA_COMMON_H */