summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/replace/README6
-rw-r--r--source4/lib/replace/replace.h29
-rw-r--r--source4/lib/util/util.h25
3 files changed, 35 insertions, 25 deletions
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
index c2de560314..77558b2ca9 100644
--- a/source4/lib/replace/README
+++ b/source4/lib/replace/README
@@ -86,6 +86,12 @@ __STRINGSTRING
MIN
MAX
QSORT_CAST
+ZERO_STRUCT
+ZERO_STRUCTP
+ZERO_STRUCTPN
+ZERO_ARRAY
+ARRAY_SIZE
+PTR_DIFF
Headers:
stdint.h
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index 840b448d24..b96356ac46 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -451,6 +451,35 @@ typedef int bool;
#define __location__ __FILE__ ":" __LINESTR__
#endif
+/**
+ * zero a structure
+ */
+#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
+
+/**
+ * zero a structure given a pointer to the structure
+ */
+#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
+
+/**
+ * zero a structure given a pointer to the structure - no zero check
+ */
+#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
+
+/* zero an array - note that sizeof(array) must work - ie. it must not be a
+ pointer */
+#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
+
+/**
+ * work out how many elements there are in a static array
+ */
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+/**
+ * pointer difference macro
+ */
+#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
+
#if MMAP_BLACKLIST
#undef HAVE_MMAP
#endif
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index dd6c1499bd..cfd77e5a13 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -41,31 +41,6 @@ extern const char *panic_action;
#include "util/byteorder.h"
#include "lib/util/util_proto.h"
-/**
- * zero a structure
- */
-#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
-
-/**
- * zero a structure given a pointer to the structure
- */
-#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
-
-/**
- * zero a structure given a pointer to the structure - no zero check
- */
-#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
-
-/**
- * pointer difference macro
- */
-#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
-
-/**
- * work out how many elements there are in a static array
- */
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
-
/**
* assert macros
*/