]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
ipc: Refactor sysvipc internal definitions
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 15 May 2019 18:20:58 +0000 (15:20 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 17 Oct 2019 14:04:59 +0000 (11:04 -0300)
This patch refactor the internal sysvipc in two main points:

  1. Add a new __ASSUME_SYSVIPC_DEFAULT_IPC_64 to infer the __IPC_64
     value to be used along either the multiplexed __NR_ipc or wired-up
     syscall.  The defaut value assumed for __IPC_64 is also changed
     from 0x100 to 0x0, aligning with Linux generic UAPI.  The idea
     is to simplify the Linux 5.1 wire-up for sysvipc syscalls for
     some 32-bit ABIs (which expectes __IPC_64 being 0x0) and simplify
     new ports (which will no longer need to add ipc_priv.h).

  2. It also removes some duplicated internal definition used on compat
     sysvipc symbols defined at ipc_priv.h (more specifically the
     __old_ipc_perm, SEMCTL_ARG_ADDRESS, MSGRCV_ARGS, and
     SEMTIMEDOP_IPC_ARGS).  The idea is also to make it simpler to enable
     the new wire-up sysvipc syscall provided by Linux v5.1.

There is no semantic change expected on any port.  Checked with a build
against all affected ABIs.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
22 files changed:
sysdeps/unix/sysv/linux/alpha/ipc_priv.h
sysdeps/unix/sysv/linux/alpha/kernel-features.h
sysdeps/unix/sysv/linux/arm/kernel-features.h
sysdeps/unix/sysv/linux/hppa/ipc_priv.h [deleted file]
sysdeps/unix/sysv/linux/i386/kernel-features.h
sysdeps/unix/sysv/linux/ia64/ipc_priv.h [deleted file]
sysdeps/unix/sysv/linux/ipc_priv.h
sysdeps/unix/sysv/linux/kernel-features.h
sysdeps/unix/sysv/linux/m68k/kernel-features.h
sysdeps/unix/sysv/linux/microblaze/kernel-features.h
sysdeps/unix/sysv/linux/mips/kernel-features.h
sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
sysdeps/unix/sysv/linux/nios2/ipc_priv.h [deleted file]
sysdeps/unix/sysv/linux/nios2/kernel-features.h [moved from sysdeps/unix/sysv/linux/csky/ipc_priv.h with 75% similarity]
sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
sysdeps/unix/sysv/linux/powerpc/kernel-features.h
sysdeps/unix/sysv/linux/riscv/ipc_priv.h [deleted file]
sysdeps/unix/sysv/linux/s390/kernel-features.h
sysdeps/unix/sysv/linux/sh/kernel-features.h
sysdeps/unix/sysv/linux/sparc/kernel-features.h
sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
sysdeps/unix/sysv/linux/x86_64/ipc_priv.h [deleted file]

index 881d9430634957d2b1a6b8ea1f86add38e4d8082..51891654ccb22caaddf2ff89389421d6cf0c8e95 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x100
-
-struct __old_ipc_perm
-{
-  __key_t __key;               /* Key.  */
-  unsigned int uid;            /* Owner's user ID.  */
-  unsigned int gid;            /* Owner's group ID.  */
-  unsigned int cuid;           /* Creator's user ID.  */
-  unsigned int cgid;           /* Creator's group ID.  */
-  unsigned int mode;           /* Read/write permission.  */
-  unsigned short int __seq;    /* Sequence number.  */
-};
+#define __OLD_IPC_ID_TYPE   unsigned int
+#define __OLD_IPC_MODE_TYPE unsigned int
+#include <sysdeps/unix/sysv/linux/ipc_priv.h>
index 3928b4b62c95f028daff827349e13bcc058b39b0..d12916c65658dd8acb4e06583f0117408ce997fd 100644 (file)
@@ -52,4 +52,7 @@
 # undef __ASSUME_STATX
 #endif
 
+/* Alpha requires old sysvipc even being a 64-bit architecture.  */
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
+
 #endif /* _KERNEL_FEATURES_H */
index 6b32970e2b18c3b2eacd05436c0ddc866b75b162..d66f3a4ab72d108feeaa4d72dd76096bc1dacc23 100644 (file)
@@ -54,3 +54,5 @@
 #if __BYTE_ORDER == __BIG_ENDIAN
 # define __ASSUME_SYSVIPC_BROKEN_MODE_T
 #endif
+
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
diff --git a/sysdeps/unix/sysv/linux/hppa/ipc_priv.h b/sysdeps/unix/sysv/linux/hppa/ipc_priv.h
deleted file mode 100644 (file)
index a52e2c7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Old SysV permission definition for Linux.  Hppa version.
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x0
index 8e982c41e65ea96c525c88e36ecafa0f92a2b9e0..33ba18e791ce679a3ffed22458ae7deb2248726c 100644 (file)
@@ -45,6 +45,7 @@
 
 /* i686 only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS       1
diff --git a/sysdeps/unix/sysv/linux/ia64/ipc_priv.h b/sysdeps/unix/sysv/linux/ia64/ipc_priv.h
deleted file mode 100644 (file)
index 29451a3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Old SysV permission definition for Linux.  IA64 version.
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x0
index deae555bfbce0526c4855811fee23bead2cf2997..aaeba83e851247118b738329e7e5e4ff2e456bc3 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <sys/ipc.h>  /* For __key_t  */
+#include <kernel-features.h>
 
-#define __IPC_64       0x100
+#ifdef __ASSUME_SYSVIPC_DEFAULT_IPC_64
+# define __IPC_64      0x0
+#else
+# define __IPC_64      0x100
+#endif
+
+#ifndef __OLD_IPC_ID_TYPE
+# define __OLD_IPC_ID_TYPE unsigned short int
+#endif
+#ifndef __OLD_IPC_MODE_TYPE
+# define __OLD_IPC_MODE_TYPE unsigned short int
+#endif
 
 struct __old_ipc_perm
 {
   __key_t __key;                       /* Key.  */
-  unsigned short int uid;              /* Owner's user ID.  */
-  unsigned short int gid;              /* Owner's group ID.  */
-  unsigned short int cuid;             /* Creator's user ID.  */
-  unsigned short int cgid;             /* Creator's group ID.  */
-  unsigned short int mode;             /* Read/write permission.  */
+  __OLD_IPC_ID_TYPE uid;               /* Owner's user ID.  */
+  __OLD_IPC_ID_TYPE gid;               /* Owner's group ID.  */
+  __OLD_IPC_ID_TYPE cuid;              /* Creator's user ID.  */
+  __OLD_IPC_ID_TYPE cgid;              /* Creator's group ID.  */
+  __OLD_IPC_MODE_TYPE mode;            /* Read/write permission.  */
   unsigned short int __seq;            /* Sequence number.  */
 };
 
index 7305686081b9c8eca368494c92f5c86b4cb541dc..e6be76ff46e07dbd25981b1a118d6f12a4d96afc 100644 (file)
@@ -85,6 +85,9 @@
 /* Support for SysV IPC through wired syscalls.  All supported architectures
    either support ipc syscall and/or all the ipc correspondent syscalls.  */
 #define __ASSUME_DIRECT_SYSVIPC_SYSCALLS       1
+/* The generic default __IPC_64 value is 0x0, however some architectures
+   require a different value of 0x100.  */
+#define __ASSUME_SYSVIPC_DEFAULT_IPC_64                1
 
 /* All supported architectures reserve a 32-bit for MODE field in sysvipc
    ipc_perm.  However, some kernel ABI interfaces still expect a 16-bit
index becc05d4dd8fc20b218737863ba64a88d85c3f6b..7ff9b5e28d1a8eae15e538d7f7358e5e803ea5ac 100644 (file)
@@ -53,3 +53,4 @@
 /* m68k only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
 #define __ASSUME_SYSVIPC_BROKEN_MODE_T
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
index 19c77a42bd2054b62e09b52c9e00db5c1d3f3185..2dd9810f93e3b41833a62e23cd9c5437bd3e3526 100644 (file)
@@ -72,3 +72,4 @@
 #if __BYTE_ORDER == __BIG_ENDIAN
 # define __ASSUME_SYSVIPC_BROKEN_MODE_T
 #endif
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
index a284417253ea20d103e431c49f330229ad62749f..7123b362eecd34c3f065ffeae496b2eed5ef7fbf 100644 (file)
@@ -50,3 +50,5 @@
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS       1
+
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
index 10d5c52dd0b71e58539932fc09e07dd128954d0e..3185d3940c7d16dd58cfa0c81258e4a97e88c742 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>
-
-#define __IPC_64       0x100
-
-struct __old_ipc_perm
-{
-  __key_t __key;               /* Key.  */
-  int uid;                     /* Owner's user ID.  */
-  int gid;                     /* Owner's group ID.  */
-  int cuid;                    /* Creator's user ID.  */
-  int cgid;                    /* Creator's group ID.  */
-  int mode;                    /* Read/write permission.  */
-  unsigned short int __seq;    /* Sequence number.  */
-};
+#define __OLD_IPC_ID_TYPE    int
+#define __OLD_IPC_MODE_TYPE  int
+#include <sysdeps/unix/sysv/linux/ipc_priv.h>
diff --git a/sysdeps/unix/sysv/linux/nios2/ipc_priv.h b/sysdeps/unix/sysv/linux/nios2/ipc_priv.h
deleted file mode 100644 (file)
index 7e15313..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Old SysV permission definition for Linux.  Nios II version.
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x0
similarity index 75%
rename from sysdeps/unix/sysv/linux/csky/ipc_priv.h
rename to sysdeps/unix/sysv/linux/nios2/kernel-features.h
index e8e8a256ea8ffb8b4a4648bc6996a9c578c1183b..c95e7051d9ba579fb7e1af759d40f0289c076c10 100644 (file)
@@ -1,5 +1,6 @@
-/* Old SysV permission definition for Linux.  C-SKY version.
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
+/* Set flags signalling availability of kernel features based on given
+   kernel version number.  NIOS2 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>  /* For __key_t  */
+#include_next <kernel-features.h>
 
