1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds#ifndef _LINUX_TYPES_H
31da177e4SLinus Torvalds#define _LINUX_TYPES_H
41da177e4SLinus Torvalds
5607ca46eSDavid Howells#define __EXPORTED_HEADERS__
6607ca46eSDavid Howells#include <uapi/linux/types.h>
79d50638bSJaswinder Singh Rajput
8527bdfeeSJaswinder Singh Rajput#ifndef __ASSEMBLY__
91da177e4SLinus Torvalds
101da177e4SLinus Torvalds#define DECLARE_BITMAP(name,bits) \
111da177e4SLinus Torvalds	unsigned long name[BITS_TO_LONGS(bits)]
121da177e4SLinus Torvalds
13b22f22a3SMasahiro Yamadatypedef u32 __kernel_dev_t;
141da177e4SLinus Torvalds
151da177e4SLinus Torvaldstypedef __kernel_fd_set		fd_set;
161da177e4SLinus Torvaldstypedef __kernel_dev_t		dev_t;
1796c0a6a7SHeiko Carstenstypedef __kernel_ulong_t	ino_t;
181da177e4SLinus Torvaldstypedef __kernel_mode_t		mode_t;
190583fcc9SAl Virotypedef unsigned short		umode_t;
20b22f22a3SMasahiro Yamadatypedef u32			nlink_t;
211da177e4SLinus Torvaldstypedef __kernel_off_t		off_t;
221da177e4SLinus Torvaldstypedef __kernel_pid_t		pid_t;
231da177e4SLinus Torvaldstypedef __kernel_daddr_t	daddr_t;
241da177e4SLinus Torvaldstypedef __kernel_key_t		key_t;
251da177e4SLinus Torvaldstypedef __kernel_suseconds_t	suseconds_t;
261da177e4SLinus Torvaldstypedef __kernel_timer_t	timer_t;
271da177e4SLinus Torvaldstypedef __kernel_clockid_t	clockid_t;
281da177e4SLinus Torvaldstypedef __kernel_mqd_t		mqd_t;
291da177e4SLinus Torvalds
306e218287SRichard Knutssontypedef _Bool			bool;
316e218287SRichard Knutsson
321da177e4SLinus Torvaldstypedef __kernel_uid32_t	uid_t;
331da177e4SLinus Torvaldstypedef __kernel_gid32_t	gid_t;
341da177e4SLinus Torvaldstypedef __kernel_uid16_t        uid16_t;
351da177e4SLinus Torvaldstypedef __kernel_gid16_t        gid16_t;
361da177e4SLinus Torvalds
37142956afSAl Virotypedef unsigned long		uintptr_t;
38142956afSAl Viro
39fbc416ffSArnd Bergmann#ifdef CONFIG_HAVE_UID16
401da177e4SLinus Torvalds/* This is defined by include/asm-{arch}/posix_types.h */
411da177e4SLinus Torvaldstypedef __kernel_old_uid_t	old_uid_t;
421da177e4SLinus Torvaldstypedef __kernel_old_gid_t	old_gid_t;
431da177e4SLinus Torvalds#endif /* CONFIG_UID16 */
441da177e4SLinus Torvalds
457437a51bSMike Frysinger#if defined(__GNUC__)
461da177e4SLinus Torvaldstypedef __kernel_loff_t		loff_t;
471da177e4SLinus Torvalds#endif
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds/*
501da177e4SLinus Torvalds * The following typedefs are also protected by individual ifdefs for
511da177e4SLinus Torvalds * historical reasons:
521da177e4SLinus Torvalds */
531da177e4SLinus Torvalds#ifndef _SIZE_T
541da177e4SLinus Torvalds#define _SIZE_T
551da177e4SLinus Torvaldstypedef __kernel_size_t		size_t;
561da177e4SLinus Torvalds#endif
571da177e4SLinus Torvalds
581da177e4SLinus Torvalds#ifndef _SSIZE_T
591da177e4SLinus Torvalds#define _SSIZE_T
601da177e4SLinus Torvaldstypedef __kernel_ssize_t	ssize_t;
611da177e4SLinus Torvalds#endif
621da177e4SLinus Torvalds
631da177e4SLinus Torvalds#ifndef _PTRDIFF_T
641da177e4SLinus Torvalds#define _PTRDIFF_T
651da177e4SLinus Torvaldstypedef __kernel_ptrdiff_t	ptrdiff_t;
661da177e4SLinus Torvalds#endif
671da177e4SLinus Torvalds
681da177e4SLinus Torvalds#ifndef _CLOCK_T
691da177e4SLinus Torvalds#define _CLOCK_T
701da177e4SLinus Torvaldstypedef __kernel_clock_t	clock_t;
711da177e4SLinus Torvalds#endif
721da177e4SLinus Torvalds
731da177e4SLinus Torvalds#ifndef _CADDR_T
741da177e4SLinus Torvalds#define _CADDR_T
751da177e4SLinus Torvaldstypedef __kernel_caddr_t	caddr_t;
761da177e4SLinus Torvalds#endif
771da177e4SLinus Torvalds
781da177e4SLinus Torvalds/* bsd */
791da177e4SLinus Torvaldstypedef unsigned char		u_char;
801da177e4SLinus Torvaldstypedef unsigned short		u_short;
811da177e4SLinus Torvaldstypedef unsigned int		u_int;
821da177e4SLinus Torvaldstypedef unsigned long		u_long;
831da177e4SLinus Torvalds
841da177e4SLinus Torvalds/* sysv */
851da177e4SLinus Torvaldstypedef unsigned char		unchar;
861da177e4SLinus Torvaldstypedef unsigned short		ushort;
871da177e4SLinus Torvaldstypedef unsigned int		uint;
881da177e4SLinus Torvaldstypedef unsigned long		ulong;
891da177e4SLinus Torvalds
901da177e4SLinus Torvalds#ifndef __BIT_TYPES_DEFINED__
911da177e4SLinus Torvalds#define __BIT_TYPES_DEFINED__
921da177e4SLinus Torvalds
93b22f22a3SMasahiro Yamadatypedef u8			u_int8_t;
94b22f22a3SMasahiro Yamadatypedef s8			int8_t;
95b22f22a3SMasahiro Yamadatypedef u16			u_int16_t;
96b22f22a3SMasahiro Yamadatypedef s16			int16_t;
97b22f22a3SMasahiro Yamadatypedef u32			u_int32_t;
98b22f22a3SMasahiro Yamadatypedef s32			int32_t;
991da177e4SLinus Torvalds
1001da177e4SLinus Torvalds#endif /* !(__BIT_TYPES_DEFINED__) */
1011da177e4SLinus Torvalds
102b22f22a3SMasahiro Yamadatypedef u8			uint8_t;
103b22f22a3SMasahiro Yamadatypedef u16			uint16_t;
104b22f22a3SMasahiro Yamadatypedef u32			uint32_t;
1051da177e4SLinus Torvalds
1067437a51bSMike Frysinger#if defined(__GNUC__)
107b22f22a3SMasahiro Yamadatypedef u64			uint64_t;
108b22f22a3SMasahiro Yamadatypedef u64			u_int64_t;
109b22f22a3SMasahiro Yamadatypedef s64			int64_t;
1101da177e4SLinus Torvalds#endif
1111da177e4SLinus Torvalds
112a75d3776SAndrew Morton/* this is a special 64bit data type that is 8-byte aligned */
1136d0e8d53SMasahiro Yamada#define aligned_u64		__aligned_u64
1146d0e8d53SMasahiro Yamada#define aligned_be64		__aligned_be64
1156d0e8d53SMasahiro Yamada#define aligned_le64		__aligned_le64
1160ba2c6e8SHarald Welte
1172c2345c2SRoger Gammans/**
1181da177e4SLinus Torvalds * The type used for indexing onto a disc or disc partition.
1192c2345c2SRoger Gammans *
1202c2345c2SRoger Gammans * Linux always considers sectors to be 512 bytes long independently
1212c2345c2SRoger Gammans * of the devices real block size.
122b3a6ffe1SJens Axboe *
123b3a6ffe1SJens Axboe * blkcnt_t is the type of the inode's block count.
1241da177e4SLinus Torvalds */
125e6243863SMatthew Wilcoxtypedef u64 sector_t;
126e6243863SMatthew Wilcoxtypedef u64 blkcnt_t;
127a0f62ac6STakashi Sato
1281da177e4SLinus Torvalds/*
129dd4a5c1eSGeert Uytterhoeven * The type of an index into the pagecache.
1301da177e4SLinus Torvalds */
1311da177e4SLinus Torvalds#define pgoff_t unsigned long
1321da177e4SLinus Torvalds
1333a9ad0b4SYinghai Lu/*
1343a9ad0b4SYinghai Lu * A dma_addr_t can hold any valid DMA address, i.e., any address returned
1353a9ad0b4SYinghai Lu * by the DMA API.
1363a9ad0b4SYinghai Lu *
1373a9ad0b4SYinghai Lu * If the DMA API only uses 32-bit addresses, dma_addr_t need only be 32
1383a9ad0b4SYinghai Lu * bits wide.  Bus addresses, e.g., PCI BARs, may be wider than 32 bits,
1393a9ad0b4SYinghai Lu * but drivers do memory-mapped I/O to ioremapped kernel virtual addresses,
1403a9ad0b4SYinghai Lu * so they don't care about the size of the actual bus addresses.
1413a9ad0b4SYinghai Lu */
1423e50594eSFUJITA Tomonori#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
1433e50594eSFUJITA Tomonoritypedef u64 dma_addr_t;
1443e50594eSFUJITA Tomonori#else
1453e50594eSFUJITA Tomonoritypedef u32 dma_addr_t;
1463a9ad0b4SYinghai Lu#endif
1473e50594eSFUJITA Tomonori
14830ff9ec4SWangBotypedef unsigned int __bitwise gfp_t;
14930ff9ec4SWangBotypedef unsigned int __bitwise slab_flags_t;
15030ff9ec4SWangBotypedef unsigned int __bitwise fmode_t;
151cf7c712cSGreg Kroah-Hartman
152600715dcSJeremy Fitzhardinge#ifdef CONFIG_PHYS_ADDR_T_64BIT
153600715dcSJeremy Fitzhardingetypedef u64 phys_addr_t;
154600715dcSJeremy Fitzhardinge#else
155600715dcSJeremy Fitzhardingetypedef u32 phys_addr_t;
156600715dcSJeremy Fitzhardinge#endif
157600715dcSJeremy Fitzhardinge
1588308c54dSJeremy Fitzhardingetypedef phys_addr_t resource_size_t;
1598308c54dSJeremy Fitzhardinge
160a699e4e4SGrant Likely/*
161a699e4e4SGrant Likely * This type is the placeholder for a hardware interrupt number. It has to be
162a699e4e4SGrant Likely * big enough to enclose whatever representation is used by a given platform.
163a699e4e4SGrant Likely */
164a699e4e4SGrant Likelytypedef unsigned long irq_hw_number_t;
165a699e4e4SGrant Likely
166ea435467SMatthew Wilcoxtypedef struct {
16781880d60SAnton Blanchard	int counter;
168ea435467SMatthew Wilcox} atomic_t;
169ea435467SMatthew Wilcox
1707ca8cf53SHerbert Xu#define ATOMIC_INIT(i) { (i) }
1717ca8cf53SHerbert Xu
172ea435467SMatthew Wilcox#ifdef CONFIG_64BIT
173ea435467SMatthew Wilcoxtypedef struct {
17437249213SMark Rutland	s64 counter;
175ea435467SMatthew Wilcox} atomic64_t;
176ea435467SMatthew Wilcox#endif
177ea435467SMatthew Wilcox
178de5d9bf6SChris Metcalfstruct list_head {
179de5d9bf6SChris Metcalf	struct list_head *next, *prev;
180de5d9bf6SChris Metcalf};
181de5d9bf6SChris Metcalf
182de5d9bf6SChris Metcalfstruct hlist_head {
183de5d9bf6SChris Metcalf	struct hlist_node *first;
184de5d9bf6SChris Metcalf};
185de5d9bf6SChris Metcalf
186de5d9bf6SChris Metcalfstruct hlist_node {
187de5d9bf6SChris Metcalf	struct hlist_node *next, **pprev;
188de5d9bf6SChris Metcalf};
189de5d9bf6SChris Metcalf
1901da177e4SLinus Torvaldsstruct ustat {
1911da177e4SLinus Torvalds	__kernel_daddr_t	f_tfree;
19296c0a6a7SHeiko Carstens#ifdef CONFIG_ARCH_32BIT_USTAT_F_TINODE
19396c0a6a7SHeiko Carstens	unsigned int		f_tinode;
19496c0a6a7SHeiko Carstens#else
19596c0a6a7SHeiko Carstens	unsigned long		f_tinode;
19696c0a6a7SHeiko Carstens#endif
1971da177e4SLinus Torvalds	char			f_fname[6];
1981da177e4SLinus Torvalds	char			f_fpack[6];
1991da177e4SLinus Torvalds};
2001da177e4SLinus Torvalds
20199098751SPaul E. McKenney/**
20267d12145SAl Viro * struct callback_head - callback structure for use with RCU and task_work
20399098751SPaul E. McKenney * @next: next update requests in a list
20499098751SPaul E. McKenney * @func: actual update function to call after the grace period.
205720abae3SKirill A. Shutemov *
206720abae3SKirill A. Shutemov * The struct is aligned to size of pointer. On most architectures it happens
207720abae3SKirill A. Shutemov * naturally due ABI requirements, but some architectures (like CRIS) have
208720abae3SKirill A. Shutemov * weird ABI and we need to ask it explicitly.
209720abae3SKirill A. Shutemov *
210468d01beSPaul E. McKenney * The alignment is required to guarantee that bit 0 of @next will be
211d5cccfc7SPaul E. McKenney * clear under normal conditions -- as long as we use call_rcu() or
212d5cccfc7SPaul E. McKenney * call_srcu() to queue the callback.
213720abae3SKirill A. Shutemov *
214720abae3SKirill A. Shutemov * This guarantee is important for few reasons:
215720abae3SKirill A. Shutemov *  - future call_rcu_lazy() will make use of lower bits in the pointer;
21630a050deSLihao Liang *  - the structure shares storage space in struct page with @compound_head,
217720abae3SKirill A. Shutemov *    which encode PageTail() in bit 0. The guarantee is needed to avoid
218720abae3SKirill A. Shutemov *    false-positive PageTail().
21999098751SPaul E. McKenney */
22067d12145SAl Virostruct callback_head {
22167d12145SAl Viro	struct callback_head *next;
22267d12145SAl Viro	void (*func)(struct callback_head *head);
223720abae3SKirill A. Shutemov} __attribute__((aligned(sizeof(void *))));
22467d12145SAl Viro#define rcu_head callback_head
22599098751SPaul E. McKenney
226ec90a194SPaul E. McKenneytypedef void (*rcu_callback_t)(struct rcu_head *head);
227ec90a194SPaul E. McKenneytypedef void (*call_rcu_func_t)(struct rcu_head *head, rcu_callback_t func);
228ec90a194SPaul E. McKenney
22952ae533bSAndy Shevchenkotypedef void (*swap_func_t)(void *a, void *b, int size);
23052ae533bSAndy Shevchenko
23152ae533bSAndy Shevchenkotypedef int (*cmp_r_func_t)(const void *a, const void *b, const void *priv);
23252ae533bSAndy Shevchenkotypedef int (*cmp_func_t)(const void *a, const void *b);
23352ae533bSAndy Shevchenko
234527bdfeeSJaswinder Singh Rajput#endif /*  __ASSEMBLY__ */
2351da177e4SLinus Torvalds#endif /* _LINUX_TYPES_H */