]>
Commit | Line | Data |
---|---|---|
2cac1093 | 1 | /* |
2 | * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $ | |
46f4a4d2 PJ |
3 | * |
4 | * This file is part of Quagga. | |
5 | * | |
6 | * Quagga is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * Quagga is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
896014f4 DL |
16 | * You should have received a copy of the GNU General Public License along |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
2cac1093 | 19 | */ |
20 | ||
cee3df1e | 21 | #ifndef _QUAGGA_ASSERT_H |
22 | #define _QUAGGA_ASSERT_H | |
23 | ||
d62a17ae | 24 | extern void _zlog_assert_failed(const char *assertion, const char *file, |
25 | unsigned int line, const char *function) | |
26 | __attribute__((noreturn)); | |
cee3df1e | 27 | |
28 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | |
29 | #define __ASSERT_FUNCTION __func__ | |
30 | #elif defined(__GNUC__) | |
31 | #define __ASSERT_FUNCTION __FUNCTION__ | |
32 | #else | |
33 | #define __ASSERT_FUNCTION NULL | |
34 | #endif | |
35 | ||
d62a17ae | 36 | #define zassert(EX) \ |
c14777c6 | 37 | ((void)((EX) ? 0 \ |
38 | : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ | |
39 | __ASSERT_FUNCTION), \ | |
40 | 0))) | |
cee3df1e | 41 | |
42 | #undef assert | |
43 | #define assert(EX) zassert(EX) | |
44 | ||
45 | #endif /* _QUAGGA_ASSERT_H */ |