Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_TYPES_H
3#define _LINUX_TYPES_H
4
5#define __EXPORTED_HEADERS__
6#include <uapi/linux/types.h>
7
8#ifndef __ASSEMBLY__
9
10#define DECLARE_BITMAP(name,bits) \
11 unsigned long name[BITS_TO_LONGS(bits)]
12
13#ifdef __SIZEOF_INT128__
14typedef __s128 s128;
15typedef __u128 u128;
16#endif
17
18typedef u32 __kernel_dev_t;
19
20typedef __kernel_fd_set fd_set;
21typedef __kernel_dev_t dev_t;
22typedef __kernel_ulong_t ino_t;
23typedef __kernel_mode_t mode_t;
24typedef unsigned short umode_t;
25typedef u32 nlink_t;
26typedef __kernel_off_t off_t;
27typedef __kernel_pid_t pid_t;
28typedef __kernel_daddr_t daddr_t;
29typedef __kernel_key_t key_t;
30typedef __kernel_suseconds_t suseconds_t;
31typedef __kernel_timer_t timer_t;
32typedef __kernel_clockid_t clockid_t;
33typedef __kernel_mqd_t mqd_t;
34
35typedef _Bool bool;
36
37typedef __kernel_uid32_t uid_t;
38typedef __kernel_gid32_t gid_t;
39typedef __kernel_uid16_t uid16_t;
40typedef __kernel_gid16_t gid16_t;
41
42typedef unsigned long uintptr_t;
43typedef long intptr_t;
44
45#ifdef CONFIG_HAVE_UID16
46/* This is defined by arch/{arch}/include/asm/posix_types.h */
47typedef __kernel_old_uid_t old_uid_t;
48typedef __kernel_old_gid_t old_gid_t;
49#endif /* CONFIG_UID16 */
50
51#if defined(__GNUC__)
52typedef __kernel_loff_t loff_t;
53typedef __kernel_uoff_t uoff_t;
54#endif
55
56/*
57 * The following typedefs are also protected by individual ifdefs for
58 * historical reasons:
59 */
60#ifndef _SIZE_T
61#define _SIZE_T
62typedef __kernel_size_t size_t;
63#endif
64
65#ifndef _SSIZE_T
66#define _SSIZE_T
67typedef __kernel_ssize_t ssize_t;
68#endif
69
70#ifndef _PTRDIFF_T
71#define _PTRDIFF_T
72typedef __kernel_ptrdiff_t ptrdiff_t;
73#endif
74
75#ifndef _CLOCK_T
76#define _CLOCK_T
77typedef __kernel_clock_t clock_t;
78#endif
79
80#ifndef _CADDR_T
81#define _CADDR_T
82typedef __kernel_caddr_t caddr_t;
83#endif
84
85/* bsd */
86typedef unsigned char u_char;
87typedef unsigned short u_short;
88typedef unsigned int u_int;
89typedef unsigned long u_long;
90
91/* sysv */
92typedef unsigned char unchar;
93typedef unsigned short ushort;
94typedef unsigned int uint;
95typedef unsigned long ulong;
96typedef unsigned long long ullong;
97
98#ifndef __BIT_TYPES_DEFINED__
99#define __BIT_TYPES_DEFINED__
100
101typedef u8 u_int8_t;
102typedef s8 int8_t;
103typedef u16 u_int16_t;
104typedef s16 int16_t;
105typedef u32 u_int32_t;
106typedef s32 int32_t;
107
108#endif /* !(__BIT_TYPES_DEFINED__) */
109
110typedef u8 uint8_t;
111typedef u16 uint16_t;
112typedef u32 uint32_t;
113
114#if defined(__GNUC__)
115typedef u64 uint64_t;
116typedef u64 u_int64_t;
117typedef s64 int64_t;
118#endif
119
120/* These are the special 64-bit data types that are 8-byte aligned */
121#define aligned_u64 __aligned_u64
122#define aligned_s64 __aligned_s64
123#define aligned_be64 __aligned_be64
124#define aligned_le64 __aligned_le64
125
126/* Nanosecond scalar representation for kernel time values */
127typedef s64 ktime_t;
128
129/**
130 * The type used for indexing onto a disc or disc partition.
131 *
132 * Linux always considers sectors to be 512 bytes long independently
133 * of the devices real block size.
134 *
135 * blkcnt_t is the type of the inode's block count.
136 */
137typedef u64 sector_t;
138typedef u64 blkcnt_t;
139
140/* generic data direction definitions */
141#define READ 0
142#define WRITE 1
143
144/*
145 * The type of an index into the pagecache.
146 */
147#define pgoff_t unsigned long
148
149/*
150 * A dma_addr_t can hold any valid DMA address, i.e., any address returned
151 * by the DMA API.
152 *
153 * If the DMA API only uses 32-bit addresses, dma_addr_t need only be 32
154 * bits wide. Bus addresses, e.g., PCI BARs, may be wider than 32 bits,
155 * but drivers do memory-mapped I/O to ioremapped kernel virtual addresses,
156 * so they don't care about the size of the actual bus addresses.
157 */
158#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
159typedef u64 dma_addr_t;
160#else
161typedef u32 dma_addr_t;
162#endif
163
164typedef unsigned int __bitwise gfp_t;
165typedef unsigned int __bitwise slab_flags_t;
166typedef unsigned int __bitwise fmode_t;
167
168#ifdef CONFIG_PHYS_ADDR_T_64BIT
169typedef u64 phys_addr_t;
170#else
171typedef u32 phys_addr_t;
172#endif
173
174typedef phys_addr_t resource_size_t;
175
176/*
177 * This type is the placeholder for a hardware interrupt number. It has to be
178 * big enough to enclose whatever representation is used by a given platform.
179 */
180typedef unsigned long irq_hw_number_t;
181
182typedef struct {
183 int counter;
184} atomic_t;
185
186#define ATOMIC_INIT(i) { (i) }
187
188#ifdef CONFIG_64BIT
189typedef struct {
190 s64 counter;
191} atomic64_t;
192#endif
193
194typedef struct {
195 atomic_t refcnt;
196} rcuref_t;
197
198#define RCUREF_INIT(i) { .refcnt = ATOMIC_INIT(i - 1) }
199
200struct list_head {
201 struct list_head *next, *prev;
202};
203
204struct hlist_head {
205 struct hlist_node *first;
206};
207
208struct hlist_node {
209 struct hlist_node *next, **pprev;
210};
211
212struct ustat {
213 __kernel_daddr_t f_tfree;
214#ifdef CONFIG_ARCH_32BIT_USTAT_F_TINODE
215 unsigned int f_tinode;
216#else
217 unsigned long f_tinode;
218#endif
219 char f_fname[6];
220 char f_fpack[6];
221};
222
223/**
224 * struct callback_head - callback structure for use with RCU and task_work
225 * @next: next update requests in a list
226 * @func: actual update function to call after the grace period.
227 *
228 * The struct is aligned to size of pointer. On most architectures it happens
229 * naturally due ABI requirements, but some architectures (like CRIS) have
230 * weird ABI and we need to ask it explicitly.
231 *
232 * The alignment is required to guarantee that bit 0 of @next will be
233 * clear under normal conditions -- as long as we use call_rcu() or
234 * call_srcu() to queue the callback.
235 *
236 * This guarantee is important for few reasons:
237 * - future call_rcu_lazy() will make use of lower bits in the pointer;
238 * - the structure shares storage space in struct page with @compound_head,
239 * which encode PageTail() in bit 0. The guarantee is needed to avoid
240 * false-positive PageTail().
241 */
242struct callback_head {
243 struct callback_head *next;
244 void (*func)(struct callback_head *head);
245} __attribute__((aligned(sizeof(void *))));
246#define rcu_head callback_head
247
248typedef void (*rcu_callback_t)(struct rcu_head *head);
249typedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
250
251typedef void (*swap_r_func_t)(void *a, void *b, int size, const void *priv);
252typedef void (*swap_func_t)(void *a, void *b, int size);
253
254typedef int (*cmp_r_func_t)(const void *a, const void *b, const void *priv);
255typedef int (*cmp_func_t)(const void *a, const void *b);
256
257/*
258 * rcuwait provides a way of blocking and waking up a single
259 * task in an rcu-safe manner.
260 *
261 * The only time @task is non-nil is when a user is blocked (or
262 * checking if it needs to) on a condition, and reset as soon as we
263 * know that the condition has succeeded and are awoken.
264 */
265struct rcuwait {
266 struct task_struct __rcu *task;
267};
268
269#endif /* __ASSEMBLY__ */
270#endif /* _LINUX_TYPES_H */