redmine

Headers polishing

@@ -87,65 +87,7 @@ @@ -87,65 +87,7 @@
87 # define IN_CREATE_SELF IN_CREATE 87 # define IN_CREATE_SELF IN_CREATE
88 #endif 88 #endif
89 89
90 -#ifdef _DEBUG 90 +#include "macros.h"
91 -# define DEBUGV(...) __VA_ARGS__  
92 -#else  
93 -# define DEBUGV(...)  
94 -#endif  
95 -  
96 -#ifdef PARANOID  
97 -# define PARANOIDV(...) __VA_ARGS__  
98 -#else  
99 -# define PARANOIDV(...)  
100 -#endif  
101 -  
102 -#ifdef _GNU_SOURCE  
103 -# ifndef likely  
104 -# define likely(x) __builtin_expect(!!(x), 1)  
105 -# endif  
106 -# ifndef unlikely  
107 -# define unlikely(x) __builtin_expect(!!(x), 0)  
108 -# endif  
109 -#else  
110 -# ifndef likely  
111 -# define likely(x) (x)  
112 -# endif  
113 -# ifndef unlikely  
114 -# define unlikely(x) (x)  
115 -# endif  
116 -#endif  
117 -  
118 -#ifndef offsetof  
119 -# define offsetof(a, b) __builtin_offsetof(a, b)  
120 -#endif  
121 -  
122 -// clang defines "__GNUC__", but not compatible with gnuc. Fixing.  
123 -#ifdef __clang__  
124 -# ifdef __GNUC__  
125 -# undef __GNUC__  
126 -# endif  
127 -#endif  
128 -  
129 -#define TOSTR(a) # a  
130 -#define XTOSTR(a) TOSTR(a)  
131 -  
132 -#define COLLECTDELAY_INSTANT ((unsigned int)~0)  
133 -  
134 -  
135 -#define MSG_SECURITY_PROBLEM(a) "Security problem: "a". Don't use this application until the bug will be fixed. Report about the problem to: "AUTHOR  
136 -  
137 -#define require_strlen_le(str, limit) \  
138 - if (strlen(str) >= limit)\  
139 - critical("length of "TOSTR(str)" (\"%s\") >= "TOSTR(limit));\  
140 -  
141 -#define SAFE(code, onfail) ({\  
142 - long _SAFE_rc;\  
143 - if ((_SAFE_rc = code)) {\  
144 - error("Got error while "TOSTR(code));\  
145 - onfail;\  
146 - } \  
147 - _SAFE_rc;\  
148 -})  
149 91
150 enum paramsource_enum { 92 enum paramsource_enum {
151 PS_UNKNOWN = 0, 93 PS_UNKNOWN = 0,
@@ -36,7 +36,8 @@ @@ -36,7 +36,8 @@
36 #define MAXMOUNTPOINTS (1<<8) 36 #define MAXMOUNTPOINTS (1<<8)
37 #define MAXPERMITTEDHOOKFILES (1<<8) 37 #define MAXPERMITTEDHOOKFILES (1<<8)
38 38
39 -#ifdef __CLSYNC_COMMON_H 39 +#ifndef PIC
  40 +# ifdef __CLSYNC_COMMON_H
40 # ifndef DEFAULT_NOTIFYENGINE 41 # ifndef DEFAULT_NOTIFYENGINE
41 # ifdef __linux__ 42 # ifdef __linux__
42 # ifdef INOTIFY_SUPPORT 43 # ifdef INOTIFY_SUPPORT
@@ -75,6 +76,7 @@ @@ -75,6 +76,7 @@
75 # error No monitor subsystem supported 76 # error No monitor subsystem supported
76 # define DEFAULT_NOTIFYENGINE NE_UNDEFINED 77 # define DEFAULT_NOTIFYENGINE NE_UNDEFINED
77 # endif 78 # endif
  79 +# endif
78 #endif 80 #endif
79 81
80 #define DEFAULT_RULES_PERM RA_ALL 82 #define DEFAULT_RULES_PERM RA_ALL
@@ -65,7 +65,7 @@ AS_IF([test "x$enable_cluster" = "xyes"], [CPPFLAGS="${CPPFLAGS} -DCLUSTER_SUPPO @@ -65,7 +65,7 @@ AS_IF([test "x$enable_cluster" = "xyes"], [CPPFLAGS="${CPPFLAGS} -DCLUSTER_SUPPO
65 65
66 AS_IF([test "x$with_mhash" = "xno"], [], [ 66 AS_IF([test "x$with_mhash" = "xno"], [], [
67 AC_CHECK_HEADER([mhash.h], [], [AC_MSG_ERROR("Unable to find mhash.h")]) 67 AC_CHECK_HEADER([mhash.h], [], [AC_MSG_ERROR("Unable to find mhash.h")])
68 - AC_SEARCH_LIBS([mhash_init], [mhash], [CPPFLAGS="${CPPFLAGS} -DHAVE_MHASH"], 68 + AC_SEARCH_LIBS([mhash_init], [mhash], [CPPFLAGS="${CPPFLAGS} -DHAVE_MHASH"; LDFLAGS="${LDFLAGS} -lmhash"],
69 [AC_MSG_ERROR("Unable to find libmhash")]) 69 [AC_MSG_ERROR("Unable to find libmhash")])
70 ]) 70 ])
71 ]) 71 ])
@@ -22,8 +22,6 @@ @@ -22,8 +22,6 @@
22 * to be slow but convenient functions. 22 * to be slow but convenient functions.
23 */ 23 */
24 24
25 -#include "common.h"  
26 -  
27 #include <stdlib.h> 25 #include <stdlib.h>
28 #include <execinfo.h> 26 #include <execinfo.h>
29 #include <stdio.h> 27 #include <stdio.h>
@@ -32,6 +30,12 @@ @@ -32,6 +30,12 @@
32 #include <stdarg.h> 30 #include <stdarg.h>
33 #include <syslog.h> 31 #include <syslog.h>
34 #include <pthread.h> /* pthread_self() */ 32 #include <pthread.h> /* pthread_self() */
  33 +#include <sys/types.h> /* getpid() */
  34 +#include <unistd.h> /* getpid() */
  35 +
  36 +
  37 +#include "configuration.h"
  38 +
