]> jfr.im git - solanum.git/blob - include/s_assert.h
extensions/invite_notify: make the NOTICE optional, configurable
[solanum.git] / include / s_assert.h
1 /*
2 * solanum: An advanced IRCd.
3 * s_assert.h: Definition of the soft assert (s_assert) macro.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2004 ircd-ratbox development team
8 * Copyright (C) 2005-2013 Charybdis development team
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 */
25
26 #ifndef INCLUDED_s_assert_h
27 #define INCLUDED_s_assert_h
28
29 #include "defaults.h"
30
31 #include "logger.h"
32 #include "send.h"
33 #include "snomask.h"
34
35 #ifdef __GNUC__
36 #define ss_assert(expr) ( \
37 ((expr)) || ( \
38 ilog(L_MAIN, \
39 "file: %s line: %d (%s): Assertion failed: (%s)", \
40 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) || (\
41 sendto_realops_snomask(SNO_GENERAL, L_ALL, \
42 "file: %s line: %d (%s): Assertion failed: (%s)", \
43 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) \
44 )
45 #else
46 #define ss_assert(expr) ( \
47 ((expr)) || ( \
48 ilog(L_MAIN, \
49 "file: %s line: %d: Assertion failed: (%s)", \
50 __FILE__, __LINE__, #expr), 0) || ( \
51 sendto_realops_snomask(SNO_GENERAL, L_ALL, \
52 "file: %s line: %d: Assertion failed: (%s)" \
53 __FILE__, __LINE__, #expr), 0) \
54 )
55 #endif
56
57 /* evaluates to true if assertion fails */
58 #ifdef SOFT_ASSERT
59 #define s_assert(expr) (!ss_assert(expr))
60 #else
61 #define s_assert(expr) (assert(ss_assert(expr)), 0)
62 #endif
63
64 #endif /* INCLUDED_s_assert_h */