-#define __IPC_64       0x0
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
index 96372bc9ade88e51d991883763dee9b4a227c8f0..3d592577716e165751af88bd65b0fc61b473527d 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x100
-
-struct __old_ipc_perm
-{
-  __key_t __key;                       /* Key.  */
-  unsigned int uid;                    /* Owner's user ID.  */
-  unsigned int gid;                    /* Owner's group ID.  */
-  unsigned int cuid;                   /* Creator's user ID.  */
-  unsigned int cgid;                   /* Creator's group ID.  */
-  unsigned int mode;                   /* Read/write permission.  */
-  unsigned short int __seq;            /* Sequence number.  */
-};
-
-#define SEMCTL_ARG_ADDRESS(__arg) &__arg.array
-
-#define MSGRCV_ARGS(__msgp, __msgtyp) \
-  ((long int []){ (long int) __msgp, __msgtyp })
-
-#define SEMTIMEDOP_IPC_ARGS(__nsops, __sops, __timeout) \
-  (__nsops), 0, (__sops), (__timeout)
-
-#include <ipc_ops.h>
+#define __OLD_IPC_ID_TYPE    unsigned int
+#define __OLD_IPC_MODE_TYPE  unsigned int
+#include <sysdeps/unix/sysv/linux/ipc_priv.h>
index d177a91ab39957980b5548403143aec0cedb7b6a..b93f7f8f1344816ec093eee6debdc977a968a798 100644 (file)
@@ -46,6 +46,7 @@
 
 /* powerpc only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS       1
diff --git a/sysdeps/unix/sysv/linux/riscv/ipc_priv.h b/sysdeps/unix/sysv/linux/riscv/ipc_priv.h
deleted file mode 100644 (file)
index dd755a9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Old SysV permission definition for Linux.  RISC-V version.
-   Copyright (C) 2018-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x0
index 6dca32c6c77abfe302b55053b96c15246fe797f9..f1f8dad3059dc253e942b5ccbb4aa9a1c8c7d5dd 100644 (file)
@@ -50,6 +50,7 @@
 #ifndef __s390x__
 # define __ASSUME_SYSVIPC_BROKEN_MODE_T
 #endif
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS2
index fae54c8df5dd703d5a53bdc1ae002414aea4daf3..dce9d41653c0761da7cb2307631ce0210ae98e3c 100644 (file)
@@ -48,6 +48,7 @@
 #if __BYTE_ORDER == __BIG_ENDIAN
 # define __ASSUME_SYSVIPC_BROKEN_MODE_T
 #endif
+#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
 
 /* Support for several syscalls was added in 4.8.  */
 #if __LINUX_KERNEL_VERSION < 0x040800
