summaryrefslogtreecommitdiff
path: root/src/nonstd/ASSERT_NONZERO.c
blob: 24a3f9a9206f65fe12a2c929f3ac5eb9fed3707c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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