aboutsummaryrefslogtreecommitdiffstats
path: root/roms/SLOF/lib/libc/include/assert.h
blob: 01434da1a9e81bbc6167fe0b9f158a4002e590ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 */