]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/net/lwip/lwip-sys/arch/cc.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[qmk_firmware.git] / tmk_core / tool / mbed / mbed-sdk / libraries / net / lwip / lwip-sys / 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 #ifndef __CC_H__ 
33 #define __CC_H__ 
34
35 #include <stdint.h>
36
37 /* Types based on stdint.h */
38 typedef uint8_t            u8_t; 
39 typedef int8_t             s8_t; 
40 typedef uint16_t           u16_t; 
41 typedef int16_t            s16_t; 
42 typedef uint32_t           u32_t; 
43 typedef int32_t            s32_t; 
44 typedef uintptr_t          mem_ptr_t; 
45
46 /* Define (sn)printf formatters for these lwIP types */
47 #define U16_F "hu"
48 #define S16_F "hd"
49 #define X16_F "hx"
50 #define U32_F "lu"
51 #define S32_F "ld"
52 #define X32_F "lx"
53 #define SZT_F "uz"
54
55 /* ARM/LPC17xx is little endian only */
56 #define BYTE_ORDER LITTLE_ENDIAN
57
58 /* Use LWIP error codes */
59 #define LWIP_PROVIDE_ERRNO
60
61 #if defined(__arm__) && defined(__ARMCC_VERSION) 
62     /* Keil uVision4 tools */
63     #define PACK_STRUCT_BEGIN __packed
64     #define PACK_STRUCT_STRUCT
65     #define PACK_STRUCT_END
66     #define PACK_STRUCT_FIELD(fld) fld
67     #define ALIGNED(n)  __align(n)
68 #elif defined (__IAR_SYSTEMS_ICC__) 
69     /* IAR Embedded Workbench tools */
70     #define PACK_STRUCT_BEGIN __packed
71     #define PACK_STRUCT_STRUCT
72     #define PACK_STRUCT_END
73     #define PACK_STRUCT_FIELD(fld) fld
74     #define IAR_STR(a) #a
75     #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##))
76 #else 
77     /* GCC tools (CodeSourcery) */
78     #define PACK_STRUCT_BEGIN
79     #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
80     #define PACK_STRUCT_END
81     #define PACK_STRUCT_FIELD(fld) fld
82     #define ALIGNED(n)  __attribute__((aligned (n)))
83 #endif 
84
85 /* Provide Thumb-2 routines for GCC to improve performance */
86 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__)
87     #define MEMCPY(dst,src,len)     thumb2_memcpy(dst,src,len)
88     #define LWIP_CHKSUM             thumb2_checksum
89     /* Set algorithm to 0 so that unused lwip_standard_chksum function
90        doesn't generate compiler warning */
91     #define LWIP_CHKSUM_ALGORITHM   0
92
93     void* thumb2_memcpy(void* pDest, const void* pSource, size_t length);
94     u16_t thumb2_checksum(void* pData, int length);
95 #else
96     /* Used with IP headers only */
97     #define LWIP_CHKSUM_ALGORITHM   1
98 #endif
99
100
101 #ifdef LWIP_DEBUG
102
103 #include "stdio.h"
104
105 void assert_printf(char *msg, int line, char *file);
106
107 /* Plaform specific diagnostic output */
108 #define LWIP_PLATFORM_DIAG(vars) printf vars
109 #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); }
110 #else
111 #define LWIP_PLATFORM_DIAG(msg) { ; }
112 #define LWIP_PLATFORM_ASSERT(flag) { ; }
113 #endif 
114
115 #include "cmsis.h"
116 #define LWIP_PLATFORM_HTONS(x)      __REV16(x)
117 #define LWIP_PLATFORM_HTONL(x)      __REV(x)
118
119 #endif /* __CC_H__ */