summaryrefslogtreecommitdiff
path: root/libgcompat
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-02-23 14:47:00 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-02-23 14:47:00 +0000
commit2bc8658e85e2cb29daa1be362a42b8234aff7c74 (patch)
treee43caf218fa17f578972453abfd88b06578f965d /libgcompat
parent3637f0b37894381e2dec6196001f8069e32dcb6b (diff)
downloadgcompat-2bc8658e85e2cb29daa1be362a42b8234aff7c74.tar.gz
gcompat-2bc8658e85e2cb29daa1be362a42b8234aff7c74.tar.bz2
gcompat-2bc8658e85e2cb29daa1be362a42b8234aff7c74.tar.xz
gcompat-2bc8658e85e2cb29daa1be362a42b8234aff7c74.zip
libgcompat: add internal api for GCOMPAT__panic().
Diffstat (limited to 'libgcompat')
-rw-r--r--libgcompat/internal.c17
-rw-r--r--libgcompat/internal.h14
2 files changed, 31 insertions, 0 deletions
diff --git a/libgcompat/internal.c b/libgcompat/internal.c
new file mode 100644
index 0000000..441b3cc
--- /dev/null
+++ b/libgcompat/internal.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+
+void GCOMPAT__panic(const char *fmt, ...)
+{
+ va_list va;
+
+ fprintf(stderr, "*** gcompat panic ***\n");
+
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ va_end(va);
+
+ abort();
+}
diff --git a/libgcompat/internal.h b/libgcompat/internal.h
new file mode 100644
index 0000000..bb107bc
--- /dev/null
+++ b/libgcompat/internal.h
@@ -0,0 +1,14 @@
+#ifndef LIBGCOMPAT_INTERNAL_H
+#define LIBGCOMPAT_INTERNAL_H
+
+void GCOMPAT__panic(const char *fmt, ...) __attribute__((noreturn));
+
+#define GCOMPAT__assert_with_reason(chk, fmt, ...) \
+ do { \
+ if (!(chk)) { \
+ GCOMPAT__panic(fmt, __VA_ARGS__); \
+ } \
+ } \
+ while(0);
+
+#endif