aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/include/assert.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/libc/include/assert.h b/lib/libc/include/assert.h
new file mode 100644
index 0000000..01434da
--- /dev/null
+++ b/lib/libc/include/assert.h
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * assert() macro definition
+ *
+ * Copyright 2018 Red Hat, Inc.
+ *
+ * This program and the accompanying materials are made available under
+ * the terms of the BSD License which accompanies this distribution, and
+ * is available at http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Contributors:
+ * Thomas Huth, Red Hat Inc. - initial implementation
+ *****************************************************************************/
+
+#ifndef SLIMLINE_ASSERT_H
+#define SLIMLINE_ASSERT_H
+
+#ifdef NDEBUG
+
+#define assert(cond) (void)
+
+#else
+
+#define assert(cond) \
+ do { \
+ if (!(cond)) { \
+ fprintf(stderr, \
+ "ERROR: Assertion '" #cond "' failed!\n" \
+ "(function %s, file " __FILE__ ", line %i)\n", \
+ __func__, __LINE__); \
+ while (1) {} \
+ } \
+ } while (0)
+
+#endif
+
+#endif /* SLIMLINE_ASSERT_H */