xref: /linux/include/uapi/linux/types.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells #ifndef _UAPI_LINUX_TYPES_H
3607ca46eSDavid Howells #define _UAPI_LINUX_TYPES_H
4607ca46eSDavid Howells 
5607ca46eSDavid Howells #include <asm/types.h>
6607ca46eSDavid Howells 
7607ca46eSDavid Howells #ifndef __ASSEMBLY__
8607ca46eSDavid Howells #ifndef	__KERNEL__
9607ca46eSDavid Howells #ifndef __EXPORTED_HEADERS__
107f317d34SAlexander A. Klimov #warning "Attempt to use kernel headers from user space, see https://kernelnewbies.org/KernelHeaders"
11607ca46eSDavid Howells #endif /* __EXPORTED_HEADERS__ */
12607ca46eSDavid Howells #endif
13607ca46eSDavid Howells 
14607ca46eSDavid Howells #include <linux/posix_types.h>
15607ca46eSDavid Howells 
16*224d80c5SPeter Zijlstra #ifdef __SIZEOF_INT128__
17*224d80c5SPeter Zijlstra typedef __signed__ __int128 __s128 __attribute__((aligned(16)));
18*224d80c5SPeter Zijlstra typedef unsigned __int128 __u128 __attribute__((aligned(16)));
19*224d80c5SPeter Zijlstra #endif
20607ca46eSDavid Howells 
21607ca46eSDavid Howells /*
22607ca46eSDavid Howells  * Below are truly Linux-specific types that should never collide with
23607ca46eSDavid Howells  * any application/library that wants linux/types.h.
24607ca46eSDavid Howells  */
25607ca46eSDavid Howells 
26179fd6baSBjorn Helgaas /* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
27607ca46eSDavid Howells #ifdef __CHECKER__
28c724c866SBjorn Helgaas #define __bitwise	__attribute__((bitwise))
29607ca46eSDavid Howells #else
30c724c866SBjorn Helgaas #define __bitwise
31607ca46eSDavid Howells #endif
32607ca46eSDavid Howells 
33caa28984SLinus Torvalds /* The kernel doesn't use this legacy form, but user space does */
34caa28984SLinus Torvalds #define __bitwise__ __bitwise
35caa28984SLinus Torvalds 
36607ca46eSDavid Howells typedef __u16 __bitwise __le16;
37607ca46eSDavid Howells typedef __u16 __bitwise __be16;
38607ca46eSDavid Howells typedef __u32 __bitwise __le32;
39607ca46eSDavid Howells typedef __u32 __bitwise __be32;
40607ca46eSDavid Howells typedef __u64 __bitwise __le64;
41607ca46eSDavid Howells typedef __u64 __bitwise __be64;
42607ca46eSDavid Howells 
43607ca46eSDavid Howells typedef __u16 __bitwise __sum16;
44607ca46eSDavid Howells typedef __u32 __bitwise __wsum;
45607ca46eSDavid Howells 
46607ca46eSDavid Howells /*
47607ca46eSDavid Howells  * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
48607ca46eSDavid Howells  * common 32/64-bit compat problems.
49607ca46eSDavid Howells  * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
50607ca46eSDavid Howells  * architectures) and to 8-byte boundaries on 64-bit architectures.  The new
51607ca46eSDavid Howells  * aligned_64 type enforces 8-byte alignment so that structs containing
52607ca46eSDavid Howells  * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
53607ca46eSDavid Howells  * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
54607ca46eSDavid Howells  */
55607ca46eSDavid Howells #define __aligned_u64 __u64 __attribute__((aligned(8)))
56607ca46eSDavid Howells #define __aligned_be64 __be64 __attribute__((aligned(8)))
57607ca46eSDavid Howells #define __aligned_le64 __le64 __attribute__((aligned(8)))
58607ca46eSDavid Howells 
598ced390cSAl Viro typedef unsigned __bitwise __poll_t;
608ced390cSAl Viro 
61607ca46eSDavid Howells #endif /*  __ASSEMBLY__ */
62607ca46eSDavid Howells #endif /* _UAPI_LINUX_TYPES_H */
63