cc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 LWIP_ARCH_CC_H
  33. #define LWIP_ARCH_CC_H
  34. #include "stdio.h"
  35. #include "FreeRTOS.h"
  36. #include <errno.h>
  37. #ifdef _MSC_VER
  38. #pragma warning (disable: 4127) /* conditional expression is constant */
  39. #pragma warning (disable: 4996) /* 'strncpy' was declared deprecated */
  40. #pragma warning (disable: 4103) /* structure packing changed by including file */
  41. #pragma warning (disable: 4820) /* 'x' bytes padding added after data member 'y' */
  42. #pragma warning (disable: 4711) /* The compiler performed inlining on the given function, although it was not marked for inlining */
  43. #endif
  44. #ifdef _MSC_VER
  45. #if _MSC_VER >= 1910
  46. #include <errno.h> /* use MSVC errno for >= 2017 */
  47. #else
  48. #define LWIP_PROVIDE_ERRNO /* provide errno for MSVC pre-2017 */
  49. #endif
  50. #else /* _MSC_VER */
  51. #define LWIP_PROVIDE_ERRNO /* provide errno for non-MSVC */
  52. #endif /* _MSC_VER */
  53. /* Define platform endianness (might already be defined) */
  54. #ifndef BYTE_ORDER
  55. #define BYTE_ORDER LITTLE_ENDIAN
  56. #endif /* BYTE_ORDER */
  57. typedef int sys_prot_t;
  58. #ifdef _MSC_VER
  59. /* define _INTPTR for Win32 MSVC stdint.h */
  60. #define _INTPTR 2
  61. /* Do not use lwIP default definitions for format strings
  62. * because these do not work with MSVC 2010 compiler (no inttypes.h)
  63. */
  64. #define LWIP_NO_INTTYPES_H 1
  65. /* Define (sn)printf formatters for these lwIP types */
  66. #define X8_F "02x"
  67. #define U16_F "hu"
  68. #define U32_F "lu"
  69. #define S32_F "ld"
  70. #define X32_F "lx"
  71. #define S16_F "hd"
  72. #define X16_F "hx"
  73. #define SZT_F "lu"
  74. #endif /* _MSC_VER */
  75. /* Compiler hints for packing structures */
  76. #define PACK_STRUCT_USE_INCLUDES
  77. #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
  78. printf("Assertion \"%s\" failed at line %d in %s\n", message, __LINE__, __FILE__); \
  79. fflush(NULL);handler;} } while(0)
  80. #ifdef _MSC_VER
  81. /* C runtime functions redefined */
  82. #if _MSC_VER < 1910
  83. #define snprintf _snprintf
  84. #endif
  85. #define strdup _strdup
  86. #endif
  87. /* Define an example for LWIP_PLATFORM_DIAG: since this uses varargs and the old
  88. * C standard lwIP targets does not support this in macros, we have extra brackets
  89. * around the arguments, which are left out in the following macro definition:
  90. */
  91. #if !defined(LWIP_TESTMODE) || !LWIP_TESTMODE
  92. void lwip_win32_platform_diag(const char *format, ...);
  93. #define LWIP_PLATFORM_DIAG(x) lwip_win32_platform_diag x
  94. #endif
  95. //#ifndef LWIP_NORAND
  96. //extern unsigned int sys_win_rand(void);
  97. //#define LWIP_RAND() (sys_win_rand())
  98. //#endif
  99. #define PPP_INCLUDE_SETTINGS_HEADER
  100. #endif /* LWIP_ARCH_CC_H */