mbed-os
Fork of mbed-os by
features/FEATURE_LWIP/lwip-interface/lwip-sys/arch/cc.h@0:f269e3021894, 2016-10-23 (annotated)
- Committer:
- elessair
- Date:
- Sun Oct 23 15:10:02 2016 +0000
- Revision:
- 0:f269e3021894
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elessair | 0:f269e3021894 | 1 | /* |
elessair | 0:f269e3021894 | 2 | * Copyright (c) 2001-2003 Swedish Institute of Computer Science. |
elessair | 0:f269e3021894 | 3 | * All rights reserved. |
elessair | 0:f269e3021894 | 4 | * |
elessair | 0:f269e3021894 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
elessair | 0:f269e3021894 | 6 | * are permitted provided that the following conditions are met: |
elessair | 0:f269e3021894 | 7 | * |
elessair | 0:f269e3021894 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
elessair | 0:f269e3021894 | 9 | * this list of conditions and the following disclaimer. |
elessair | 0:f269e3021894 | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
elessair | 0:f269e3021894 | 11 | * this list of conditions and the following disclaimer in the documentation |
elessair | 0:f269e3021894 | 12 | * and/or other materials provided with the distribution. |
elessair | 0:f269e3021894 | 13 | * 3. The name of the author may not be used to endorse or promote products |
elessair | 0:f269e3021894 | 14 | * derived from this software without specific prior written permission. |
elessair | 0:f269e3021894 | 15 | * |
elessair | 0:f269e3021894 | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
elessair | 0:f269e3021894 | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
elessair | 0:f269e3021894 | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
elessair | 0:f269e3021894 | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
elessair | 0:f269e3021894 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
elessair | 0:f269e3021894 | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
elessair | 0:f269e3021894 | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
elessair | 0:f269e3021894 | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
elessair | 0:f269e3021894 | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
elessair | 0:f269e3021894 | 25 | * OF SUCH DAMAGE. |
elessair | 0:f269e3021894 | 26 | * |
elessair | 0:f269e3021894 | 27 | * This file is part of the lwIP TCP/IP stack. |
elessair | 0:f269e3021894 | 28 | * |
elessair | 0:f269e3021894 | 29 | * Author: Adam Dunkels <adam@sics.se> |
elessair | 0:f269e3021894 | 30 | * |
elessair | 0:f269e3021894 | 31 | */ |
elessair | 0:f269e3021894 | 32 | #ifndef __CC_H__ |
elessair | 0:f269e3021894 | 33 | #define __CC_H__ |
elessair | 0:f269e3021894 | 34 | |
elessair | 0:f269e3021894 | 35 | #include <stdint.h> |
elessair | 0:f269e3021894 | 36 | #include <stddef.h> /* for size_t */ |
elessair | 0:f269e3021894 | 37 | |
elessair | 0:f269e3021894 | 38 | /* Types based on stdint.h */ |
elessair | 0:f269e3021894 | 39 | typedef uint8_t u8_t; |
elessair | 0:f269e3021894 | 40 | typedef int8_t s8_t; |
elessair | 0:f269e3021894 | 41 | typedef uint16_t u16_t; |
elessair | 0:f269e3021894 | 42 | typedef int16_t s16_t; |
elessair | 0:f269e3021894 | 43 | typedef uint32_t u32_t; |
elessair | 0:f269e3021894 | 44 | typedef int32_t s32_t; |
elessair | 0:f269e3021894 | 45 | typedef uintptr_t mem_ptr_t; |
elessair | 0:f269e3021894 | 46 | |
elessair | 0:f269e3021894 | 47 | /* Define (sn)printf formatters for these lwIP types */ |
elessair | 0:f269e3021894 | 48 | #define U16_F "hu" |
elessair | 0:f269e3021894 | 49 | #define S16_F "hd" |
elessair | 0:f269e3021894 | 50 | #define X16_F "hx" |
elessair | 0:f269e3021894 | 51 | #define U32_F "lu" |
elessair | 0:f269e3021894 | 52 | #define S32_F "ld" |
elessair | 0:f269e3021894 | 53 | #define X32_F "lx" |
elessair | 0:f269e3021894 | 54 | #define SZT_F "uz" |
elessair | 0:f269e3021894 | 55 | |
elessair | 0:f269e3021894 | 56 | /* ARM/LPC17xx is little endian only */ |
elessair | 0:f269e3021894 | 57 | #define BYTE_ORDER LITTLE_ENDIAN |
elessair | 0:f269e3021894 | 58 | |
elessair | 0:f269e3021894 | 59 | /* Use LWIP error codes */ |
elessair | 0:f269e3021894 | 60 | #define LWIP_PROVIDE_ERRNO |
elessair | 0:f269e3021894 | 61 | |
elessair | 0:f269e3021894 | 62 | #if defined(__arm__) && defined(__ARMCC_VERSION) |
elessair | 0:f269e3021894 | 63 | /* Keil uVision4 tools */ |
elessair | 0:f269e3021894 | 64 | #define PACK_STRUCT_BEGIN __packed |
elessair | 0:f269e3021894 | 65 | #define PACK_STRUCT_STRUCT |
elessair | 0:f269e3021894 | 66 | #define PACK_STRUCT_END |
elessair | 0:f269e3021894 | 67 | #define PACK_STRUCT_FIELD(fld) fld |
elessair | 0:f269e3021894 | 68 | #define ALIGNED(n) __align(n) |
elessair | 0:f269e3021894 | 69 | #elif defined (__IAR_SYSTEMS_ICC__) |
elessair | 0:f269e3021894 | 70 | /* IAR Embedded Workbench tools */ |
elessair | 0:f269e3021894 | 71 | #define PACK_STRUCT_BEGIN __packed |
elessair | 0:f269e3021894 | 72 | #define PACK_STRUCT_STRUCT |
elessair | 0:f269e3021894 | 73 | #define PACK_STRUCT_END |
elessair | 0:f269e3021894 | 74 | #define PACK_STRUCT_FIELD(fld) fld |
elessair | 0:f269e3021894 | 75 | #define IAR_STR(a) #a |
elessair | 0:f269e3021894 | 76 | #define ALIGNED(n) _Pragma(IAR_STR(data_alignment= ## n ##)) |
elessair | 0:f269e3021894 | 77 | #else |
elessair | 0:f269e3021894 | 78 | /* GCC tools (CodeSourcery) */ |
elessair | 0:f269e3021894 | 79 | #define PACK_STRUCT_BEGIN |
elessair | 0:f269e3021894 | 80 | #define PACK_STRUCT_STRUCT __attribute__ ((__packed__)) |
elessair | 0:f269e3021894 | 81 | #define PACK_STRUCT_END |
elessair | 0:f269e3021894 | 82 | #define PACK_STRUCT_FIELD(fld) fld |
elessair | 0:f269e3021894 | 83 | #define ALIGNED(n) __attribute__((aligned (n))) |
elessair | 0:f269e3021894 | 84 | #endif |
elessair | 0:f269e3021894 | 85 | |
elessair | 0:f269e3021894 | 86 | /* Provide Thumb-2 routines for GCC to improve performance */ |
elessair | 0:f269e3021894 | 87 | #if defined(TOOLCHAIN_GCC) && defined(__thumb2__) |
elessair | 0:f269e3021894 | 88 | #define MEMCPY(dst,src,len) thumb2_memcpy(dst,src,len) |
elessair | 0:f269e3021894 | 89 | #define LWIP_CHKSUM thumb2_checksum |
elessair | 0:f269e3021894 | 90 | /* Set algorithm to 0 so that unused lwip_standard_chksum function |
elessair | 0:f269e3021894 | 91 | doesn't generate compiler warning */ |
elessair | 0:f269e3021894 | 92 | #define LWIP_CHKSUM_ALGORITHM 0 |
elessair | 0:f269e3021894 | 93 | |
elessair | 0:f269e3021894 | 94 | void* thumb2_memcpy(void* pDest, const void* pSource, size_t length); |
elessair | 0:f269e3021894 | 95 | u16_t thumb2_checksum(void* pData, int length); |
elessair | 0:f269e3021894 | 96 | #else |
elessair | 0:f269e3021894 | 97 | /* Used with IP headers only */ |
elessair | 0:f269e3021894 | 98 | #define LWIP_CHKSUM_ALGORITHM 1 |
elessair | 0:f269e3021894 | 99 | #endif |
elessair | 0:f269e3021894 | 100 | |
elessair | 0:f269e3021894 | 101 | |
elessair | 0:f269e3021894 | 102 | #ifdef LWIP_DEBUG |
elessair | 0:f269e3021894 | 103 | |
elessair | 0:f269e3021894 | 104 | #include "stdio.h" |
elessair | 0:f269e3021894 | 105 | |
elessair | 0:f269e3021894 | 106 | void assert_printf(char *msg, int line, char *file); |
elessair | 0:f269e3021894 | 107 | |
elessair | 0:f269e3021894 | 108 | /* Plaform specific diagnostic output */ |
elessair | 0:f269e3021894 | 109 | #define LWIP_PLATFORM_DIAG(vars) printf vars |
elessair | 0:f269e3021894 | 110 | #define LWIP_PLATFORM_ASSERT(flag) { assert_printf((flag), __LINE__, __FILE__); } |
elessair | 0:f269e3021894 | 111 | #else |
elessair | 0:f269e3021894 | 112 | #define LWIP_PLATFORM_DIAG(msg) { ; } |
elessair | 0:f269e3021894 | 113 | #define LWIP_PLATFORM_ASSERT(flag) { ; } |
elessair | 0:f269e3021894 | 114 | #endif |
elessair | 0:f269e3021894 | 115 | |
elessair | 0:f269e3021894 | 116 | #include "cmsis.h" |
elessair | 0:f269e3021894 | 117 | #define LWIP_PLATFORM_HTONS(x) __REV16(x) |
elessair | 0:f269e3021894 | 118 | #define LWIP_PLATFORM_HTONL(x) __REV(x) |
elessair | 0:f269e3021894 | 119 | |
elessair | 0:f269e3021894 | 120 | #endif /* __CC_H__ */ |