1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 * Description: td types header. 15 * Note: This file should be changed only infrequently and with great care. 16 */ 17 #ifndef __TD_TYPE_H__ 18 #define __TD_TYPE_H__ 19 20 #ifdef __KERNEL__ 21 #include <linux/types.h> 22 #elif (defined(__LITEOS__) || defined(TD_SUPPORT_STDLIB) || defined(CONFIG_CGRA_CORE)) 23 #include <stdint.h> 24 #endif 25 26 #ifdef __cplusplus 27 #if __cplusplus 28 extern "C"{ 29 #endif 30 #endif 31 32 #ifndef NULL 33 #ifdef __cplusplus 34 #define NULL 0L 35 #else 36 #define NULL ((void*)0) 37 #endif 38 #endif 39 40 /* defines */ 41 #define TD_NULL NULL 42 #define TD_NULL_PTR TD_NULL 43 #define TD_FALSE 0 44 #define TD_TRUE 1 45 46 typedef unsigned char td_uchar; 47 typedef unsigned char td_u8; 48 typedef unsigned short td_u16; 49 typedef unsigned int td_u32; 50 typedef unsigned long long td_u64; 51 typedef unsigned long td_ulong; 52 typedef char td_char; 53 typedef signed char td_s8; 54 typedef short td_s16; 55 typedef int td_s32; 56 typedef long long td_s64; 57 typedef long td_slong; 58 typedef float td_float; 59 typedef double td_double; 60 typedef void td_void; 61 typedef td_u8 td_bool; 62 typedef td_u32 td_handle; 63 typedef td_u8 td_byte; 64 typedef td_byte* td_pbyte; 65 typedef void* td_pvoid; 66 typedef volatile td_u32 td_u32_reg; 67 typedef unsigned long td_size_t; 68 typedef signed long td_ssize_t; 69 typedef unsigned long td_length_t; 70 typedef unsigned long long td_mem_size_t; 71 typedef long long td_mem_handle_t; 72 typedef unsigned int td_fr32; // 分数,分子高16bit,分母低16bit 73 74 #if ((!defined(_LINUX_TYPES_H)) && (!defined(_STDINT_H)) && (!defined(CONFIG_CGRA_CORE)) \ 75 &&(!defined(__DEFINED_uintptr_t))) 76 typedef unsigned int uintptr_t; 77 #define __DEFINED_uintptr_t 78 #endif 79 typedef uintptr_t td_uintptr_t; 80 81 #ifdef __LP64__ 82 typedef unsigned long long td_phys_addr_t; 83 typedef unsigned long long td_virt_addr_t; 84 #else 85 typedef unsigned int td_phys_addr_t; 86 typedef unsigned int td_virt_addr_t; 87 #endif 88 typedef unsigned int td_phys_addr_bit32; 89 90 #ifdef __cplusplus 91 #if __cplusplus 92 } 93 #endif 94 #endif /* __cplusplus */ 95 96 #endif /* __TD_TYPES_H__ */ 97 98