index c523461d951b0109677ecbf38bbd1a524976a4e7..25194117f681e55ae26432c7a04df272db1ccfe2 100644 (file)
@@ -60,6 +60,9 @@
 
 /* sparc only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+#ifndef __arch64__
+# undef __ASSUME_SYSVIPC_DEFAULT_IPC_64
+#endif
 
 /* Support for the renameat2 syscall was added in 3.16.  */
 #if __LINUX_KERNEL_VERSION < 0x031000
index 00f8510056dfd1a3cc13ec7ea2d540d479759210..0443d6b672506ef948f17a268e5957ecd9fed462 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x0
-
-struct __old_ipc_perm
-{
-  __key_t __key;               /* Key.  */
-  unsigned int uid;            /* Owner's user ID.  */
-  unsigned int gid;            /* Owner's group ID.  */
-  unsigned int cuid;           /* Creator's user ID.  */
-  unsigned int cgid;           /* Creator's group ID.  */
-  unsigned int mode;           /* Read/write permission.  */
-  unsigned short int __seq;    /* Sequence number.  */
-};
+#define __OLD_IPC_ID_TYPE   unsigned int
+#define __OLD_IPC_MODE_TYPE unsigned int
+#include <sysdeps/unix/sysv/linux/ipc_priv.h>
 
 /* SPARC semctl multiplex syscall expects the union pointed address, not
    the union address itself.  */
+#undef SEMCTL_ARG_ADDRESS
 #define SEMCTL_ARG_ADDRESS(__arg) __arg.array
 
 /* Also for msgrcv it does not use the kludge on final 2 arguments.  */
+#undef MSGRCV_ARGS
 #define MSGRCV_ARGS(__msgp, __msgtyp) __msgp, __msgtyp
 
 #define SEMTIMEDOP_IPC_ARGS(__nsops, __sops, __timeout) \
diff --git a/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
deleted file mode 100644 (file)
index e89c9b5..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Old SysV permission definition for Linux.  x86_64 version.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64       0x0
-
-struct __old_ipc_perm
-{
-  __key_t __key;               /* Key.  */
-  unsigned short uid;          /* Owner's user ID.  */
-  unsigned short gid;          /* Owner's group ID.  */
-  unsigned short cuid;         /* Creator's user ID.  */
-  unsigned short cgid;         /* Creator's group ID.  */
-  unsigned short mode;         /* Read/write permission.  */
-  unsigned short int __seq;    /* Sequence number.  */
-};