diff options
Diffstat (limited to 'src/nonstd/ASSERT_NONZERO.c')
| -rw-r--r-- | src/nonstd/ASSERT_NONZERO.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nonstd/ASSERT_NONZERO.c b/src/nonstd/ASSERT_NONZERO.c new file mode 100644 index 00000000..24a3f9a9 --- /dev/null +++ b/src/nonstd/ASSERT_NONZERO.c @@ -0,0 +1,14 @@ +#include <nonstd/assert.h> + +#ifndef NDEBUG +#define ASSERT_NONZERO(_n) do { \ + if (!_n) { \ + struct __constraint_info _ci = {0}; \ + _ci.func = __func__; \ + __libc.stdlib.constraint_handler("Undefined behavior: " \ + "Parameter " #_n " can not be 0", &_ci, ERANGE); \ + } \ + } while (0) +#else +#define ASSERT_NONZERO(n) +#endif |
