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 "cpu.h" 36 37 #define LWIP_MAILBOX_QUEUE 1 38 #define LWIP_TIMEVAL_PRIVATE 0 39 #define LWIP_NO_INTTYPES_H 1 40 41 #if defined(__GNUC__) 42 #define PACK_STRUCT_BEGIN 43 #define PACK_STRUCT_STRUCT __attribute__((packed)) 44 #define PACK_STRUCT_FIELD(x) x 45 #elif defined(__ICCARM__) 46 #define PACK_STRUCT_BEGIN __packed 47 #define PACK_STRUCT_STRUCT 48 #define PACK_STRUCT_FIELD(x) x 49 #else 50 #define PACK_STRUCT_BEGIN 51 #define PACK_STRUCT_STRUCT 52 #define PACK_STRUCT_FIELD(x) x 53 #endif 54 55 56 #if LWIP_NO_INTTYPES_H 57 #define U8_F "2d" 58 #define X8_F "2x" 59 #define U16_F "4d" 60 #define S16_F "4d" 61 #define X16_F "4x" 62 #define U32_F "8ld" 63 #define S32_F "8ld" 64 #define X32_F "8lx" 65 #define SZT_F U32_F 66 #endif 67 68 /* 69 * Platform specific diagnostic output - 70 * LWIP_PLATFORM_DIAG(x) - non-fatal, print a message. 71 * LWIP_PLATFORM_ASSERT(x) - fatal, print message and abandon execution. 72 * Portability defines for printf formatters: 73 * U16_F, S16_F, X16_F, U32_F, S32_F, X32_F, SZT_F 74 */ 75 #ifndef LWIP_PLATFORM_ASSERT 76 #define LWIP_PLATFORM_ASSERT(x) \ 77 do \ 78 { printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); \ 79 } while(0) 80 #endif 81 82 #ifndef LWIP_PLATFORM_DIAG 83 #define LWIP_PLATFORM_DIAG(x) do {printf x ;} while(0) 84 #endif 85 86 87 88 89 /* 90 * unknow defination 91 */ 92 // cup byte order 93 #ifndef BYTE_ORDER 94 #define BYTE_ORDER LITTLE_ENDIAN 95 #endif 96 97 #define LWIP_RAND() ((u32_t)rand()) 98 99 #if 0 100 101 #define LWIP_MAILBOX_QUEUE 1 102 #define LWIP_TIMEVAL_PRIVATE 0 103 #define LWIP_NO_INTTYPES_H 1 104 105 #define LWIP_RAND() ((u32_t)rand()) 106 107 #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) 108 109 #if 0 110 typedef unsigned char u8_t; 111 typedef signed char s8_t; 112 typedef unsigned short u16_t; 113 typedef signed short s16_t; 114 typedef unsigned int u32_t; 115 typedef signed long s32_t; 116 typedef u32_t mem_ptr_t; 117 typedef int sys_prot_t; 118 #endif 119 120 #define U16_F "d" 121 #define S16_F "d" 122 #define X16_F "x" 123 #define U32_F "d" 124 #define S32_F "d" 125 #define X32_F "x" 126 #define SZT_F "uz" 127 128 /* define compiler specific symbols */ 129 #if defined (__ICCARM__) 130 #if !defined (__IARSTDLIB__) 131 #define _STRING 132 #ifndef memcmp 133 #define memcmp(dst, src, sz) _memcmp(dst, src, sz) 134 #endif 135 #ifndef memset 136 #define memset(dst, val, sz) _memset(dst, val, sz) 137 #endif 138 #ifndef memcpy 139 #define memcpy(dst, src, sz) _memcpy(dst, src, sz) 140 #endif 141 #endif // __IARSTDLIB__ 142 143 #define PACK_STRUCT_BEGIN 144 #define PACK_STRUCT_STRUCT 145 #define PACK_STRUCT_END 146 #define PACK_STRUCT_FIELD(x) x 147 #define PACK_STRUCT_USE_INCLUDES 148 149 #elif defined (__CC_ARM) 150 151 #define PACK_STRUCT_BEGIN __packed 152 #define PACK_STRUCT_STRUCT 153 #define PACK_STRUCT_END 154 #define PACK_STRUCT_FIELD(x) x 155 156 #elif defined (__GNUC__) 157 158 #define PACK_STRUCT_BEGIN 159 #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) 160 #define PACK_STRUCT_END 161 #define PACK_STRUCT_FIELD(x) x 162 #define PACK_STRUCT_USE_INCLUDES 163 164 #elif defined (__TASKING__) 165 166 #define PACK_STRUCT_BEGIN 167 #define PACK_STRUCT_STRUCT 168 #define PACK_STRUCT_END 169 #define PACK_STRUCT_FIELD(x) x 170 171 #endif 172 173 //#define LWIP_PLATFORM_DIAG printf //Realtek add 174 175 #define LWIP_PLATFORM_ASSERT(x) //do { if(!(x)) while(1); } while(0) 176 #endif 177 178 #endif /* __CC_H__ */ 179