L4Re - L4 Runtime Environment
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
macros.h
1
5
/*
6
* (c) 2000-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7
* Frank Mehnert <fm3@os.inf.tu-dresden.de>,
8
* Lars Reuther <reuther@os.inf.tu-dresden.de>
9
* economic rights: Technische Universität Dresden (Germany)
10
* This file is part of TUD:OS and distributed under the terms of the
11
* GNU Lesser General Public License 2.1.
12
* Please see the COPYING-LGPL-2.1 file for details.
13
*/
14
/*****************************************************************************/
15
/*****************************************************************************/
16
#ifndef _L4UTIL_MACROS_H
17
#define _L4UTIL_MACROS_H
18
19
/* L4 includes */
20
#include <l4/sys/types.h>
21
#include <l4/sys/kdebug.h>
22
#include <l4/util/l4_macros.h>
23
24
/*****************************************************************************
25
*** generic macros
26
*****************************************************************************/
27
28
#ifdef ___________MOVED_TO_LOG_PKG
29
30
/* print message and enter kernel debugger */
31
#ifndef Panic
32
33
// Don't include <stdlib.h> here, leads to trouble.
34
// Don't use exit() here since we want to terminate ASAP.
35
// We might be executed in context of the region manager.
36
EXTERN_C_BEGIN
37
void
_exit(
int
status) __attribute__ ((__noreturn__));
38
EXTERN_C_END
39
40
# ifdef L4BID_RELEASE_MODE
41
# define Panic(args...) do \
42
{ \
43
LOG(args); \
44
LOG_flush(); \
45
_exit(-1); \
46
} \
47
while (1)
48
# else
49
# define Panic(args...) do \
50
{ \
51
LOG(args); \
52
LOG_flush(); \
53
enter_kdebug("PANIC, 'g' for exit");\
54
_exit(-1); \
55
} \
56
while (1)
57
# endif
58
#endif
59
60
/* assertion */
61
#ifndef Assert
62
# define Assert(expr) do \
63
{ \
64
if (!(expr)) \
65
{ \
66
LOG_printf(#expr "\n"); \
67
Panic("Assertion failed"); \
68
} \
69
} \
70
while (0)
71
#endif
72
73
/* enter kernel debugger */
74
#ifndef Kdebug
75
# define Kdebug(args...) do \
76
{ \
77
LOG(args); \
78
LOG_flush(); \
79
enter_kdebug("KD"); \
80
} \
81
while (0)
82
#endif
83
#endif
84
85
/*****************************************************************************
86
*** debug stuff (to be removed, use LOG* macros instead!)
87
*****************************************************************************/
88
89
/* we use our own debug macros */
90
#ifdef KDEBUG
91
# undef KDEBUG
92
#endif
93
#ifdef ASSERT
94
# undef ASSERT
95
#endif
96
#ifdef PANIC
97
# undef PANIC
98
#endif
99
100
#ifdef DEBUG
101
102
#define KDEBUG(args...) do \
103
{ \
104
LOGl(args); \
105
LOG_flush(); \
106
enter_kdebug("KD"); \
107
} \
108
while (0)
109
110
#ifdef DEBUG_ASSERTIONS
111
# define ASSERT(expr) Assert(expr)
112
#else
113
# define ASSERT(expr) do {} while (0)
114
#endif
115
116
#ifdef DEBUG_ERRORS
117
# define PANIC(format, args...) Panic(format, ## args)
118
#else
119
# define PANIC(args...) do {} while (0)
120
#endif
121
122
#else
/* !DEBUG */
123
124
#define KDEBUG(args...) do {} while (0)
125
#define ASSERT(expr) do {} while (0)
126
#define PANIC(args...) do {} while (0)
127
128
#endif
/* !DEBUG */
129
130
#endif
/* !_L4UTIL_MACROS_H */
L4Re - L4 Runtime Environment