1 /* 2 * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved. 3 * 4 * UniProton is licensed under Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * http://license.coscl.org.cn/MulanPSL2 8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 * See the Mulan PSL v2 for more details. 12 * Create: 2009-12-22 13 * Description: 定义基本数据类型和数据结构。 14 */ 15 #ifndef PRT_TYPEDEF_H 16 #define PRT_TYPEDEF_H 17 18 #include <stdint.h> 19 #include <stdbool.h> 20 21 #ifdef __cplusplus 22 #if __cplusplus 23 extern "C" { 24 #endif /* __cpluscplus */ 25 #endif /* __cpluscplus */ 26 27 typedef unsigned char U8; 28 typedef unsigned short U16; 29 typedef unsigned int U32; 30 typedef unsigned long long U64; 31 typedef signed char S8; 32 typedef signed short S16; 33 typedef signed int S32; 34 typedef signed long long S64; 35 36 #ifndef OS_SEC_ALW_INLINE 37 #define OS_SEC_ALW_INLINE 38 #endif 39 40 #ifndef INLINE 41 #define INLINE static __inline __attribute__((always_inline)) 42 #endif 43 44 #ifndef OS_EMBED_ASM 45 #define OS_EMBED_ASM __asm__ __volatile__ 46 #endif 47 48 /* 参数不加void表示可以传任意个参数 */ 49 typedef void (*OsVoidFunc)(void); 50 51 #define ALIGN(addr, boundary) (((uintptr_t)(addr) + (boundary) - 1) & ~((uintptr_t)(boundary) - 1)) 52 #define TRUNCATE(addr, size) ((addr) & ~((uintptr_t)(size) - 1)) 53 54 #ifdef YES 55 #undef YES 56 #endif 57 #define YES 1 58 59 #ifdef NO 60 #undef NO 61 #endif 62 #define NO 0 63 64 #ifndef FALSE 65 #define FALSE ((bool)0) 66 #endif 67 68 #ifndef TRUE 69 #define TRUE ((bool)1) 70 #endif 71 72 #ifndef NULL 73 #define NULL ((void *)0) 74 #endif 75 76 #define OS_ERROR (U32)(-1) 77 #define OS_INVALID (-1) 78 79 #ifndef OS_OK 80 #define OS_OK 0 81 #endif 82 83 #ifndef LIKELY 84 #define LIKELY(x) __builtin_expect(!!(x), 1) 85 #endif 86 87 #ifndef UNLIKELY 88 #define UNLIKELY(x) __builtin_expect(!!(x), 0) 89 #endif 90 91 #ifdef __cplusplus 92 #if __cplusplus 93 } 94 #endif /* __cpluscplus */ 95 #endif /* __cpluscplus */ 96 97 #endif /* PRT_TYPEDEF_H */ 98