ReactOS 0.4.16-dev-306-g647d351
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 "arch/cc.h"
49
66#ifndef BYTE_ORDER
67#define BYTE_ORDER LITTLE_ENDIAN
68#endif
69
71#ifdef __DOXYGEN__
72#define LWIP_RAND() ((u32_t)rand())
73#endif
74
80#ifndef LWIP_PLATFORM_DIAG
81#define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
82#include <stdio.h>
83#include <stdlib.h>
84#endif
85
91#ifndef LWIP_PLATFORM_ASSERT
92#define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \
93 x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
94#include <stdio.h>
95#include <stdlib.h>
96#endif
97
102#ifndef LWIP_NO_STDDEF_H
103#define LWIP_NO_STDDEF_H 0
104#endif
105
106#if !LWIP_NO_STDDEF_H
107#include <stddef.h> /* for size_t */
108#endif
109
114#ifndef LWIP_NO_STDINT_H
115#define LWIP_NO_STDINT_H 0
116#endif
117
118/* Define generic types used in lwIP */
119#if !LWIP_NO_STDINT_H
120#include <stdint.h>
121/* stdint.h is C99 which should also provide support for 64-bit integers */
122#if !defined(LWIP_HAVE_INT64) && defined(UINT64_MAX)
123#define LWIP_HAVE_INT64 1
124#endif
125typedef uint8_t u8_t;
126typedef int8_t s8_t;
131#if LWIP_HAVE_INT64
132typedef uint64_t u64_t;
133typedef int64_t s64_t;
134#endif
136#endif
137
142#ifndef LWIP_NO_INTTYPES_H
143#define LWIP_NO_INTTYPES_H 0
144#endif
145
146/* Define (sn)printf formatters for these lwIP types */
147#if !LWIP_NO_INTTYPES_H
148#include <inttypes.h>
149#ifndef X8_F
150#define X8_F "02" PRIx8
151#endif
152#ifndef U16_F
153#define U16_F PRIu16
154#endif
155#ifndef S16_F
156#define S16_F PRId16
157#endif
158#ifndef X16_F
159#define X16_F PRIx16
160#endif
161#ifndef U32_F
162#define U32_F PRIu32
163#endif
164#ifndef S32_F
165#define S32_F PRId32
166#endif
167#ifndef X32_F
168#define X32_F PRIx32
169#endif
170#ifndef SZT_F
171#define SZT_F PRIuPTR
172#endif
173#endif
174
179#ifndef LWIP_NO_LIMITS_H
180#define LWIP_NO_LIMITS_H 0
181#endif
182
183/* Include limits.h? */
184#if !LWIP_NO_LIMITS_H
185#include <limits.h>
186#endif
187
188/* Do we need to define ssize_t? This is a compatibility hack:
189 * Unfortunately, this type seems to be unavailable on some systems (even if
190 * sys/types or unistd.h are available).
191 * Being like that, we define it to 'int' if SSIZE_MAX is not defined.
192 */
193#ifdef SSIZE_MAX
194/* If SSIZE_MAX is defined, unistd.h should provide the type as well */
195#ifndef LWIP_NO_UNISTD_H
196#define LWIP_NO_UNISTD_H 0
197#endif
198#if !LWIP_NO_UNISTD_H
199#include <unistd.h>
200#endif
201#else /* SSIZE_MAX */
202typedef int ssize_t;
203#define SSIZE_MAX INT_MAX
204#endif /* SSIZE_MAX */
205
206/* some maximum values needed in lwip code */
207#define LWIP_UINT32_MAX 0xffffffff
208
214#ifndef LWIP_NO_CTYPE_H
215#define LWIP_NO_CTYPE_H 0
216#endif
217
218#if LWIP_NO_CTYPE_H
219#define lwip_in_range(c, lo, up) ((u8_t)(c) >= (lo) && (u8_t)(c) <= (up))
220#define lwip_isdigit(c) lwip_in_range((c), '0', '9')
221#define lwip_isxdigit(c) (lwip_isdigit(c) || lwip_in_range((c), 'a', 'f') || lwip_in_range((c), 'A', 'F'))
222#define lwip_islower(c) lwip_in_range((c), 'a', 'z')
223#define lwip_isspace(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || (c) == '\r' || (c) == '\t' || (c) == '\v')
224#define lwip_isupper(c) lwip_in_range((c), 'A', 'Z')
225#define lwip_tolower(c) (lwip_isupper(c) ? (c) - 'A' + 'a' : c)
226#define lwip_toupper(c) (lwip_islower(c) ? (c) - 'a' + 'A' : c)
227#else
228#include <ctype.h>
229#define lwip_isdigit(c) isdigit((unsigned char)(c))
230#define lwip_isxdigit(c) isxdigit((unsigned char)(c))
231#define lwip_islower(c) islower((unsigned char)(c))
232#define lwip_isspace(c) isspace((unsigned char)(c))
233#define lwip_isupper(c) isupper((unsigned char)(c))
234#define lwip_tolower(c) tolower((unsigned char)(c))
235#define lwip_toupper(c) toupper((unsigned char)(c))
236#endif
237
239#ifndef LWIP_CONST_CAST
240#define LWIP_CONST_CAST(target_type, val) ((target_type)((ptrdiff_t)val))
241#endif
242
244#ifndef LWIP_ALIGNMENT_CAST
245#define LWIP_ALIGNMENT_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
246#endif
247
251#ifndef LWIP_PTR_NUMERIC_CAST
252#define LWIP_PTR_NUMERIC_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
253#endif
254
256#ifndef LWIP_PACKED_CAST
257#define LWIP_PACKED_CAST(target_type, val) LWIP_CONST_CAST(target_type, val)
258#endif
259
270#ifndef LWIP_DECLARE_MEMORY_ALIGNED
271#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]
272#endif
273
278#ifndef LWIP_MEM_ALIGN_SIZE
279#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1U) & ~(MEM_ALIGNMENT-1U))
280#endif
281
286#ifndef LWIP_MEM_ALIGN_BUFFER
287#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1U))
288#endif
289
293#ifndef LWIP_MEM_ALIGN
294#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
295#endif
296
297#ifdef __cplusplus
298extern "C" {
299#endif
300
306#ifndef PACK_STRUCT_BEGIN
307#define PACK_STRUCT_BEGIN
308#endif /* PACK_STRUCT_BEGIN */
309
315#ifndef PACK_STRUCT_END
316#define PACK_STRUCT_END
317#endif /* PACK_STRUCT_END */
318
324#ifndef PACK_STRUCT_STRUCT
325#if defined(__GNUC__) || defined(__clang__)
326#define PACK_STRUCT_STRUCT __attribute__((packed))
327#else
328#define PACK_STRUCT_STRUCT
329#endif
330#endif /* PACK_STRUCT_STRUCT */
331
337#ifndef PACK_STRUCT_FIELD
338#define PACK_STRUCT_FIELD(x) x
339#endif /* PACK_STRUCT_FIELD */
340
346#ifndef PACK_STRUCT_FLD_8
347#define PACK_STRUCT_FLD_8(x) PACK_STRUCT_FIELD(x)
348#endif /* PACK_STRUCT_FLD_8 */
349
355#ifndef PACK_STRUCT_FLD_S
356#define PACK_STRUCT_FLD_S(x) PACK_STRUCT_FIELD(x)
357#endif /* PACK_STRUCT_FLD_S */
358
367#ifdef __DOXYGEN__
368#define PACK_STRUCT_USE_INCLUDES
369#endif
370
372#ifndef LWIP_UNUSED_ARG
373#define LWIP_UNUSED_ARG(x) (void)x
374#endif /* LWIP_UNUSED_ARG */
375
381#if defined __DOXYGEN__
382#define LWIP_PROVIDE_ERRNO
383#endif
384
385/* Use a special, reproducable version of rand() for fuzz tests? */
386#ifdef LWIP_RAND_FOR_FUZZ
387#ifdef LWIP_RAND
388#undef LWIP_RAND
389#endif
390u32_t lwip_fuzz_rand(void);
391#define LWIP_RAND() lwip_fuzz_rand()
392#endif
393
398#ifdef __cplusplus
399}
400#endif
401
402#endif /* LWIP_HDR_ARCH_H */
unsigned short int uint16_t
Definition: acefiex.h:54
signed char int8_t
Definition: acefiex.h:50
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
INT16 int16_t
Definition: types.h:70
UINT64 uint64_t
Definition: types.h:77
INT64 int64_t
Definition: types.h:72
int32_t s32_t
Definition: arch.h:130
uint32_t u32_t
Definition: arch.h:129
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
int8_t s8_t
Definition: arch.h:126
int16_t s16_t
Definition: arch.h:128
uintptr_t mem_ptr_t
Definition: arch.h:135
int ssize_t
Definition: arch.h:202
unsigned int uintptr_t
Definition: intrin.h:47
BYTE uint8_t
Definition: msvideo1.c:66