The Pedigree Project  0.1
modules/system/lwip/include/lwip/debug.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
25 /*
26  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without modification,
30  * are permitted provided that the following conditions are met:
31  *
32  * 1. Redistributions of source code must retain the above copyright notice,
33  * this list of conditions and the following disclaimer.
34  * 2. Redistributions in binary form must reproduce the above copyright notice,
35  * this list of conditions and the following disclaimer in the documentation
36  * and/or other materials provided with the distribution.
37  * 3. The name of the author may not be used to endorse or promote products
38  * derived from this software without specific prior written permission.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
42  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
43  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
45  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
48  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
49  * OF SUCH DAMAGE.
50  *
51  * This file is part of the lwIP TCP/IP stack.
52  *
53  * Author: Adam Dunkels <adam@sics.se>
54  *
55  */
56 #ifndef LWIP_HDR_DEBUG_H
57 #define LWIP_HDR_DEBUG_H
58 
59 #include "lwip/arch.h"
60 #include "lwip/opt.h"
61 
72 #define LWIP_DBG_LEVEL_ALL 0x00
73 
74 #define LWIP_DBG_LEVEL_WARNING 0x01
75 
76 #define LWIP_DBG_LEVEL_SERIOUS 0x02
77 
78 #define LWIP_DBG_LEVEL_SEVERE 0x03
79 
83 #define LWIP_DBG_MASK_LEVEL 0x03
84 /* compatibility define only */
85 #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL
86 
91 #define LWIP_DBG_ON 0x80U
92 
93 #define LWIP_DBG_OFF 0x00U
94 
102 #define LWIP_DBG_TRACE 0x40U
103 
104 #define LWIP_DBG_STATE 0x20U
105 
106 #define LWIP_DBG_FRESH 0x10U
107 
108 #define LWIP_DBG_HALT 0x08U
109 
126 #ifdef __DOXYGEN__
127 #define LWIP_NOASSERT
128 #undef LWIP_NOASSERT
129 #endif
130 
134 #ifndef LWIP_NOASSERT
135 #define LWIP_ASSERT(message, assertion) do { if (!(assertion)) { \
136  LWIP_PLATFORM_ASSERT(message); }} while(0)
137 #ifndef LWIP_PLATFORM_ASSERT
138 #error "If you want to use LWIP_ASSERT, LWIP_PLATFORM_ASSERT(message) needs to be defined in your arch/cc.h"
139 #endif
140 #else /* LWIP_NOASSERT */
141 #define LWIP_ASSERT(message, assertion)
142 #endif /* LWIP_NOASSERT */
143 
144 #ifndef LWIP_ERROR
145 #ifndef LWIP_NOASSERT
146 #define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_ASSERT(message)
147 #elif defined LWIP_DEBUG
148 #define LWIP_PLATFORM_ERROR(message) LWIP_PLATFORM_DIAG((message))
149 #else
150 #define LWIP_PLATFORM_ERROR(message)
151 #endif
152 
153 /* if "expression" isn't true, then print "message" and execute "handler" expression */
154 #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
155  LWIP_PLATFORM_ERROR(message); handler;}} while(0)
156 #endif /* LWIP_ERROR */
157 
161 #ifdef __DOXYGEN__
162 #define LWIP_DEBUG
163 #undef LWIP_DEBUG
164 #endif
165 
166 #ifdef LWIP_DEBUG
167 #ifndef LWIP_PLATFORM_DIAG
168 #error "If you want to use LWIP_DEBUG, LWIP_PLATFORM_DIAG(message) needs to be defined in your arch/cc.h"
169 #endif
170 #define LWIP_DEBUGF(debug, message) do { \
171  if ( \
172  ((debug) & LWIP_DBG_ON) && \
173  ((debug) & LWIP_DBG_TYPES_ON) && \
174  ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
175  LWIP_PLATFORM_DIAG(message); \
176  if ((debug) & LWIP_DBG_HALT) { \
177  while(1); \
178  } \
179  } \
180  } while(0)
181 
182 #else /* LWIP_DEBUG */
183 #define LWIP_DEBUGF(debug, message)
184 #endif /* LWIP_DEBUG */
185 
186 #endif /* LWIP_HDR_DEBUG_H */