]> jfr.im git - solanum.git/blame - include/s_assert.h
Add +R channel mode module requiring services account to chat (#102)
[solanum.git] / include / s_assert.h
CommitLineData
77d3d2db 1/*
a6f63a82 2 * solanum: An advanced IRCd.
77d3d2db
KB
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
9b8e9eb3 29#include "defaults.h"
77d3d2db 30
77d3d2db
KB
31#include "logger.h"
32#include "send.h"
33#include "snomask.h"
34
35#ifdef __GNUC__
b5ad4cdf
SA
36#define ss_assert(expr) ( \
37 ((expr)) || ( \
77d3d2db
KB
38 ilog(L_MAIN, \
39 "file: %s line: %d (%s): Assertion failed: (%s)", \
b5ad4cdf 40 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) || (\
77d3d2db
KB
41 sendto_realops_snomask(SNO_GENERAL, L_ALL, \
42 "file: %s line: %d (%s): Assertion failed: (%s)", \
b5ad4cdf
SA
43 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) \
44 )
77d3d2db 45#else
b5ad4cdf
SA
46#define ss_assert(expr) ( \
47 ((expr)) || ( \
77d3d2db
KB
48 ilog(L_MAIN, \
49 "file: %s line: %d: Assertion failed: (%s)", \
b5ad4cdf 50 __FILE__, __LINE__, #expr), 0) || ( \
77d3d2db
KB
51 sendto_realops_snomask(SNO_GENERAL, L_ALL, \
52 "file: %s line: %d: Assertion failed: (%s)" \
b5ad4cdf
SA
53 __FILE__, __LINE__, #expr), 0) \
54 )
77d3d2db 55#endif
b5ad4cdf
SA
56
57/* evaluates to true if assertion fails */
58#ifdef SOFT_ASSERT
59#define s_assert(expr) (!ss_assert(expr))
77d3d2db 60#else
b5ad4cdf 61#define s_assert(expr) (assert(ss_assert(expr)), 0)
77d3d2db
KB
62#endif
63
64#endif /* INCLUDED_s_assert_h */