]> git.proxmox.com Git - mirror_frr.git/blob - lib/zassert.h
Merge pull request #6279 from opensourcerouting/nb-cb-args
[mirror_frr.git] / lib / zassert.h
1 /*
2 * This file is part of Quagga.
3 *
4 * Quagga is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * Quagga is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef _QUAGGA_ASSERT_H
20 #define _QUAGGA_ASSERT_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 extern void _zlog_assert_failed(const char *assertion, const char *file,
27 unsigned int line, const char *function)
28 __attribute__((noreturn));
29
30 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
31 #define __ASSERT_FUNCTION __func__
32 #elif defined(__GNUC__)
33 #define __ASSERT_FUNCTION __FUNCTION__
34 #else
35 #define __ASSERT_FUNCTION NULL
36 #endif
37
38 #define zassert(EX) \
39 ((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
40 __ASSERT_FUNCTION), \
41 0)))
42
43 #undef assert
44 #define assert(EX) zassert(EX)
45
46 #ifdef __cplusplus
47 }
48 #endif
49
50 #endif /* _QUAGGA_ASSERT_H */