asm-generic: Move common compat types to asm-generic/compat.h
authorArnd Bergmann <arnd@arndb.de>
Wed, 18 Apr 2018 20:01:26 +0000 (22:01 +0200)
committerArnd Bergmann <arnd@arndb.de>
Wed, 29 Aug 2018 13:42:20 +0000 (15:42 +0200)
While converting compat system call handlers to work on 32-bit
architectures, I found a number of types used in those handlers
that are identical between all architectures.

Let's move all the identical ones into asm-generic/compat.h to avoid
having to add even more identical definitions of those types.

For unknown reasons, mips defines __compat_gid32_t, __compat_uid32_t
and compat_caddr_t as signed, while all others have them unsigned.
This seems to be a mistake, but I'm leaving it alone here. The other
types all differ by size or alignment on at least on architecture.

compat_aio_context_t is currently defined in linux/compat.h but
also needed for compat_sys_io_getevents(), so let's move it into
the same place.

While we still have not decided whether the 32-bit time handling
will always use the compat syscalls, or in which form, I think this
is a useful cleanup that we can merge regardless.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
arch/arm64/include/asm/compat.h
arch/mips/include/asm/compat.h
arch/parisc/include/asm/compat.h
arch/powerpc/include/asm/compat.h
arch/s390/include/asm/compat.h
arch/sparc/include/asm/compat.h
arch/x86/include/asm/compat.h
include/asm-generic/compat.h
include/linux/compat.h

index 4a89007db14a28438756d8c6c627cb908aacfb89..ee689d8a026dd7205cb7e0ad50c72bdd0c61d3c1 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/sched.h>
 #include <linux/sched/task_stack.h>
 
+#include <asm-generic/compat.h>
+
 #define COMPAT_USER_HZ         100
 #ifdef __AARCH64EB__
 #define COMPAT_UTS_MACHINE     "armv8b\0\0"
 #define COMPAT_UTS_MACHINE     "armv8l\0\0"
 #endif
 
-typedef u32            compat_size_t;
-typedef s32            compat_ssize_t;
-typedef s32            compat_clock_t;
-typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
 typedef u16            __compat_gid_t;
 typedef u16            __compat_uid16_t;
@@ -43,27 +41,13 @@ typedef u16         __compat_gid16_t;
 typedef u32            __compat_uid32_t;
 typedef u32            __compat_gid32_t;
 typedef u16            compat_mode_t;
-typedef u32            compat_ino_t;
 typedef u32            compat_dev_t;
-typedef s32            compat_off_t;
-typedef s64            compat_loff_t;
 typedef s32            compat_nlink_t;
 typedef u16            compat_ipc_pid_t;
-typedef s32            compat_daddr_t;
 typedef u32            compat_caddr_t;
 typedef __kernel_fsid_t        compat_fsid_t;
-typedef s32            compat_key_t;
-typedef s32            compat_timer_t;
-
-typedef s16            compat_short_t;
-typedef s32            compat_int_t;
-typedef s32            compat_long_t;
 typedef s64            compat_s64;
-typedef u16            compat_ushort_t;
-typedef u32            compat_uint_t;
-typedef u32            compat_ulong_t;
 typedef u64            compat_u64;
