summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/config-parser.c4
-rw-r--r--shared/debug.h6
-rw-r--r--shared/external.h21
-rw-r--r--shared/utils.h32
4 files changed, 45 insertions, 18 deletions
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 8094cda..9f294f4 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -387,7 +387,7 @@ config_parse_line(const char *filename, char **buf,
case CFG_VAL_TYPE_ASYNC_ADDRS:
error("CFG_VAL_TYPE_ASYNC_ADDRS is a return value");
- /* Fall through */
+ _fallthrough_;
case CFG_VAL_TYPE_ADDRS:
if (!strtosockaddrs(tmp, rvalue, async_dns))
@@ -433,7 +433,7 @@ config_parse_line(const char *filename, char **buf,
break;
case CFG_VAL_TYPE_INVALID:
- /* fall through */
+ _fallthrough_;
default:
goto error;
}
diff --git a/shared/debug.h b/shared/debug.h
index 8581a9a..6f1a054 100644
--- a/shared/debug.h
+++ b/shared/debug.h
@@ -1,6 +1,7 @@
#ifndef foodebughfoo
#define foodebughfoo
+/* FIXME: Should these be shared? */
enum debug_lvl {
DBG_ERROR = (0x1 << 1),
DBG_INFO = (0x1 << 2),
@@ -27,11 +28,6 @@ debug_enabled(enum debug_lvl lvl)
return !!(lvl & debug_mask);
}
-/* These need to be defined in the linking binary */
-void __debug(enum debug_lvl lvl, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-
-void __die(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
-
#define __ifdebug(lvl, fmt, ...) \
do { \
if (debug_enabled((lvl))) \
diff --git a/shared/external.h b/shared/external.h
new file mode 100644
index 0000000..1d7f3b7
--- /dev/null
+++ b/shared/external.h
@@ -0,0 +1,21 @@
+#ifndef fooexternalhfoo
+#define fooexternalhfoo
+
+/* These need to be defined in the linking binary */
+#define zmalloc(s) __zmalloc(__func__, __LINE__, s)
+void *__zmalloc(const char *fn, int line, size_t s);
+
+#define xstrdup(s) __xstrdup(__func__, __LINE__, s)
+char *__xstrdup(const char *fn, int line, const char *s);
+
+#define xstrndup(s, n) __xstrndup(__func__, __LINE__, s, n)
+char *__xstrndup(const char *fn, int line, const char *s, size_t n);
+
+#define xfree(s) __xfree(__func__, __LINE__, s)
+void __xfree(const char *fn, int line, void *ptr);
+
+void __debug(enum debug_lvl lvl, const char *fmt, ...) _printf_(2, 3);
+
+void __die(const char *fmt, ...) _printf_(1, 2);
+
+#endif
diff --git a/shared/utils.h b/shared/utils.h
index 3ad603b..0fc1429 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -12,21 +12,31 @@
extern unsigned debug_mask;
-#include "list.h"
-#include "debug.h"
+#define _unused_ __attribute__((__unused__))
+
+#define _printf_(a, b) __attribute__((__format__(printf, a, b)))
-/* These functions need to be defined in the linking binary */
-#define zmalloc(s) __zmalloc(__func__, __LINE__, s)
-void *__zmalloc(const char *fn, int line, size_t s);
+#define _alignas_(x) __attribute__((__aligned__(__alignof(x))))
-#define xstrdup(s) __xstrdup(__func__, __LINE__, s)
-char *__xstrdup(const char *fn, int line, const char *s);
+#define _big_endian_ __attribute__((packed, scalar_storage_order("big-endian")))
-#define xstrndup(s, n) __xstrndup(__func__, __LINE__, s, n)
-char *__xstrndup(const char *fn, int line, const char *s, size_t n);
+#if __GNUC__ >= 7
+#define _fallthrough_ __attribute__((__fallthrough__))
+#else
+#define _fallthrough_
+#endif
-#define xfree(s) __xfree(__func__, __LINE__, s)
-void __xfree(const char *fn, int line, void *ptr);
+#ifndef _noreturn_
+#if __STDC_VERSION__ >= 201112L
+#define _noreturn_ _Noreturn
+#else
+#define _noreturn_ __attribute__((__noreturn__))
+#endif
+#endif
+
+#include "list.h"
+#include "debug.h"
+#include "external.h"
/* Length of longest DNS name = 253 + trailing dot */
#define FQDN_STR_LEN 254