[PATCH 1/2] uapi: introduce __kernel_uapi_size_t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



__kernel_uapi_size_t is a pure UAPI type, in defined(__KERNEL__) code
it's always the same as __kernel_size_t.

It's also the same as __kernel_size_t on all architectures except x32
where sizeof(size_t) < sizeof(__kernel_size_t).

__kernel_uapi_size_t can be used as a size_t replacement in UAPI
headers, e.g. in cases when size_t might differ from __kernel_size_t.

Signed-off-by: Dmitry V. Levin <ldv@xxxxxxxxxxxx>
---
 include/uapi/asm-generic/posix_types.h      | 10 ++++++++++
 arch/x86/include/uapi/asm/posix_types_x32.h |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/include/uapi/asm-generic/posix_types.h b/include/uapi/asm-generic/posix_types.h
index fe74fcc..e93c324 100644
--- a/include/uapi/asm-generic/posix_types.h
+++ b/include/uapi/asm-generic/posix_types.h
@@ -74,6 +74,16 @@ typedef __kernel_long_t	__kernel_ptrdiff_t;
 #endif
 #endif
 
+/*
+ * __kernel_uapi_size_t is a pure UAPI type, in defined(__KERNEL__) code
+ * it's always the same as __kernel_size_t.
+ * __kernel_uapi_size_t can be used as a size_t replacement in UAPI headers,
+ * e.g. in cases when size_t might differ from __kernel_size_t.
+ */
+#ifndef __kernel_uapi_size_t
+typedef __kernel_size_t __kernel_uapi_size_t;
+#endif
+
 #ifndef __kernel_fsid_t
 typedef struct {
 	int	val[2];
diff --git a/arch/x86/include/uapi/asm/posix_types_x32.h b/arch/x86/include/uapi/asm/posix_types_x32.h
index 85f9bda..0e36e67 100644
--- a/arch/x86/include/uapi/asm/posix_types_x32.h
+++ b/arch/x86/include/uapi/asm/posix_types_x32.h
@@ -14,6 +14,9 @@ typedef long long __kernel_long_t;
 typedef unsigned long long __kernel_ulong_t;
 #define __kernel_long_t __kernel_long_t
 
+typedef unsigned int __kernel_uapi_size_t;
+#define __kernel_uapi_size_t __kernel_uapi_size_t
+
 #include <asm/posix_types_64.h>
 
 #endif /* _ASM_X86_POSIX_TYPES_X32_H */
-- 
ldv



[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux