]> jfr.im git - solanum.git/blame - include/s_assert.h
wsockd: avoid clang static analysis warning
[solanum.git] / include / s_assert.h
CommitLineData
77d3d2db
KB
1/*
2 * charybdis: 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
9b8e9eb3 29#include "defaults.h"
77d3d2db
KB
30
31#ifdef SOFT_ASSERT
32
33#include "logger.h"
34#include "send.h"
35#include "snomask.h"
36
37#ifdef __GNUC__
38#define s_assert(expr) do \
39 if(!(expr)) { \
40 ilog(L_MAIN, \
41 "file: %s line: %d (%s): Assertion failed: (%s)", \
42 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
43 sendto_realops_snomask(SNO_GENERAL, L_ALL, \
44 "file: %s line: %d (%s): Assertion failed: (%s)", \
45 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
46 } \
47 while(0)
48#else
49#define s_assert(expr) do \
50 if(!(expr)) { \
51 ilog(L_MAIN, \
52 "file: %s line: %d: Assertion failed: (%s)", \
53 __FILE__, __LINE__, #expr); \
54 sendto_realops_snomask(SNO_GENERAL, L_ALL, \
55 "file: %s line: %d: Assertion failed: (%s)" \
56 __FILE__, __LINE__, #expr); \
57 } \
58 while(0)
59#endif
60#else
61#define s_assert(expr) assert(expr)
62#endif
63
64#endif /* INCLUDED_s_assert_h */