cc.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-02-20 Meco Man add RT-Thread copyright
  9. */
  10. /*
  11. * Copyright (c) 2001, Swedish Institute of Computer Science.
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * 1. Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the distribution.
  22. * 3. Neither the name of the Institute nor the names of its contributors
  23. * may be used to endorse or promote products derived from this software
  24. * without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
  27. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
  30. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36. * SUCH DAMAGE.
  37. *
  38. * This file is part of the lwIP TCP/IP stack.
  39. *
  40. * Author: Adam Dunkels <adam@sics.se>
  41. *
  42. * $Id: cc.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $
  43. */
  44. #ifndef __ARCH_CC_H__
  45. #define __ARCH_CC_H__
  46. #include <rthw.h>
  47. #include <rtthread.h>
  48. #ifndef BYTE_ORDER
  49. #ifdef ARCH_CPU_BIG_ENDIAN
  50. #define BYTE_ORDER BIG_ENDIAN
  51. #else
  52. #define BYTE_ORDER LITTLE_ENDIAN
  53. #endif /* ARCH_CPU_BIG_ENDIAN */
  54. #endif /* BYTE_ORDER */
  55. #if RT_USING_LWIP_VER_NUM < 0x20000
  56. #include <stdint.h>
  57. typedef uint8_t u8_t;
  58. typedef int8_t s8_t;
  59. typedef uint16_t u16_t;
  60. typedef int16_t s16_t;
  61. typedef uint32_t u32_t;
  62. typedef int32_t s32_t;
  63. typedef uintptr_t mem_ptr_t;
  64. #define U16_F "hu"
  65. #define S16_F "hd"
  66. #define X16_F "hx"
  67. #define U32_F "lu"
  68. #define S32_F "ld"
  69. #define X32_F "lx"
  70. #endif /* RT_USING_LWIP_VER_NUM < 0x20000 */
  71. #if defined(__CC_ARM) /* ARMCC compiler */
  72. #define PACK_STRUCT_FIELD(x) x
  73. #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
  74. #define PACK_STRUCT_BEGIN
  75. #define PACK_STRUCT_END
  76. #elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*Arm Compiler 6*/
  77. #define PACK_STRUCT_FIELD(x) x
  78. #define PACK_STRUCT_STRUCT __attribute__((packed))
  79. #define PACK_STRUCT_BEGIN
  80. #define PACK_STRUCT_END
  81. #elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */
  82. #define PACK_STRUCT_BEGIN
  83. #define PACK_STRUCT_STRUCT
  84. #define PACK_STRUCT_END
  85. #define PACK_STRUCT_FIELD(x) x
  86. #define PACK_STRUCT_USE_INCLUDES
  87. #elif defined(__GNUC__) /* GNU GCC Compiler */
  88. #define PACK_STRUCT_FIELD(x) x
  89. #define PACK_STRUCT_STRUCT __attribute__((packed))
  90. #define PACK_STRUCT_BEGIN
  91. #define PACK_STRUCT_END
  92. #elif defined(_MSC_VER)
  93. #define PACK_STRUCT_FIELD(x) x
  94. #define PACK_STRUCT_STRUCT
  95. #define PACK_STRUCT_BEGIN
  96. #define PACK_STRUCT_END
  97. #define PACK_STRUCT_USE_INCLUDES
  98. #endif
  99. void sys_arch_assert(const char* file, int line);
  100. #define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0)
  101. #define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0)
  102. #endif /* __ARCH_CC_H__ */