summaryrefslogtreecommitdiffstats
path: root/src/common.h
blob: 9d8836f8bf9427ad9029c18b08ed1030afa1290b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef NETDATA_COMMON_H
#define NETDATA_COMMON_H 1

#if defined(HAVE_INTTYPES_H)
#include <inttypes.h>
#elif defined(HAVE_STDINT_H)
#include <stdint.h>
#endif
#include <sys/types.h>
#include <unistd.h>

#define abs(x) ((x < 0)? -x : x)
#define usecdiff(now, last) (((((now)->tv_sec * 1000000ULL) + (now)->tv_usec) - (((last)->tv_sec * 1000000ULL) + (last)->tv_usec)))

extern uint32_t simple_hash(const char *name);
extern void strreverse(char* begin, char* end);
extern char *mystrsep(char **ptr, char *s);
extern char *trim(char *s);

extern void *mymmap(const char *filename, size_t size, int flags, int ksm);
extern int savememory(const char *filename, void *mem, unsigned long size);

extern int fd_is_valid(int fd);

extern char *global_host_prefix;
extern int enable_ksm;

/* Number of ticks per second */
#define HZ        myhz
extern unsigned int hz;
extern void get_HZ(void);

extern pid_t gettid(void);

#endif /* NETDATA_COMMON_H */