summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util_safealign.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/util_safealign.h b/src/util/util_safealign.h
index c39ba159b..685d65966 100644
--- a/src/util/util_safealign.h
+++ b/src/util/util_safealign.h
@@ -32,6 +32,16 @@
#include <string.h>
#include <stdint.h>
+/* Use this macro to suppress alignment warnings (use it
+ * only to suppress false-positives) */
+#define DISCARD_ALIGN(ptr) ((void *)(ptr))
+
+#define IS_ALIGNED(ptr, type) \
+ ((uintptr_t)(ptr) % sizeof(type) == 0)
+
+#define PADDING_SIZE(base, type) \
+ ((sizeof(type) - ((base) % sizeof(type))) % sizeof(type))
+
#define SIZE_T_OVERFLOW(current, add) \
(((size_t)(add)) > (SIZE_MAX - ((size_t)(current))))