aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/slibc/internals.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/slibc/internals.h b/include/slibc/internals.h
index 099e2e7..b3f6235 100644
--- a/include/slibc/internals.h
+++ b/include/slibc/internals.h
@@ -18,9 +18,24 @@
#ifndef _SLIBC_INTERNALS_H
#define _SLIBC_INTERNALS_H
+#include <errno.h>
+
+
#define _(msg) msg
+#define OVERFLOW(op, a, b, res, errnum, failrc) \
+ do \
+ if (__builtin_##op##_overflow(a, b, res)) \
+ return errno = (errnum), (failrc); \
+ while (0)
+
+
+#define MEM_OVERFLOW(op, a, b, res) \
+ OVERFLOW(op, a, b, res, ENOMEM, NULL)
+
+
+
#endif