UbixOS  2.0
arch.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  * derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30  * OF SUCH DAMAGE.
31  *
32  * This file is part of the lwIP TCP/IP stack.
33  *
34  * Author: Adam Dunkels <adam@sics.se>
35  *
36  */
37 #ifndef LWIP_HDR_ARCH_H
38 #define LWIP_HDR_ARCH_H
39 
40 #ifndef LITTLE_ENDIAN
41 #define LITTLE_ENDIAN 1234
42 #endif
43 
44 #ifndef BIG_ENDIAN
45 #define BIG_ENDIAN 4321
46 #endif
47 
48 #include <sys/types.h>
49 #include <net/arch/cc.h>
50 #include <lib/kprintf.h>
51 #include <ubixos/kpanic.h>
52 
67 #ifndef BYTE_ORDER
68 #define BYTE_ORDER LITTLE_ENDIAN
69 #endif
70 
72 #ifdef __DOXYGEN__
73 #define LWIP_RAND() ((u32_t)rand())
74 #endif
75 
81 #ifndef LWIP_PLATFORM_DIAG
82 #define LWIP_PLATFORM_DIAG(x) do {kprintf x;} while(0)
83 #endif
84 
90 #ifndef LWIP_PLATFORM_ASSERT
91 #define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); kpanic("asserted");} while(0)
92 #endif
93 
98 #ifndef LWIP_NO_STDDEF_H
99 #define LWIP_NO_STDDEF_H 0
100 #endif
101 
102 #if !LWIP_NO_STDDEF_H
103 /* for size_t */
104 /* MrOlsen 2017-12-17
105 #include <stddef.h>
106 */
107 #endif
108 
113 #ifndef LWIP_NO_STDINT_H
114 #define LWIP_NO_STDINT_H 0
115 #endif
116 
117 /* Define generic types used in lwIP */
118 #if !LWIP_NO_STDINT_H
119 /* MrOlsen 2017-12-17
120 #include <stdint.h>
121 */
122 typedef uint8_t u8_t;
123 typedef int8_t s8_t;
124 typedef uint16_t u16_t;
125 typedef int16_t s16_t;
126 typedef uint32_t u32_t;
127 typedef int32_t s32_t;
129 #endif
130 
135 #ifndef LWIP_NO_INTTYPES_H
136 #define LWIP_NO_INTTYPES_H 0
137 #endif
138 
139 /* Define (sn)printf formatters for these lwIP types */
140 #if !LWIP_NO_INTTYPES_H
141 /* MrOlsen
142 #include <inttypes.h>
143 */
144 #ifndef X8_F
145 #define X8_F "02" PRIx8
146 #endif
147 #ifndef U16_F
148 #define U16_F PRIu16
149 #endif
150 #ifndef S16_F
151 #define S16_F PRId16
152 #endif
153 #ifndef X16_F
154 #define X16_F PRIx16
155 #endif
156 #ifndef U32_F
157 #define U32_F PRIu32
158 #endif
159 #ifndef S32_F
160 #define S32_F PRId32
161 #endif
162 #ifndef X32_F
163 #define X32_F PRIx32
164 #endif
165 #ifndef SZT_F
166 #define SZT_F PRIuPTR
167 #endif
168 #endif
169 
174 #ifndef LWIP_NO_LIMITS_H
175 #define LWIP_NO_LIMITS_H 0
176 #endif
177 
178 /* Include limits.h? */
179 #if !LWIP_NO_LIMITS_H
180 /*
181 #include <limits.h>
182 */
183 #endif
184 
186 #ifndef LWIP_CONST_CAST
187 #define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val))
188 #endif
189 
191 #ifndef LWIP_ALIGNMENT_CAST
192 #define LWIP_ALIGNMENT_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
193 #endif
194 
198 #ifndef LWIP_PTR_NUMERIC_CAST
199 #define LWIP_PTR_NUMERIC_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
200 #endif
201 
212 #ifndef LWIP_DECLARE_MEMORY_ALIGNED
213 #define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]
214 #endif
215 
220 #ifndef LWIP_MEM_ALIGN_SIZE
221 #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U))
222 #endif
223 
228 #ifndef LWIP_MEM_ALIGN_BUFFER
229 #define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1U))
230 #endif
231 
235 #ifndef LWIP_MEM_ALIGN
236 #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
237 #endif
238 
239 #ifdef __cplusplus
240 extern "C" {
241 #endif
242 
248 #ifndef PACK_STRUCT_BEGIN
249 #define PACK_STRUCT_BEGIN
250 #endif /* PACK_STRUCT_BEGIN */
251 
257 #ifndef PACK_STRUCT_END
258 #define PACK_STRUCT_END
259 #endif /* PACK_STRUCT_END */
260 
266 #ifndef PACK_STRUCT_STRUCT
267 #if defined(__GNUC__) || defined(__clang__)
268 #define PACK_STRUCT_STRUCT __attribute__((packed))
269 #else
270 #define PACK_STRUCT_STRUCT
271 #endif
272 #endif /* PACK_STRUCT_STRUCT */
273 
279 #ifndef PACK_STRUCT_FIELD
280 #define PACK_STRUCT_FIELD(x) x
281 #endif /* PACK_STRUCT_FIELD */
282 
288 #ifndef PACK_STRUCT_FLD_8
289 #define PACK_STRUCT_FLD_8(x) PACK_STRUCT_FIELD(x)
290 #endif /* PACK_STRUCT_FLD_8 */
291 
297 #ifndef PACK_STRUCT_FLD_S
298 #define PACK_STRUCT_FLD_S(x) PACK_STRUCT_FIELD(x)
299 #endif /* PACK_STRUCT_FLD_S */
300 
309 #ifdef __DOXYGEN__
310 #define PACK_STRUCT_USE_INCLUDES
311 #endif
312 
314 #ifndef LWIP_UNUSED_ARG
315 #define LWIP_UNUSED_ARG(x) (void)x
316 #endif /* LWIP_UNUSED_ARG */
317 
322 #ifdef __cplusplus
323 }
324 #endif
325 
326 #endif /* LWIP_HDR_ARCH_H */
s16_t
int16_t s16_t
Definition: arch.h:125
u16_t
uint16_t u16_t
Definition: arch.h:124
int16_t
__int16_t int16_t
Definition: types.h:103
u32_t
uint32_t u32_t
Definition: arch.h:126
types.h
uint16_t
__uint16_t uint16_t
Definition: types.h:45
kpanic.h
kprintf.h
s32_t
int32_t s32_t
Definition: arch.h:127
int8_t
__int8_t int8_t
Definition: types.h:98
u8_t
uint8_t u8_t
Definition: arch.h:122
uint32_t
__uint32_t uint32_t
Definition: types.h:46
int32_t
__int32_t int32_t
Definition: types.h:108
s8_t
int8_t s8_t
Definition: arch.h:123
mem_ptr_t
uintptr_t mem_ptr_t
Definition: arch.h:128
cc.h
uintptr_t
uint32_t uintptr_t
Definition: types.h:136
uint8_t
__uint8_t uint8_t
Definition: types.h:44