-typedef u32            compat_uptr_t;
 
 struct compat_stat {
 #ifdef __AARCH64EB__
index 7dcbd855814ed46dfb6d24099f7ff5760ba1e29d..c99166eadbde15bb32a6086f224ba3b083acb7a7 100644 (file)
@@ -9,43 +9,25 @@
 #include <asm/page.h>
 #include <asm/ptrace.h>
 
+#include <asm-generic/compat.h>
+
 #define COMPAT_USER_HZ         100
 #define COMPAT_UTS_MACHINE     "mips\0\0\0"
 
-typedef u32            compat_size_t;
-typedef s32            compat_ssize_t;
-typedef s32            compat_clock_t;
-typedef s32            compat_suseconds_t;
-
-typedef s32            compat_pid_t;
 typedef s32            __compat_uid_t;
 typedef s32            __compat_gid_t;
 typedef __compat_uid_t __compat_uid32_t;
 typedef __compat_gid_t __compat_gid32_t;
 typedef u32            compat_mode_t;
-typedef u32            compat_ino_t;
 typedef u32            compat_dev_t;
-typedef s32            compat_off_t;
-typedef s64            compat_loff_t;
 typedef u32            compat_nlink_t;
 typedef s32            compat_ipc_pid_t;
-typedef s32            compat_daddr_t;
 typedef s32            compat_caddr_t;
 typedef struct {
        s32     val[2];
 } compat_fsid_t;
-typedef s32            compat_timer_t;
-typedef s32            compat_key_t;
-
-typedef s16            compat_short_t;
-typedef s32            compat_int_t;
-typedef s32            compat_long_t;
 typedef s64            compat_s64;
-typedef u16            compat_ushort_t;
-typedef u32            compat_uint_t;
-typedef u32            compat_ulong_t;
 typedef u64            compat_u64;
-typedef u32            compat_uptr_t;
 
 struct compat_stat {
        compat_dev_t    st_dev;
index 32dadaf2b53420704ebdcf2414617df2317c7b68..e03e3c849f40aa40bd80eb98e6f0d2e5ed136a6a 100644 (file)
@@ -8,36 +8,22 @@
 #include <linux/sched.h>
 #include <linux/thread_info.h>
 
+#include <asm-generic/compat.h>
+
 #define COMPAT_USER_HZ                 100
 #define COMPAT_UTS_MACHINE     "parisc\0\0"
 
-typedef u32    compat_size_t;
-typedef s32    compat_ssize_t;
-typedef s32    compat_clock_t;
-typedef s32    compat_pid_t;
 typedef u32    __compat_uid_t;
 typedef u32    __compat_gid_t;
 typedef u32    __compat_uid32_t;
 typedef u32    __compat_gid32_t;
 typedef u16    compat_mode_t;
-typedef u32    compat_ino_t;
 typedef u32    compat_dev_t;
-typedef s32    compat_off_t;
-typedef s64    compat_loff_t;
 typedef u16    compat_nlink_t;
 typedef u16    compat_ipc_pid_t;
-typedef s32    compat_daddr_t;
 typedef u32    compat_caddr_t;
-typedef s32    compat_key_t;
-typedef s32    compat_timer_t;
-
-typedef s32    compat_int_t;
-typedef s32    compat_long_t;
 typedef s64    compat_s64;
-typedef u32    compat_uint_t;
-typedef u32    compat_ulong_t;
 typedef u64    compat_u64;
-typedef u32    compat_uptr_t;
 
 struct compat_stat {
        compat_dev_t            st_dev; /* dev_t is 32 bits on parisc */
index 93f79d1a03c3a28c5df66e0416abed6a5fb411a6..74d0db511099c7888740131a5717fd6d7e811089 100644 (file)
@@ -8,6 +8,8 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 
+#include <asm-generic/compat.h>
+
 #define COMPAT_USER_HZ         100
 #ifdef __BIG_ENDIAN__
 #define COMPAT_UTS_MACHINE     "ppc\0\0"
 #define COMPAT_UTS_MACHINE     "ppcle\0\0"
 #endif
 
-typedef u32            compat_size_t;
-typedef s32            compat_ssize_t;
-typedef s32            compat_clock_t;
-typedef s32            compat_pid_t;
 typedef u32            __compat_uid_t;
 typedef u32            __compat_gid_t;
 typedef u32            __compat_uid32_t;
 typedef u32            __compat_gid32_t;
 typedef u32            compat_mode_t;
-typedef u32            compat_ino_t;
 typedef u32            compat_dev_t;
-typedef s32            compat_off_t;
-typedef s64            compat_loff_t;
 typedef s16            compat_nlink_t;
 typedef u16            compat_ipc_pid_t;
-typedef s32            compat_daddr_t;
 typedef u32            compat_caddr_t;
 typedef __kernel_fsid_t        compat_fsid_t;
-typedef s32            compat_key_t;
-typedef s32            compat_timer_t;
-
-typedef s32            compat_int_t;
-typedef s32            compat_long_t;
 typedef s64            compat_s64;
-typedef u32            compat_uint_t;
-typedef u32            compat_ulong_t;
 typedef u64            compat_u64;
-typedef u32            compat_uptr_t;
 
 struct compat_stat {
        compat_dev_t    st_dev;
index 97db2fba546ad2c517a25fe9dbf25f8f351bf8ea..63b46e30b2c3733c07436c6b8b7f1d30b32bdbfa 100644 (file)
@@ -9,6 +9,8 @@
 #include <linux/sched/task_stack.h>
 #include <linux/thread_info.h>
 
+#include <asm-generic/compat.h>
+
 #define __TYPE_IS_PTR(t) (!__builtin_types_compatible_p( \
                                typeof(0?(__force t)0:0ULL), u64))
 
 #define COMPAT_USER_HZ         100
 #define COMPAT_UTS_MACHINE     "s390\0\0\0\0"
 
-typedef u32            compat_size_t;
-typedef s32            compat_ssize_t;
-typedef s32            compat_clock_t;
-typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
 typedef u16            __compat_gid_t;
 typedef u32            __compat_uid32_t;
 typedef u32            __compat_gid32_t;
 typedef u16            compat_mode_t;
-typedef u32            compat_ino_t;
 typedef u16            compat_dev_t;
-typedef s32            compat_off_t;
-typedef s64            compat_loff_t;
 typedef u16            compat_nlink_t;
 typedef u16            compat_ipc_pid_t;
-typedef s32            compat_daddr_t;
 typedef u32            compat_caddr_t;
 typedef __kernel_fsid_t        compat_fsid_t;
-typedef s32            compat_key_t;
-typedef s32            compat_timer_t;
-
-typedef s32            compat_int_t;
-typedef s32            compat_long_t;
 typedef s64            compat_s64;
-typedef u32            compat_uint_t;
-typedef u32            compat_ulong_t;
 typedef u64            compat_u64;
-typedef u32            compat_uptr_t;
 
 typedef struct {
        u32 mask;
index 7018cb60beef0b91a6cd4c31a20abed82e968d97..30b1763580b1d1c86ecf9e7ec4d049a14171bed3 100644 (file)
@@ -6,38 +6,23 @@
  */
 #include <linux/types.h>
 
+#include <asm-generic/compat.h>
+
 #define COMPAT_USER_HZ         100
 #define COMPAT_UTS_MACHINE     "sparc\0\0"
 
-typedef u32            compat_size_t;
-typedef s32            compat_ssize_t;
-typedef s32            compat_clock_t;
-typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
 typedef u16            __compat_gid_t;
 typedef u32            __compat_uid32_t;
 typedef u32            __compat_gid32_t;
 typedef u16            compat_mode_t;
-typedef u32            compat_ino_t;
 typedef u16            compat_dev_t;
-typedef s32            compat_off_t;
-typedef s64            compat_loff_t;
 typedef s16            compat_nlink_t;
 typedef u16            compat_ipc_pid_t;
-typedef s32            compat_daddr_t;
 typedef u32            compat_caddr_t;
 typedef __kernel_fsid_t        compat_fsid_t;
-typedef s32            compat_key_t;
-typedef s32            compat_timer_t;
-
-typedef s32            compat_int_t;
-typedef s32            compat_long_t;
 typedef s64            compat_s64;
-typedef u32            compat_uint_t;
-typedef u32            compat_ulong_t;
 typedef u64            compat_u64;
-typedef u32            compat_uptr_t;
-
 struct compat_stat {
        compat_dev_t    st_dev;
        compat_ino_t    st_ino;
index fb97cf7c4137185a88b2af1846d914dc08de7120..0ce6f452d33481404e2b6910cfd89a817b59290a 100644 (file)
 #include <asm/user32.h>
 #include <asm/unistd.h>
 
+#include <asm-generic/compat.h>
+
 #define COMPAT_USER_HZ         100
 #define COMPAT_UTS_MACHINE     "i686\0\0"
 
-typedef u32            compat_size_t;
-typedef s32            compat_ssize_t;
-typedef s32            compat_clock_t;
-typedef s32            compat_pid_t;
 typedef u16            __compat_uid_t;
 typedef u16            __compat_gid_t;
 typedef u32            __compat_uid32_t;
 typedef u32            __compat_gid32_t;
 typedef u16            compat_mode_t;
-typedef u32            compat_ino_t;
 typedef u16            compat_dev_t;
-typedef s32            compat_off_t;
-typedef s64            compat_loff_t;
 typedef u16            compat_nlink_t;
 typedef u16            compat_ipc_pid_t;
-typedef s32            compat_daddr_t;
 typedef u32            compat_caddr_t;
 typedef __kernel_fsid_t        compat_fsid_t;
-typedef s32            compat_timer_t;
-typedef s32            compat_key_t;
-
-typedef s32            compat_int_t;
-typedef s32            compat_long_t;
 typedef s64 __attribute__((aligned(4))) compat_s64;
-typedef u32            compat_uint_t;
-typedef u32            compat_ulong_t;
-typedef u32            compat_u32;
 typedef u64 __attribute__((aligned(4))) compat_u64;
-typedef u32            compat_uptr_t;
 
 struct compat_stat {
        compat_dev_t    st_dev;
index 28819451b6d13fc905a6ec7c554ddb2deec671ef..a86f65bffab8d0da0038215c0f1797c8f5936f1f 100644 (file)
@@ -1,3 +1,25 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_GENERIC_COMPAT_H
+#define __ASM_GENERIC_COMPAT_H
 
-/* This is an empty stub for 32-bit-only architectures */
+/* These types are common across all compat ABIs */
+typedef u32 compat_size_t;
+typedef s32 compat_ssize_t;
+typedef s32 compat_clock_t;
+typedef s32 compat_pid_t;
+typedef u32 compat_ino_t;
+typedef s32 compat_off_t;
+typedef s64 compat_loff_t;
+typedef s32 compat_daddr_t;
+typedef s32 compat_timer_t;
+typedef s32 compat_key_t;
+typedef s16 compat_short_t;
+typedef s32 compat_int_t;
+typedef s32 compat_long_t;
+typedef u16 compat_ushort_t;
+typedef u32 compat_uint_t;
+typedef u32 compat_ulong_t;
+typedef u32 compat_uptr_t;
+typedef u32 compat_aio_context_t;
+
+#endif
index 0e058792ecf642d3572fd4016c03de6833136188..d376fa8be00d025d11bfcb97c3a3b1a579471b77 100644 (file)
@@ -110,8 +110,6 @@ typedef struct compat_sigaltstack {
 typedef __compat_uid32_t       compat_uid_t;
 typedef __compat_gid32_t       compat_gid_t;
 
-typedef        compat_ulong_t          compat_aio_context_t;
-
 struct compat_sel_arg_struct;
 struct rusage;