Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / lwip / standalone / arch / cc.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2014-2017 Nest Labs, Inc.
5  *    Copyright (c) 2001-2003 Swedish Institute of Computer Science.
6  *    All rights reserved.
7  *
8  *    Licensed under the Apache License, Version 2.0 (the "License");
9  *    you may not use this file except in compliance with the License.
10  *    You may obtain a copy of the License at
11  *
12  *        http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing, software
15  *    distributed under the License is distributed on an "AS IS" BASIS,
16  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  *    See the License for the specific language governing permissions and
18  *    limitations under the License.
19  */
20
21 /*
22  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
23  * All rights reserved.
24  *
25  * Redistribution and use in source and binary forms, with or without modification,
26  * are permitted provided that the following conditions are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright notice,
29  *    this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright notice,
31  *    this list of conditions and the following disclaimer in the documentation
32  *    and/or other materials provided with the distribution.
33  * 3. The name of the author may not be used to endorse or promote products
34  *    derived from this software without specific prior written permission.
35  *
36  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
38  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
39  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
41  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
44  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
45  * OF SUCH DAMAGE.
46  *
47  * This file is part of the lwIP TCP/IP stack.
48  *
49  * Author: Adam Dunkels <adam@sics.se>
50  *
51  */
52 #ifndef __ARCH_CC_H__
53 #define __ARCH_CC_H__
54
55 #ifndef __STDC_LIMIT_MACROS
56 #define __STDC_LIMIT_MACROS
57 #endif
58
59 /* Include some files for defining library routines */
60 #include <inttypes.h>
61 #include <limits.h>
62 #include <string.h>
63 #include <sys/time.h>
64
65 #define LWIP_TIMEVAL_PRIVATE 0
66
67 /* Define platform endianness */
68 #ifndef BYTE_ORDER
69 #define BYTE_ORDER LITTLE_ENDIAN
70 #endif /* BYTE_ORDER */
71
72 /* Define generic types used in lwIP */
73 typedef unsigned char u8_t;
74 typedef signed char s8_t;
75 typedef unsigned short u16_t;
76 typedef signed short s16_t;
77 typedef unsigned int u32_t;
78 typedef signed int s32_t;
79
80 typedef uintptr_t mem_ptr_t;
81
82 /* Define (sn)printf formatters for these lwIP types */
83 #define X8_F "02x"
84 #define U16_F "hu"
85 #define S16_F "hd"
86 #define X16_F "hx"
87 #define U32_F "u"
88 #define S32_F "d"
89 #define X32_F "x"
90
91 /* If only we could use C99 and get %zu */
92 #if defined(__x86_64__)
93 #define SZT_F "lu"
94 #else
95 #define SZT_F "u"
96 #endif
97
98 /* Compiler hints for packing structures */
99 #define PACK_STRUCT_FIELD(x) x
100 #define PACK_STRUCT_STRUCT __attribute__((packed))
101 #define PACK_STRUCT_BEGIN
102 #define PACK_STRUCT_END
103
104 /* prototypes for printf() and abort() */
105 #include <stdio.h>
106 #include <stdlib.h>
107 /* Plaform specific diagnostic output */
108 #define LWIP_PLATFORM_DIAG(x)                                                                                                      \
109     do                                                                                                                             \
110     {                                                                                                                              \
111         printf x;                                                                                                                  \
112     } while (0)
113
114 #define LWIP_PLATFORM_ASSERT(x)                                                                                                    \
115     do                                                                                                                             \
116     {                                                                                                                              \
117         printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__);                                               \
118         fflush(NULL);                                                                                                              \
119         abort();                                                                                                                   \
120     } while (0)
121
122 #define LWIP_RAND() ((u32_t) rand())
123
124 #endif /* __ARCH_CC_H__ */