diff options
Diffstat (limited to 'sysdeps/unix/sysv')
32 files changed, 336 insertions, 419 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 7203581e2f..0e09d61a7a 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -48,7 +48,8 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ bits/termios-c_iflag.h bits/termios-c_oflag.h \ bits/termios-baud.h bits/termios-c_cflag.h \ bits/termios-c_lflag.h bits/termios-tcflow.h \ - bits/termios-misc.h + bits/termios-misc.h \ + bits/ipc-perm.h tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-quota tst-sync_file_range tst-sysconf-iov_max tst-ttyname \ diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/ipc.h b/sysdeps/unix/sysv/linux/aarch64/bits/ipc.h deleted file mode 100644 index a58c8980b5..0000000000 --- a/sysdeps/unix/sysv/linux/aarch64/bits/ipc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1995-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/>. */ - -#ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." -#endif - -#include <bits/types.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -# define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - -/* Data structure used to pass permission information to IPC operations. */ -struct ipc_perm - { - __key_t __key; /* Key. */ - __uid_t uid; /* Owner's user ID. */ - __gid_t gid; /* Owner's group ID. */ - __uid_t cuid; /* Creator's user ID. */ - __gid_t cgid; /* Creator's group ID. */ - unsigned int mode; /* Read/write permission. */ - unsigned short int __seq; /* Sequence number. */ - unsigned short int __pad1; - __syscall_ulong_t __glibc_reserved1; - __syscall_ulong_t __glibc_reserved2; - }; diff --git a/sysdeps/unix/sysv/linux/alpha/bits/ipc.h b/sysdeps/unix/sysv/linux/alpha/bits/ipc.h deleted file mode 100644 index 71cf2d5160..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/bits/ipc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1995-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/>. */ - -#ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." -#endif - -#include <bits/types.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -# define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - -/* Data structure used to pass permission information to IPC operations. */ -struct 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. */ - unsigned short int __pad1; - unsigned long int __glibc_reserved1; - unsigned long int __glibc_reserved2; - }; diff --git a/sysdeps/unix/sysv/linux/arm/be/Versions b/sysdeps/unix/sysv/linux/arm/be/Versions new file mode 100644 index 0000000000..a50cd57630 --- /dev/null +++ b/sysdeps/unix/sysv/linux/arm/be/Versions @@ -0,0 +1,5 @@ +libc { + GLIBC_2.31 { + msgctl; semctl; shmctl; + } +} diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 9371927927..b152c0e24a 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -130,6 +130,9 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 msgctl F +GLIBC_2.31 semctl F +GLIBC_2.31 shmctl F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0xa0 GLIBC_2.4 _IO_2_1_stdin_ D 0xa0 diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h index 3befa92b57..6b32970e2b 100644 --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h @@ -17,6 +17,7 @@ License along with the GNU C Library. If not, see <https://www.gnu.org/licenses/>. */ +#include <endian.h> #include_next <kernel-features.h> /* The ARM kernel before 3.14.3 may or may not support @@ -49,3 +50,7 @@ #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS 1 + +#if __BYTE_ORDER == __BIG_ENDIAN +# define __ASSUME_SYSVIPC_BROKEN_MODE_T +#endif diff --git a/sysdeps/unix/sysv/linux/bits/ipc-perm.h b/sysdeps/unix/sysv/linux/bits/ipc-perm.h new file mode 100644 index 0000000000..2c3f49f292 --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/ipc-perm.h @@ -0,0 +1,40 @@ +/* struct ipc_perm definition. + 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 + 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 + <http://www.gnu.org/licenses/>. */ + +#ifndef _SYS_IPC_H +# error "Never use <bits/ipc-perm.h> directly; include <sys/ipc.h> instead." +#endif + +/* Data structure used to pass permission information to IPC operations. + It follows the kernel ipc64_perm size so the syscall can be made directly + without temporary buffer copy. However, since glibc defines the MODE + field as mode_t per POSIX definition (BZ#18231), it omits the __PAD1 field + (since glibc does not export mode_t as 16-bit for any architecture). */ +struct ipc_perm +{ + __key_t __key; /* Key. */ + __uid_t uid; /* Owner's user ID. */ + __gid_t gid; /* Owner's group ID. */ + __uid_t cuid; /* Creator's user ID. */ + __gid_t cgid; /* Creator's group ID. */ + __mode_t mode; /* Read/write permission. */ + unsigned short int __seq; /* Sequence number. */ + unsigned short int __pad2; + __syscall_ulong_t __glibc_reserved1; + __syscall_ulong_t __glibc_reserved2; +}; diff --git a/sysdeps/unix/sysv/linux/bits/ipc.h b/sysdeps/unix/sysv/linux/bits/ipc.h index 652369cb8d..9939857ab5 100644 --- a/sysdeps/unix/sysv/linux/bits/ipc.h +++ b/sysdeps/unix/sysv/linux/bits/ipc.h @@ -37,19 +37,4 @@ /* Special key values. */ #define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - -/* Data structure used to pass permission information to IPC operations. */ -struct ipc_perm - { - __key_t __key; /* Key. */ - __uid_t uid; /* Owner's user ID. */ - __gid_t gid; /* Owner's group ID. */ - __uid_t cuid; /* Creator's user ID. */ - __gid_t cgid; /* Creator's group ID. */ - unsigned short int mode; /* Read/write permission. */ - unsigned short int __pad1; - unsigned short int __seq; /* Sequence number. */ - unsigned short int __pad2; - __syscall_ulong_t __glibc_reserved1; - __syscall_ulong_t __glibc_reserved2; - }; +#include <bits/ipc-perm.h> diff --git a/sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h b/sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h new file mode 100644 index 0000000000..f29fc1689c --- /dev/null +++ b/sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h @@ -0,0 +1,37 @@ +/* struct ipc_perm definition. + 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 + 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 + <http://www.gnu.org/licenses/>. */ + +#ifndef _SYS_IPC_H +# error "Never use <bits/ipc-perm.h> directly; include <sys/ipc.h> instead." +#endif + +/* Data structure used to pass permission information to IPC operations. */ +struct ipc_perm + { + __key_t __key; /* Key. */ + __uid_t uid; /* Owner's user ID. */ + __gid_t gid; /* Owner's group ID. */ + __uid_t cuid; /* Creator's user ID. */ + __gid_t cgid; /* Creator's group ID. */ + __mode_t mode; /* Read/write permission. */ + unsigned short int __pad2; + unsigned short int __seq; /* Sequence number. */ + unsigned int __pad3; + __extension__ unsigned long long int __glibc_reserved1; + __extension__ unsigned long long int __glibc_reserved2; + }; diff --git a/sysdeps/unix/sysv/linux/hppa/bits/ipc.h b/sysdeps/unix/sysv/linux/hppa/bits/ipc.h deleted file mode 100644 index b7ae38da70..0000000000 --- a/sysdeps/unix/sysv/linux/hppa/bits/ipc.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 1995-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/>. */ - -#ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." -#endif - -#include <bits/types.h> -#include <bits/wordsize.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -# define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - -/* Data structure used to pass permission information to IPC operations. */ -struct ipc_perm - { - __key_t __key; /* Key. */ - __uid_t uid; /* Owner's user ID. */ - __gid_t gid; /* Owner's group ID. */ - __uid_t cuid; /* Creator's user ID. */ - __gid_t cgid; /* Creator's group ID. */ -#if __WORDSIZE == 32 - unsigned short int __pad1; - unsigned short int mode; /* Read/write permission. */ - unsigned short int __pad2; -#else - __mode_t mode; /* Read/write permission. */ - unsigned short int __pad2; -#endif - unsigned short int __seq; /* Sequence number. */ - unsigned int __pad3; - __extension__ unsigned long long int __glibc_reserved1; - __extension__ unsigned long long int __glibc_reserved2; - }; diff --git a/sysdeps/unix/sysv/linux/ia64/bits/ipc.h b/sysdeps/unix/sysv/linux/ia64/bits/ipc.h deleted file mode 100644 index 2d7a920242..0000000000 --- a/sysdeps/unix/sysv/linux/ia64/bits/ipc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2000-2019 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by David Mosberger-Tang <davidm@hpl.hp.com> - - 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/>. */ - -#ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." -#endif - -#include <sys/types.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#define IPC_INFO 3 /* See ipcs. */ - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - -/* Data structure used to pass permission information to IPC operations. */ -struct ipc_perm - { - __key_t __key; /* Key. */ - __uid_t uid; /* Owner's user ID. */ - __gid_t gid; /* Owner's group ID. */ - __uid_t cuid; /* Creator's user ID. */ - __gid_t cgid; /* Creator's group ID. */ - __mode_t mode; /* Read/write permission. */ - unsigned short int __seq; /* Sequence number. */ - unsigned short int __pad1; - unsigned long int __glibc_reserved1; - unsigned long int __glibc_reserved2; - }; diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 5b35722768..7305686081 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -86,6 +86,14 @@ either support ipc syscall and/or all the ipc correspondent syscalls. */ #define __ASSUME_DIRECT_SYSVIPC_SYSCALLS 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 + field. This is only an issue if arch-defined IPC_PERM padding is on a + wrong position regarding endianness. In this case, the IPC control + routines (msgctl, semctl, and semtctl) requires to shift the value to + correct place. + The ABIs that requires it define __ASSUME_SYSVIPC_BROKEN_MODE_T. */ + /* Support for p{read,write}v2 was added in 4.6. However Linux default implementation does not assume the __ASSUME_* and instead use a fallback implementation based on p{read,write}v and returning an error for diff --git a/sysdeps/unix/sysv/linux/m68k/Versions b/sysdeps/unix/sysv/linux/m68k/Versions index 8e72cd18cb..4b18795513 100644 --- a/sysdeps/unix/sysv/linux/m68k/Versions +++ b/sysdeps/unix/sysv/linux/m68k/Versions @@ -37,6 +37,9 @@ libc { GLIBC_2.11 { fallocate64; } + GLIBC_2.31 { + msgctl; semctl; shmctl; + } GLIBC_2.12 { __m68k_read_tp; } diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index f3aa47d090..5e3cdea246 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -131,6 +131,9 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 msgctl F +GLIBC_2.31 semctl F +GLIBC_2.31 shmctl F GLIBC_2.4 _Exit F GLIBC_2.4 _IO_2_1_stderr_ D 0x98 GLIBC_2.4 _IO_2_1_stdin_ D 0x98 diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h index fe9a5b3e88..becc05d4dd 100644 --- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h +++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h @@ -52,3 +52,4 @@ /* m68k only supports ipc syscall. */ #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS +#define __ASSUME_SYSVIPC_BROKEN_MODE_T diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 64d4623b6b..ea5e7a41af 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2155,6 +2155,9 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 msgctl F +GLIBC_2.31 semctl F +GLIBC_2.31 shmctl F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/Versions b/sysdeps/unix/sysv/linux/microblaze/be/Versions new file mode 100644 index 0000000000..a50cd57630 --- /dev/null +++ b/sysdeps/unix/sysv/linux/microblaze/be/Versions @@ -0,0 +1,5 @@ +libc { + GLIBC_2.31 { + msgctl; semctl; shmctl; + } +} diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index f7ced487f7..ac55b0acd7 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2137,3 +2137,6 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 msgctl F +GLIBC_2.31 semctl F +GLIBC_2.31 shmctl F diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h index 79102079cd..19c77a42bd 100644 --- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h +++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h @@ -15,6 +15,7 @@ License along with the GNU C Library. If not, see <https://www.gnu.org/licenses/>. */ +#include <endian.h> /* All supported kernel versions for MicroBlaze have these syscalls. */ #define __ASSUME_SOCKET_SYSCALL 1 @@ -67,3 +68,7 @@ #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS3 + +#if __BYTE_ORDER == __BIG_ENDIAN +# define __ASSUME_SYSVIPC_BROKEN_MODE_T +#endif diff --git a/sysdeps/unix/sysv/linux/mips/bits/ipc.h b/sysdeps/unix/sysv/linux/mips/bits/ipc.h deleted file mode 100644 index 465bc42d9a..0000000000 --- a/sysdeps/unix/sysv/linux/mips/bits/ipc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 1995-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/>. */ - -#ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." -#endif - -#include <bits/types.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -# define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - -/* Data structure used to pass permission information to IPC operations. */ -struct 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. */ - unsigned short int __pad1; - unsigned long int __glibc_reserved1; - unsigned long int __glibc_reserved2; -}; diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c index a52b5477ce..19d5ded19f 100644 --- a/sysdeps/unix/sysv/linux/msgctl.c +++ b/sysdeps/unix/sysv/linux/msgctl.c @@ -23,11 +23,15 @@ #include <errno.h> #ifndef DEFAULT_VERSION -# define DEFAULT_VERSION GLIBC_2_2 +# ifndef __ASSUME_SYSVIPC_BROKEN_MODE_T +# define DEFAULT_VERSION GLIBC_2_2 +# else +# define DEFAULT_VERSION GLIBC_2_31 +# endif #endif -int -__new_msgctl (int msqid, int cmd, struct msqid_ds *buf) +static int +msgctl_syscall (int msqid, int cmd, struct msqid_ds *buf) { #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf); @@ -36,8 +40,54 @@ __new_msgctl (int msqid, int cmd, struct msqid_ds *buf) buf); #endif } + +int +__new_msgctl (int msqid, int cmd, struct msqid_ds *buf) +{ + /* POSIX states ipc_perm mode should have type of mode_t. */ + _Static_assert (sizeof ((struct msqid_ds){0}.msg_perm.mode) + == sizeof (mode_t), + "sizeof (msqid_ds.msg_perm.mode) != sizeof (mode_t)"); + +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T + struct msqid_ds tmpds; + if (cmd == IPC_SET) + { + tmpds = *buf; + tmpds.msg_perm.mode *= 0x10000U; + buf = &tmpds; + } +#endif + + int ret = msgctl_syscall (msqid, cmd, buf); + +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T + if (ret >= 0) + { + switch (cmd) + { + case IPC_STAT: + case MSG_STAT: + case MSG_STAT_ANY: + buf->msg_perm.mode >>= 16; + } + } +#endif + + return ret; +} versioned_symbol (libc, __new_msgctl, msgctl, DEFAULT_VERSION); +#if defined __ASSUME_SYSVIPC_BROKEN_MODE_T \ + && SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_31) +int +attribute_compat_text_section +__msgctl_mode16 (int msqid, int cmd, struct msqid_ds *buf) +{ + return msgctl_syscall (msqid, cmd, buf); +} +compat_symbol (libc, __msgctl_mode16, msgctl, GLIBC_2_2); +#endif #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) struct __old_msqid_ds diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/ipc.h b/sysdeps/unix/sysv/linux/powerpc/bits/ipc-perm.h index 7385406127..959ea32993 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/ipc.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/ipc-perm.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1995-2019 Free Software Foundation, Inc. +/* struct ipc_perm definition. Linux/powerpc version. + Copyright (C) 1995-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,28 +17,9 @@ <https://www.gnu.org/licenses/>. */ #ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." +# error "Never use <bits/ipc-perm.h> directly; include <sys/ipc.h> instead." #endif -#include <bits/types.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -# define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - /* Data structure used to pass permission information to IPC operations. */ struct ipc_perm { diff --git a/sysdeps/unix/sysv/linux/s390/bits/ipc.h b/sysdeps/unix/sysv/linux/s390/bits/ipc.h deleted file mode 100644 index d4dd567ea9..0000000000 --- a/sysdeps/unix/sysv/linux/s390/bits/ipc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2001-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/>. */ - -#ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." -#endif - -#include <bits/types.h> -#include <bits/wordsize.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -#define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - -/* Data structure used to pass permission information to IPC operations. */ -struct ipc_perm - { - __key_t __key; /* Key. */ - __uid_t uid; /* Owner's user ID. */ - __gid_t gid; /* Owner's group ID. */ - __uid_t cuid; /* Creator's user ID. */ - __gid_t cgid; /* Creator's group ID. */ -#if __WORDSIZE == 64 - __mode_t mode; /* Read/write permission. */ -#else - unsigned short int mode; /* Read/write permission. */ - unsigned short int __pad1; -#endif - unsigned short int __seq; /* Sequence number. */ - unsigned short int __pad2; - unsigned long int __glibc_reserved1; - unsigned long int __glibc_reserved2; - }; diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h index 7e7437df5c..6dca32c6c7 100644 --- a/sysdeps/unix/sysv/linux/s390/kernel-features.h +++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h @@ -47,6 +47,9 @@ /* s390 only supports ipc syscall. */ #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS +#ifndef __s390x__ +# define __ASSUME_SYSVIPC_BROKEN_MODE_T +#endif #undef __ASSUME_CLONE_DEFAULT #define __ASSUME_CLONE_BACKWARDS2 diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/Versions b/sysdeps/unix/sysv/linux/s390/s390-32/Versions index 1c120e8cbe..99193982a7 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/Versions +++ b/sysdeps/unix/sysv/linux/s390/s390-32/Versions @@ -49,6 +49,9 @@ libc { GLIBC_2.11 { fallocate64; } + GLIBC_2.31 { + msgctl; semctl; shmctl; + } } libutil { diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 122d0fb65a..4feca641b0 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2180,6 +2180,9 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 msgctl F +GLIBC_2.31 semctl F +GLIBC_2.31 shmctl F GLIBC_2.4 _IO_fprintf F GLIBC_2.4 _IO_printf F GLIBC_2.4 _IO_sprintf F diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c index fbe4b4f11f..e7f48e4093 100644 --- a/sysdeps/unix/sysv/linux/semctl.c +++ b/sysdeps/unix/sysv/linux/semctl.c @@ -33,12 +33,33 @@ union semun }; #ifndef DEFAULT_VERSION -# define DEFAULT_VERSION GLIBC_2_2 +# ifndef __ASSUME_SYSVIPC_BROKEN_MODE_T +# define DEFAULT_VERSION GLIBC_2_2 +# else +# define DEFAULT_VERSION GLIBC_2_31 +# endif #endif +static int +semctl_syscall (int semid, int semnum, int cmd, union semun arg) +{ +#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS + return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64, + arg.array); +#else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64, + SEMCTL_ARG_ADDRESS (arg)); +#endif +} + int __new_semctl (int semid, int semnum, int cmd, ...) { + /* POSIX states ipc_perm mode should have type of mode_t. */ + _Static_assert (sizeof ((struct semid_ds){0}.sem_perm.mode) + == sizeof (mode_t), + "sizeof (msqid_ds.msg_perm.mode) != sizeof (mode_t)"); + union semun arg = { 0 }; va_list ap; @@ -59,16 +80,65 @@ __new_semctl (int semid, int semnum, int cmd, ...) break; } -#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS - return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64, - arg.array); -#else - return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64, - SEMCTL_ARG_ADDRESS (arg)); +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T + struct semid_ds tmpds; + if (cmd == IPC_SET) + { + tmpds = *arg.buf; + tmpds.sem_perm.mode *= 0x10000U; + arg.buf = &tmpds; + } +#endif + + int ret = semctl_syscall (semid, semnum, cmd, arg); + +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T + if (ret >= 0) + { + switch (cmd) + { + case IPC_STAT: + case SEM_STAT: + case SEM_STAT_ANY: + arg.buf->sem_perm.mode >>= 16; + } + } #endif + + return ret; } versioned_symbol (libc, __new_semctl, semctl, DEFAULT_VERSION); +#if defined __ASSUME_SYSVIPC_BROKEN_MODE_T \ + && SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_31) +int +attribute_compat_text_section +__semctl_mode16 (int semid, int semnum, int cmd, ...) +{ + union semun arg = { 0 }; + va_list ap; + + /* Get the argument only if required. */ + switch (cmd) + { + case SETVAL: /* arg.val */ + case GETALL: /* arg.array */ + case SETALL: + case IPC_STAT: /* arg.buf */ + case IPC_SET: + case SEM_STAT: + case IPC_INFO: /* arg.__buf */ + case SEM_INFO: + va_start (ap, cmd); + arg = va_arg (ap, union semun); + va_end (ap); + break; + } + + return semctl_syscall (semid, semnum, cmd, arg); +} +compat_symbol (libc, __semctl_mode16, semctl, GLIBC_2_2); +#endif #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) /* Since semctl use a variadic argument for semid_ds there is not need to diff --git a/sysdeps/unix/sysv/linux/sh/be/Versions b/sysdeps/unix/sysv/linux/sh/be/Versions new file mode 100644 index 0000000000..a50cd57630 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sh/be/Versions @@ -0,0 +1,5 @@ +libc { + GLIBC_2.31 { + msgctl; semctl; shmctl; + } +} diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 4b057bf4a2..6bfc2b7439 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2050,6 +2050,9 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 msgctl F +GLIBC_2.31 semctl F +GLIBC_2.31 shmctl F GLIBC_2.4 __confstr_chk F GLIBC_2.4 __fgets_chk F GLIBC_2.4 __fgets_unlocked_chk F diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h index 80fd7a8a4e..fae54c8df5 100644 --- a/sysdeps/unix/sysv/linux/sh/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h @@ -20,6 +20,8 @@ #ifndef __KERNEL_FEATURES_SH__ # define __KERNEL_FEATURES_SH__ +#include <endian.h> + /* These syscalls were added for SH in 2.6.37. */ #define __ASSUME_SOCKET_SYSCALL 1 #define __ASSUME_BIND_SYSCALL 1 @@ -43,6 +45,9 @@ /* sh only supports ipc syscall. */ #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS +#if __BYTE_ORDER == __BIG_ENDIAN +# define __ASSUME_SYSVIPC_BROKEN_MODE_T +#endif /* Support for several syscalls was added in 4.8. */ #if __LINUX_KERNEL_VERSION < 0x040800 diff --git a/sysdeps/unix/sysv/linux/shmctl.c b/sysdeps/unix/sysv/linux/shmctl.c index 281fd13bb4..606c8dcd6b 100644 --- a/sysdeps/unix/sysv/linux/shmctl.c +++ b/sysdeps/unix/sysv/linux/shmctl.c @@ -23,15 +23,16 @@ #include <shlib-compat.h> #include <errno.h> - #ifndef DEFAULT_VERSION -# define DEFAULT_VERSION GLIBC_2_2 +# ifndef __ASSUME_SYSVIPC_BROKEN_MODE_T +# define DEFAULT_VERSION GLIBC_2_2 +# else +# define DEFAULT_VERSION GLIBC_2_31 +# endif #endif - -/* Provide operations to control over shared memory segments. */ -int -__new_shmctl (int shmid, int cmd, struct shmid_ds *buf) +static int +shmctl_syscall (int shmid, int cmd, struct shmid_ds *buf) { #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS return INLINE_SYSCALL_CALL (shmctl, shmid, cmd | __IPC_64, buf); @@ -40,8 +41,55 @@ __new_shmctl (int shmid, int cmd, struct shmid_ds *buf) buf); #endif } + +/* Provide operations to control over shared memory segments. */ +int +__new_shmctl (int shmid, int cmd, struct shmid_ds *buf) +{ + /* POSIX states ipc_perm mode should have type of mode_t. */ + _Static_assert (sizeof ((struct shmid_ds){0}.shm_perm.mode) + == sizeof (mode_t), + "sizeof (msqid_ds.msg_perm.mode) != sizeof (mode_t)"); + +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T + struct shmid_ds tmpds; + if (cmd == IPC_SET) + { + tmpds = *buf; + tmpds.shm_perm.mode *= 0x10000U; + buf = &tmpds; + } +#endif + + int ret = shmctl_syscall (shmid, cmd, buf); + +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T + if (ret >= 0) + { + switch (cmd) + { + case IPC_STAT: + case SHM_STAT: + case SHM_STAT_ANY: + buf->shm_perm.mode >>= 16; + } + } +#endif + + return ret; +} versioned_symbol (libc, __new_shmctl, shmctl, DEFAULT_VERSION); +#if defined __ASSUME_SYSVIPC_BROKEN_MODE_T \ + && SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_31) +int +attribute_compat_text_section +__shmctl_mode16 (int shmid, int cmd, struct shmid_ds *buf) +{ + return shmctl_syscall (shmid, cmd, buf); +} +compat_symbol (libc, __shmctl_mode16, shmctl, GLIBC_2_2); +#endif #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) struct __old_shmid_ds diff --git a/sysdeps/unix/sysv/linux/sparc/bits/ipc.h b/sysdeps/unix/sysv/linux/sparc/bits/ipc-perm.h index 9d290a6b82..e57f50c330 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/ipc.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/ipc-perm.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1995-2019 Free Software Foundation, Inc. +/* struct ipc_perm definition. Linux/sparc version. + Copyright (C) 1995-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,29 +17,9 @@ <https://www.gnu.org/licenses/>. */ #ifndef _SYS_IPC_H -# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead." +# error "Never use <bits/ipc-perm.h> directly; include <sys/ipc.h> instead." #endif -#include <bits/types.h> -#include <bits/wordsize.h> - -/* Mode bits for `msgget', `semget', and `shmget'. */ -#define IPC_CREAT 01000 /* Create key if key does not exist. */ -#define IPC_EXCL 02000 /* Fail if key exists. */ -#define IPC_NOWAIT 04000 /* Return error on wait. */ - -/* Control commands for `msgctl', `semctl', and `shmctl'. */ -#define IPC_RMID 0 /* Remove identifier. */ -#define IPC_SET 1 /* Set `ipc_perm' options. */ -#define IPC_STAT 2 /* Get `ipc_perm' options. */ -#ifdef __USE_GNU -# define IPC_INFO 3 /* See ipcs. */ -#endif - -/* Special key values. */ -#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ - - /* Data structure used to pass permission information to IPC operations. */ struct ipc_perm { @@ -47,14 +28,8 @@ struct ipc_perm __gid_t gid; /* Owner's group ID. */ __uid_t cuid; /* Creator's user ID. */ __gid_t cgid; /* Creator's group ID. */ -#if __WORDSIZE == 32 - unsigned short int __pad1; - unsigned short int mode; /* Read/write permission. */ - unsigned short int __pad2; -#else __mode_t mode; /* Read/write permission. */ unsigned short int __pad1; -#endif unsigned short int __seq; /* Sequence number. */ __extension__ unsigned long long int __glibc_reserved1; __extension__ unsigned long long int __glibc_reserved2; |