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