35 #include "error.h" 39 #include "error.h"
36 #include "pthreadex.h" /* pthread_*_shared() */ 40 #include "pthreadex.h" /* pthread_*_shared() */
37 41
@@ -18,7 +18,6 @@ @@ -18,7 +18,6 @@
18 */ 18 */
19 19
20 #define LIBCLSYNC 20 #define LIBCLSYNC
21 -#include "common.h"  
22 21
23 #include <errno.h> 22 #include <errno.h>
24 #include <stdlib.h> 23 #include <stdlib.h>
  1 +#ifndef __CLSYNC_MACROS_H
  2 +#define __CLSYNC_MACROS_H
  3 +
  4 +#ifdef _DEBUG
  5 +# define DEBUGV(...) __VA_ARGS__
  6 +#else
  7 +# define DEBUGV(...)
  8 +#endif
  9 +
  10 +#ifdef PARANOID
  11 +# define PARANOIDV(...) __VA_ARGS__
  12 +#else
  13 +# define PARANOIDV(...)
  14 +#endif
  15 +
  16 +#ifdef _GNU_SOURCE
  17 +# ifndef likely
  18 +# define likely(x) __builtin_expect(!!(x), 1)
  19 +# endif
  20 +# ifndef unlikely
  21 +# define unlikely(x) __builtin_expect(!!(x), 0)
  22 +# endif
  23 +#else
  24 +# ifndef likely
  25 +# define likely(x) (x)
  26 +# endif
  27 +# ifndef unlikely
  28 +# define unlikely(x) (x)
  29 +# endif
  30 +#endif
  31 +
  32 +#ifndef offsetof
  33 +# define offsetof(a, b) __builtin_offsetof(a, b)
  34 +#endif
  35 +
  36 +// clang defines "__GNUC__", but not compatible with gnuc. Fixing.
  37 +#ifdef __clang__
  38 +# ifdef __GNUC__
  39 +# undef __GNUC__
  40 +# endif
  41 +#endif
  42 +
  43 +#define TOSTR(a) # a
  44 +#define XTOSTR(a) TOSTR(a)
  45 +
  46 +#define COLLECTDELAY_INSTANT ((unsigned int)~0)
  47 +
  48 +
  49 +#define MSG_SECURITY_PROBLEM(a) "Security problem: "a". Don't use this application until the bug will be fixed. Report about the problem to: "AUTHOR
  50 +
  51 +#define require_strlen_le(str, limit) \
  52 + if (strlen(str) >= limit)\
  53 + critical("length of "TOSTR(str)" (\"%s\") >= "TOSTR(limit));\
  54 +
  55 +#define SAFE(code, onfail) ({\
  56 + long _SAFE_rc;\
  57 + if ((_SAFE_rc = code)) {\
  58 + error("Got error while "TOSTR(code));\
  59 + onfail;\
  60 + } \
  61 + _SAFE_rc;\
  62 +})
  63 +
  64 +#endif
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20 -#include "common.h" 20 +#include "macros.h"
21 21
22 #include <stdlib.h> 22 #include <stdlib.h>
23 #include <string.h> 23 #include <string.h>
@@ -17,8 +17,6 @@ @@ -17,8 +17,6 @@
17 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20 -#include "common.h"  
21 -  
22 #include <stdarg.h> 20 #include <stdarg.h>
23 #include <stdio.h> 21 #include <stdio.h>
24 #include <stdlib.h> 22 #include <stdlib.h>