cc.h 4.1 KB

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