L4Re Operating System Framework
Interface and Usage Documentation
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
h
i
k
m
o
p
r
s
t
u
w
Functions
a
b
c
k
m
r
s
t
w
Variables
Typedefs
Enumerations
Enumerator
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Typedefs
_
a
b
c
d
e
f
g
i
k
m
n
o
p
r
s
t
v
w
Enumerations
a
c
d
e
f
i
m
n
p
q
r
s
t
v
Enumerator
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
w
x
Related Symbols
Files
File List
Globals
All
_
a
b
d
e
f
g
l
m
n
o
p
r
s
Functions
_
b
e
f
g
l
o
p
Typedefs
e
g
l
p
Enumerations
e
l
p
Enumerator
a
d
e
f
l
n
p
r
s
Macros
_
e
g
l
m
p
s
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
/*****************************************************************************/
9
/*
10
* (c) 2009 Author(s)
11
* economic rights: Technische Universität Dresden (Germany)
12
* License: see LICENSE.spdx (in this directory or the directories above)
13
*/
14
15
/*****************************************************************************/
16
#pragma once
17
18
#ifdef NDEBUG
19
20
#define DO_NOTHING do {} while (0)
21
#define ASSERT_ASSERT(x) DO_NOTHING
22
#define ASSERT_VALID(c) DO_NOTHING
23
#define ASSERT_EQUAL(a,b) DO_NOTHING
24
#define ASSERT_NOT_EQUAL(a,b) DO_NOTHING
25
#define ASSERT_LOWER_EQ(a,b) DO_NOTHING
26
#define ASSERT_GREATER_EQ(a,b) DO_NOTHING
27
#define ASSERT_BETWEEN(a,b,c) DO_NOTHING
28
#define ASSERT_IPC_OK(i) DO_NOTHING
29
#define ASSERT_OK(e) do { (void)e; } while (0)
30
#define ASSERT_NOT_NULL(p) DO_NOTHING
31
#ifndef assert
32
#define assert(cond) DO_NOTHING
33
#endif
34
35
#else
// NDEBUG
36
37
#ifndef ASSERT_PRINTF
38
#include <stdio.h>
39
#define ASSERT_PRINTF printf
40
#endif
41
#ifndef ASSERT_ASSERT
42
#include <
assert.h
>
43
#define ASSERT_ASSERT(x) assert(x)
44
#endif
45
46
#define ASSERT_VALID(cap) \
47
do { \
48
typeof(cap) _cap = cap; \
49
if (l4_is_invalid_cap(_cap)) { \
50
ASSERT_PRINTF("%s: Cap invalid.\n", __func__); \
51
ASSERT_ASSERT(!l4_is_invalid_cap(_cap)); \
52
} \
53
} while (0)
54
55
56
#define ASSERT_EQUAL(a, b) \
57
do { \
58
typeof(a) _a = a; \
59
typeof(b) _b = b; \
60
if (_a != _b) { \
61
ASSERT_PRINTF("%s:\n", __func__); \
62
ASSERT_PRINTF(" "#a" (%lx) != "#b" (%lx)\n", (unsigned long)_a, (unsigned long)_b); \
63
ASSERT_ASSERT(_a == _b); \
64
} \
65
} while (0)
66
67
68
#define ASSERT_NOT_EQUAL(a, b) \
69
do { \
70
typeof(a) _a = a; \
71
typeof(b) _b = b; \
72
if (_a == _b) { \
73
ASSERT_PRINTF("%s:\n", __func__); \
74
ASSERT_PRINTF(" "#a" (%lx) == "#b" (%lx)\n", (unsigned long)_a, (unsigned long)_b); \
75
ASSERT_ASSERT(_a != _b); \
76
} \
77
} while (0)
78
79
80
#define ASSERT_LOWER_EQ(val, max) \
81
do { \
82
typeof(val) _val = val; \
83
typeof(max) _max = max; \
84
if (_val > _max) { \
85
ASSERT_PRINTF("%s:\n", __func__); \
86
ASSERT_PRINTF(" "#val" (%lx) > "#max" (%lx)\n", (unsigned long)_val, (unsigned long)_max); \
87
ASSERT_ASSERT(_val <= _max); \
88
} \
89
} while (0)
90
91
92
#define ASSERT_GREATER_EQ(val, min) \
93
do { \
94
typeof(val) _val = val; \
95
typeof(min) _min = min; \
96
if (_val < _min) { \
97
ASSERT_PRINTF("%s:\n", __func__); \
98
ASSERT_PRINTF(" "#val" (%lx) < "#min" (%lx)\n", (unsigned long)_val, (unsigned long)_min); \
99
ASSERT_ASSERT(_val >= _min); \
100
} \
101
} while (0)
102
103
104
#define ASSERT_BETWEEN(val, min, max) \
105
ASSERT_LOWER_EQ((val), (max)); \
106
ASSERT_GREATER_EQ((val), (min));
107
108
109
#define ASSERT_IPC_OK(msgtag) \
110
do { \
111
int _r = l4_ipc_error(msgtag, l4_utcb()); \
112
if (_r) { \
113
ASSERT_PRINTF("%s: IPC Error: %lx\n", __func__, _r); \
114
ASSERT_ASSERT(_r == 0); \
115
} \
116
} while (0)
117
118
#define ASSERT_OK(val) ASSERT_EQUAL((val), 0)
119
#define ASSERT_NOT_NULL(ptr) ASSERT_NOT_EQUAL((ptr), (void *)0)
120
121
#endif
// NDEBUG
assert.h
Some useful assert-style macros.
l4
util
assert.h
Generated on Mon Mar 3 2025 23:08:50 for L4Re Operating System Framework by
1.9.8