1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2016. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. The name of the author may not be used to endorse or promote 13 * products derived from this software without specific prior 14 * written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Description: define system adaptor unit 29 * Author: none 30 * Create: 2013 31 */ 32 33 #ifndef __CC_H__ 34 #define __CC_H__ 35 36 #include "los_typedef.h" 37 #include <sys/time.h> 38 #ifdef LWIP_DEBUG 39 #include "stdio.h" 40 #endif 41 42 #if defined (__cplusplus) && __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 46 #define LWIP_TIMEVAL_PRIVATE 0 47 #define LWIP_NO_INTTYPES_H 1 48 #define LWIP_MAX_VALUE 0xFFFFFFFF 49 50 /* Define (sn)printf formatters for these lwIP types */ 51 #define X8_F "02x" 52 #define U8_F "hhu" 53 #define U16_F "hu" 54 #define S16_F "hd" 55 #define X16_F "hx" 56 #define U32_F "u" 57 #define S32_F "d" 58 #define X32_F "x" 59 #define SZT_F "uz" 60 61 /* ARM/LPC17xx is little endian only */ 62 #ifdef BYTE_ORDER 63 #undef BYTE_ORDER 64 #endif 65 #define BYTE_ORDER LITTLE_ENDIAN 66 67 /* Use LWIP error codes */ 68 #if defined(__arm__) && defined(__ARMCC_VERSION) 69 /* Keil uVision4 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 ALIGNED(n) __align(n) 75 #elif defined (__IAR_SYSTEMS_ICC__) 76 /* IAR Embedded Workbench tools */ 77 #define PACK_STRUCT_BEGIN __packed 78 #define PACK_STRUCT_STRUCT 79 #define PACK_STRUCT_END 80 #define PACK_STRUCT_FIELD(fld) fld 81 #error NEEDS ALIGNED 82 #else 83 /* GCC tools (CodeSourcery) */ 84 #define PACK_STRUCT_BEGIN 85 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) 86 #define PACK_STRUCT_END 87 #define PACK_STRUCT_FIELD(fld) fld 88 #define ALIGNED(n) __attribute__((aligned (n))) 89 #endif 90 91 /* Provide Thumb-2 routines for GCC to improve performance */ 92 #if defined(TOOLCHAIN_GCC) && defined(__thumb2__) 93 #define LWIP_CHKSUM thumb2_checksum 94 /* 95 * Set algorithm to 0 so that unused lwip_standard_chksum function 96 * doesn't generate compiler warning 97 */ 98 #define LWIP_CHKSUM_ALGORITHM 0 99 100 void *thumb2_memcpy(void *pDest, const void *pSource, size_t length); 101 u16_t thumb2_checksum(void *pData, int length); 102 #else 103 /* Used with IP headers only */ 104 #define LWIP_CHKSUM_ALGORITHM 4 105 #endif 106 107 #ifdef LWIP_DEBUG 108 void assert_printf(char *msg, int line, const char *file); 109 110 /* Plaform specific diagnostic output */ 111 #define LWIP_PLATFORM_DIAG(vars) printf vars 112 #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); } 113 #else 114 #define LWIP_PLATFORM_DIAG(msg) { ; } 115 #define LWIP_PLATFORM_ASSERT(flag) { ; } 116 #endif 117 118 #define LWIP_PLATFORM_PRINT PRINTK 119 #define LWIP_PLATFORM_HTONS(x) htons(x) 120 #define LWIP_PLATFORM_HTONL(x) htonl(x) 121 122 #if defined (__cplusplus) && __cplusplus 123 } 124 #endif /* __cplusplus */ 125 #endif /* __CC_H__ */ 126 127