aboutsummaryrefslogtreecommitdiff
path: root/src/lib/mhd_assert.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/mhd_assert.h')
-rw-r--r--src/lib/mhd_assert.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/mhd_assert.h b/src/lib/mhd_assert.h
new file mode 100644
index 00000000..c720ce5c
--- /dev/null
+++ b/src/lib/mhd_assert.h
@@ -0,0 +1,49 @@
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2017 Karlson2k (Evgeny Grin)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library.
17 If not, see <http://www.gnu.org/licenses/>.
18*/
19
20/**
21 * @file microhttpd/mhd_assert.h
22 * @brief macros for mhd_assert()
23 * @author Karlson2k (Evgeny Grin)
24 */
25
26#ifndef MHD_ASSERT_H
27#define MHD_ASSERT_H 1
28
29#include "mhd_options.h"
30#ifdef NDEBUG
31# define mhd_assert(ignore) ((void)0)
32#else /* _DEBUG */
33# ifdef HAVE_ASSERT
34# include <assert.h>
35# define mhd_assert(CHK) assert(CHK)
36# else /* ! HAVE_ASSERT */
37# include <stdio.h>
38# include <stdlib.h>
39# define mhd_assert(CHK) \
40 do { \
41 if (!(CHK)) { \
42 fprintf(stderr, "%s:%u Assertion failed: %s\nProgram aborted.\n", \
43 __FILE__, (unsigned)__LINE__, #CHK); \
44 fflush(stderr); abort(); } \
45 } while(0)
46# endif /* ! HAVE_ASSERT */
47#endif /* _DEBUG */
48
49#endif /* ! MHD_ASSERT_H */