ctdb:includes: add #ifdef guard for ZERO_STRUCT
[Samba.git] / ctdb / include / internal / includes.h
blob05f248890277ba5bb69f481480e81b8587c1054a
1 #ifndef _CTDB_INCLUDES_H
2 #define _CTDB_INCLUDES_H
4 #define HAVE_UNIXSOCKET 1
6 #include "replace.h"
7 #include "talloc.h"
8 #include "system/wait.h"
9 #include "system/network.h"
10 #include "tdb.h"
11 #include "idtree.h"
12 #include "ctdb_client.h"
14 /* Allow use of deprecated function tevent_loop_allow_nesting() */
15 #define TEVENT_DEPRECATED
16 /* Saves ctdb from massive churn. */
17 #define TEVENT_COMPAT_DEFINES 1
19 #include "tevent.h"
21 extern int LogLevel;
22 extern int this_log_level;
24 enum debug_level {
25 DEBUG_EMERG = -3,
26 DEBUG_ALERT = -2,
27 DEBUG_CRIT = -1,
28 DEBUG_ERR = 0,
29 DEBUG_WARNING = 1,
30 DEBUG_NOTICE = 2,
31 DEBUG_INFO = 3,
32 DEBUG_DEBUG = 4,
35 #define DEBUGLVL(lvl) ((lvl) <= LogLevel)
36 #define DEBUG(lvl, x) do { this_log_level = (lvl); if ((lvl) < DEBUG_DEBUG) { log_ringbuffer x; } if ((lvl) <= LogLevel) { do_debug x; }} while (0)
37 #define DEBUGADD(lvl, x) do { if ((lvl) <= LogLevel) { this_log_level = (lvl); do_debug_add x; }} while (0)
39 #ifndef _PUBLIC_
40 #define _PUBLIC_
41 #endif /* _PUBLIC_ */
42 #ifndef _NORETURN_
43 #define _NORETURN_
44 #endif /* _NORETURN_ */
45 #ifndef _PURE_
46 #define _PURE_
47 #endif /* _PURE_ */
49 #ifndef ZERO_STRUCT
50 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
51 #endif /* ZERO_STRUCT */
53 #ifndef discard_const
54 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
55 #endif
57 struct timeval timeval_zero(void);
58 bool timeval_is_zero(const struct timeval *tv);
59 struct timeval timeval_current(void);
60 struct timeval timeval_set(uint32_t secs, uint32_t usecs);
61 int timeval_compare(const struct timeval *tv1, const struct timeval *tv2);
62 struct timeval timeval_until(const struct timeval *tv1,
63 const struct timeval *tv2);
64 _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs);
65 double timeval_elapsed(struct timeval *tv);
66 double timeval_delta(struct timeval *tv2, struct timeval *tv);
67 char **file_lines_load(const char *fname, int *numlines, TALLOC_CTX *mem_ctx);
68 char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len);
69 uint8_t *hex_decode_talloc(TALLOC_CTX *mem_ctx, const char *hex_in, size_t *len);
70 _PUBLIC_ const char **str_list_add(const char **list, const char *s);
71 _PUBLIC_ int set_blocking(int fd, bool set);
73 #include "lib/util/debug.h"
74 #include "lib/util/util.h"
76 #endif /* _CTDB_INCLUDES_H */