1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _TOOLS_LINUX_TYPES_H_ 3 #define _TOOLS_LINUX_TYPES_H_ 4 5 #include <stdbool.h> 6 #include <stddef.h> 7 #include <stdint.h> 8 9 #ifndef __SANE_USERSPACE_TYPES__ 10 #define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */ 11 #endif 12 13 #include <asm/types.h> 14 #include <asm/posix_types.h> 15 16 struct page; 17 struct kmem_cache; 18 19 typedef enum { 20 GFP_KERNEL, 21 GFP_ATOMIC, 22 __GFP_HIGHMEM, 23 __GFP_HIGH 24 } gfp_t; 25 26 #ifdef __SIZEOF_INT128__ 27 typedef __signed__ __int128 __s128 __attribute__((aligned(16))); 28 typedef unsigned __int128 __u128 __attribute__((aligned(16))); 29 #endif 30 31 /* 32 * We define u64 as uint64_t for every architecture 33 * so that we can print it with "%"PRIx64 without getting warnings. 34 * 35 * typedef __u64 u64; 36 * typedef __s64 s64; 37 */ 38 typedef uint64_t u64; 39 typedef int64_t s64; 40 41 typedef __u32 u32; 42 typedef __s32 s32; 43 44 typedef __u16 u16; 45 typedef __s16 s16; 46 47 typedef __u8 u8; 48 typedef __s8 s8; 49 50 typedef unsigned long long ullong; 51 52 #ifdef __CHECKER__ 53 #define __bitwise __attribute__((bitwise)) 54 #else 55 #define __bitwise 56 #endif 57 58 #define __force 59 /* This is defined in linux/compiler_types.h and is left for backward 60 * compatibility. 61 */ 62 #ifndef __user 63 #define __user 64 #endif 65 #define __must_check 66 #define __cold 67 68 typedef __u16 __bitwise __le16; 69 typedef __u16 __bitwise __be16; 70 typedef __u32 __bitwise __le32; 71 typedef __u32 __bitwise __be32; 72 typedef __u64 __bitwise __le64; 73 typedef __u64 __bitwise __be64; 74 75 typedef __u16 __bitwise __sum16; 76 typedef __u32 __bitwise __wsum; 77 78 #ifdef CONFIG_PHYS_ADDR_T_64BIT 79 typedef u64 phys_addr_t; 80 #else 81 typedef u32 phys_addr_t; 82 #endif 83 84 typedef struct { 85 int counter; 86 } atomic_t; 87 88 typedef struct { 89 long counter; 90 } atomic_long_t; 91 92 #ifndef __aligned_u64 93 # define __aligned_u64 __u64 __attribute__((aligned(8))) 94 #endif 95 96 #ifndef __aligned_be64 97 # define __aligned_be64 __be64 __attribute__((aligned(8))) 98 #endif 99 100 #ifndef __aligned_le64 101 # define __aligned_le64 __le64 __attribute__((aligned(8))) 102 #endif 103 104 struct list_head { 105 struct list_head *next, *prev; 106 }; 107 108 struct hlist_head { 109 struct hlist_node *first; 110 }; 111 112 struct hlist_node { 113 struct hlist_node *next, **pprev; 114 }; 115 116 #endif /* _TOOLS_LINUX_TYPES_H_ */ 117