]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/blob - src/include/arch/cc.h
819db79ae9a0b2640e46ea084f7312b6e4ba3d6a
[pes-rpp/rpp-lwip.git] / src / include / arch / cc.h
1 /*
2  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  *    this list of conditions and the following disclaimer in the documentation
12  *    and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  *    derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25  * OF SUCH DAMAGE.
26  *
27  * This file is part of the lwIP TCP/IP stack.
28  *
29  * Author: Adam Dunkels <adam@sics.se>
30  *
31  */
32 /*
33  * settings to adapt lwIP for compiler and machine architecture
34  * DETAILS: ./lwip/doc/sys_arch.txt
35  */
36 #ifndef __CC_H__
37 #define __CC_H__
38
39 #include "types.h"
40
41 /* This file must either include a system-local <errno.h> which defines
42    the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO
43    to make lwip/arch.h define the codes which are used throughout. */
44 #define LWIP_PROVIDE_ERRNO
45
46 /* if the compiler does not provede memset() this file must include a
47    definition of it, or include a file which defines it. */
48
49 /* type definitions */
50 typedef uint8_t             u8_t;
51 typedef int8_t              s8_t;
52 typedef uint16_t            u16_t;
53 typedef int16_t             s16_t;
54 typedef uint32_t            u32_t;
55 typedef int32_t             s32_t;
56 typedef u32_t               mem_ptr_t;
57
58 /*#ifdef __little_endian__
59 #ifndef BYTE_ORDER
60 #define BYTE_ORDER LITTLE_ENDIAN
61 #endif
62 #else*/
63 #define BYTE_ORDER BIG_ENDIAN
64 /*#endif*/
65
66 /* Define (sn)printf formatters for these lwIP types */
67 #define U16_F "hu"
68 #define S16_F "hd"
69 #define X16_F "hx"
70 #define U32_F "u"
71 #define S32_F "d"
72 #define X32_F "x"
73
74
75 #if defined(__arm__) && defined(__ARMCC_VERSION)
76     //
77     // Setup PACKing macros for KEIL/RVMDK Tools
78     //
79     #define PACK_STRUCT_BEGIN __packed
80     #define PACK_STRUCT_STRUCT
81     #define PACK_STRUCT_END
82     #define PACK_STRUCT_FIELD(x) x
83 #elif defined (__IAR_SYSTEMS_ICC__)
84     //
85     // Setup PACKing macros for IAR Tools
86     //
87     #define PACK_STRUCT_BEGIN
88     #define PACK_STRUCT_STRUCT
89     #define PACK_STRUCT_END
90     #define PACK_STRUCT_FIELD(x) x
91     #define PACK_STRUCT_USE_INCLUDES
92 #elif defined (__TMS470__)
93     #define PACK_STRUCT_BEGIN
94     #define PACK_STRUCT_STRUCT
95     #define PACK_STRUCT_END
96     #define PACK_STRUCT_FIELD(x) x
97 #else
98     //
99     // Setup PACKing macros for GCC Tools
100     //
101     #define PACK_STRUCT_BEGIN
102     #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
103     #define PACK_STRUCT_END
104     #define PACK_STRUCT_FIELD(x) x
105 #endif
106
107 /*
108  *     1 - load byte by byte, construct 16 bits word and add: not efficient for most platforms
109  *     2 - load first byte if odd address, loop processing 16 bits words, add last byte.
110  *     3 - load first byte and word if not 4 byte aligned, loop processing 32 bits words, add last word/byte.
111  *
112  *     see inet_chksum.c
113  */
114 #ifndef LWIP_CHKSUM_ALGORITHM
115 #define LWIP_CHKSUM_ALGORITHM 2
116 #endif
117
118 //#define DEBUG
119 #ifdef DEBUG
120
121 #define LWIP_PLATFORM_DIAG(expr)
122
123 //extern void __error__(char *pcFilename, unsigned long ulLine);
124 extern int32_t rpp_sci_printf(const char* format, ...);
125 #define LWIP_PLATFORM_ASSERT(expr)      rpp_sci_printf((const char *) expr)
126 /*
127 {                                       \
128     if(!(expr))                         \
129     {                                   \
130         __error__(__FILE__, __LINE__);  \
131     }                                   \
132 }
133 */
134 #else
135 #define LWIP_PLATFORM_ASSERT(expr)
136 #endif /* DEBUG */
137
138 /* "lightweight" synchronization mechanisms */
139 /* #define SYS_ARCH_DECL_PROTECT(x) */ /* declare a protection state variable */
140 /* #define SYS_ARCH_PROTECT(x) */ /* enter protection mode */
141 /* #define SYS_ARCH_UNPROTECT(x) */ /* leave protection mode */
142
143 #endif /* __CC_H__ */