1 /* 2 * Copyright (C) 2022 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 FILLP_OS_H 17 #define FILLP_OS_H 18 19 #include "fillpcallbacks.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 #ifndef FILLP_NUM_OF_EPOLL_INSTANCE_SUPPORTED 26 #define FILLP_NUM_OF_EPOLL_INSTANCE_SUPPORTED 10 27 #endif 28 29 #define FILLP_INVALID_PTR(Ptr) (FILLP_NULL_PTR == (Ptr)) 30 31 #ifdef FILLP_LITTLE_ENDIAN 32 33 #define FILLP_NTOHL(x) \ 34 ((((x)&0x000000ff) << 24) | (((x)&0x0000ff00) << 8) | (((x)&0x00ff0000) >> 8) | (((x)&0xff000000) >> 24)) 35 36 #define FILLP_NTOHS(x) (FILLP_UINT16)((((x)&0x00ff) << 8) | (((x)&0xff00) >> 8)) 37 38 #define FILLP_NTOHLL(x) \ 39 ((((x) >> 56) & 0x00000000000000FF) | (((x) >> 40) & 0x000000000000FF00) | (((x) >> 24) & 0x0000000000FF0000) | \ 40 (((x) >> 8) & 0x00000000FF000000) | (((x) << 8) & 0x000000FF00000000) | (((x) << 24) & 0x0000FF0000000000) | \ 41 (((x) << 40) & 0x00FF000000000000) | (((x) << 56) & 0xFF00000000000000)) 42 43 44 #define FILLP_HTONL(x) FILLP_NTOHL(x) 45 #define FILLP_HTONS(x) FILLP_NTOHS(x) 46 #define FILLP_HTONLL(x) FILLP_NTOHLL(x) 47 48 #else 49 #define FILLP_NTOHL(x) (x) 50 #define FILLP_NTOHS(x) (x) 51 #define FILLP_HTONL(x) (x) 52 #define FILLP_HTONS(x) (x) 53 #define FILLP_HTONLL(x) (x) 54 #define FILLP_NTOHLL(x) (x) 55 #endif 56 57 #define FILLP_ONE_SECOND 1000 58 #define FILLP_BPS_TO_KBPS 1000 59 #define FILLP_NULL_NUM 0x0 60 61 #if defined(FILLP_LINUX) 62 #define FILLP_THREAD pthread_t 63 #ifndef unlikely 64 #define unlikely(x) __builtin_expect((x), 0) 65 #endif 66 #elif defined(FILLP_WIN32) 67 #define FILLP_THREAD unsigned int 68 #define unlikely(x) (x) 69 #else 70 #error "define systhread type and unlikely !!!" 71 #endif 72 73 typedef struct FillpLmGlobalStruct { 74 FILLP_ULLONG logModules; /* Modules for which logs needs to enabled */ 75 FILLP_UINT8 debugLevel; /* dbg level : FillpDebugLevel */ 76 FILLP_UINT8 funcTrace; /* Open(1) and Close(0) function trc flag */ 77 FILLP_BOOL mgtMsgLog; /* Enable/Disable the management message log */ 78 #ifdef FILLP_64BIT_ALIGN 79 FILLP_UINT8 padd; 80 #endif 81 FillpLmCallbackFunc lmCallbackFn; 82 } FillpLmGlobal; 83 84 extern FillpSysLibBasicCallbackFuncSt g_fillpOsBasicLibFun; 85 extern FillpSysLibSemCallbackFuncSt g_fillpOsSemLibFun; 86 extern FillpSysLibSockCallbackFuncSt g_fillpOsSocketLibFun; 87 extern FillpAppCallbackFunc g_fillpAppCbkFun; 88 extern FillpLmGlobal g_fillpLmGlobal; 89 90 #ifdef __cplusplus 91 } 92 #endif 93 94 #endif /* FILLP_OS_H */ 95