1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/* assert.h - Assert declaration for libc-parts.
Copyright (C) 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
Written by Neal H. Walfield <neal@gnu.org>.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU Hurd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#ifndef _ASSERT_H
#define _ASSERT_H 1
#include <hurd/stddef.h>
#define build_assert(__expr) (void) (sizeof (char[(__expr)? 1 : -1]))
#if defined(_L4_TEST_ENVIRONMENT) || defined(_ENABLE_TESTS)
# include_next <assert.h>
# define assertx(__ax_expr, __ax_fmt, ...) \
do \
{ \
extern int S_PRINTF (const char *fmt, ...); \
\
if (! (__ax_expr)) \
S_PRINTF (__ax_fmt, ##__VA_ARGS__); \
assert (__ax_expr); \
} \
while (0)
#else
# ifndef NDEBUG
#include <l4/thread.h>
# define assertx(__ax_expr, __ax_fmt, ...) \
do { \
extern char *program_name; \
extern int S_PRINTF (const char *fmt, ...); \
\
if (! (__ax_expr)) \
{ \
S_PRINTF ("%s (%x):%s:%s:%d: %s failed", \
program_name, l4_myself (), \
__FILE__, __func__, __LINE__, \
#__ax_expr); \
if ((__ax_fmt) && *(__ax_fmt)) \
{ \
S_PRINTF (": " __ax_fmt, ##__VA_ARGS__); \
} \
S_PRINTF ("\n"); \
\
extern void backtrace_print (void); \
backtrace_print (); \
\
for (;;) \
{ \
extern void _exit (int); \
_exit(128); \
} \
} \
} while (0)
# define assert(__a_expr) \
assertx (__a_expr, "")
# else
# define assert(expr) do { } while (0)
# define assertx(expr, fmt, ...) do { } while (0)
# endif
# define assert_perror(err) assert(err == 0)
#endif /* _L4_TEST_ENVIRONMENT */
#endif /* _ASSERT_H */
|