1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef COMMON_TYPES_H 13 #define COMMON_TYPES_H 14 15 #include <common/macro.h> 16 17 typedef unsigned long long u64; 18 typedef unsigned int u32; 19 typedef unsigned short u16; 20 typedef unsigned char u8; 21 22 typedef long long s64; 23 typedef int s32; 24 typedef short s16; 25 typedef signed char s8; 26 27 #define NULL ((void *)0) 28 29 typedef char bool; 30 #define true (1) 31 #define false (0) 32 33 #if __SIZEOF_POINTER__ == 4 34 typedef u32 paddr_t; 35 typedef u32 vaddr_t; 36 typedef u32 atomic_cnt; 37 #else 38 typedef u64 paddr_t; 39 typedef u64 vaddr_t; 40 typedef u64 atomic_cnt; 41 #endif 42 43 typedef int cap_t; 44 typedef int badge_t; 45 46 #ifdef CHCORE 47 #if __SIZEOF_POINTER__ == 4 48 typedef u32 clockid_t; 49 typedef u32 size_t; 50 typedef u32 time_t; 51 #else 52 typedef u64 clockid_t; 53 typedef u64 size_t; 54 typedef u64 time_t; 55 #endif 56 57 /** musl off_t is always 64-bit on any architectures */ 58 typedef s64 off_t; 59 60 struct timespec { 61 time_t tv_sec; /* Seconds. */ 62 time_t tv_nsec; /* Nanoseconds. */ 63 }; 64 #else 65 #include <sys/types.h> 66 #endif 67 68 #endif /* COMMON_TYPES_H */