• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 #pragma once
14 
15 #include <stddef.h>
16 #include <stdint.h>
17 #include <stdbool.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef uint64_t u64;
24 typedef uint32_t u32;
25 typedef uint16_t u16;
26 typedef uint8_t u8;
27 
28 typedef int64_t s64;
29 typedef int32_t s32;
30 typedef int16_t s16;
31 typedef int8_t s8;
32 
33 #if __SIZEOF_POINTER__ == 4
34 typedef uint32_t paddr_t;
35 typedef uint32_t vaddr_t;
36 #else
37 typedef uint64_t paddr_t;
38 typedef uint64_t vaddr_t;
39 #endif
40 
41 typedef int cap_t;
42 typedef int badge_t;
43 
44 #define ADDR_LOWER32(addr) ((addr)&0xffffffff)
45 #define ADDR_UPPER32(addr) ADDR_LOWER32((addr) >> 32)
46 
47 /* We only consider ET_EXEC and ET_DYN now */
48 #define ET_NONE 0
49 #define ET_REL  1
50 #define ET_EXEC 2
51 #define ET_DYN  3
52 #define ET_CORE 4
53 
54 #define CHCORE_LOADER "/libc_shared.so"
55 #define LDD_NAME \
56     "/ldd" /* ldd is actually a copy of libc.so but with different name */
57 
58 #define likely(x)   __builtin_expect(!!(x), 1)
59 #define unlikely(x) __builtin_expect(!!(x), 0)
60 
61 #ifdef __cplusplus
62 }
63 #endif
64