1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SYS_COMMON_HEADER_H 17 #define SYS_COMMON_HEADER_H 18 19 #include <unistd.h> 20 #include <pthread.h> 21 #include <errno.h> 22 #include <semaphore.h> 23 #include <sys/stat.h> 24 #include <sys/types.h> 25 #include <mqueue.h> 26 27 #ifndef LWIP_LITEOS_A_COMPAT 28 #include "asm/atomic.h" 29 #include "lwip/sockets.h" 30 #else 31 #include <net/if.h> 32 #include <limits.h> 33 #include <netinet/in.h> 34 #include <arpa/inet.h> 35 #include <sys/ioctl.h> 36 #endif /* LWIP_LITEOS_A_COMPAT */ 37 38 #ifndef offsetof 39 #define offsetof(type, member) __builtin_offsetof(type, member) 40 #endif 41 42 #define container_of(ptr, type, member) ({ \ 43 void *__mptr = (void *)(ptr); \ 44 (type *)((char *)__mptr - offsetof(type, member)); \ 45 }) 46 47 #define NSTACKX_EXPORT extern 48 #define NSTACKX_EXPORT_VARIABLE 49 50 typedef int32_t SocketDesc; 51 52 #define INVALID_SOCKET (-1) 53 54 #ifdef LWIP_LITEOS_A_COMPAT 55 #ifndef LWIP_SOCKET_OFFSET 56 #define LWIP_SOCKET_OFFSET 0 57 #endif 58 59 #ifndef LWIP_CONFIG_NUM_SOCKETS 60 #define LWIP_CONFIG_NUM_SOCKETS 128 61 #endif 62 #endif /* LWIP_LITEOS_A_COMPAT */ 63 64 #endif // SYS_COMMON_HEADER_H 65