diff mbox series

[2/5] sysvipc: Move __IPC_64 to kernel-features.h

Message ID 20190516151249.19029-2-adhemerval.zanella@linaro.org
State New
Headers show
Series [1/5] sysvipc: Fix compat msgctl | expand

Commit Message

Adhemerval Zanella Netto May 16, 2019, 3:12 p.m. UTC
This patch moves the __IPC_64 definition from ipc_priv.h header to
kernel-features.h.  It also changes the expected value for newer ports
from 0x100 to 0x0, aligning with Linux UAPI.  The idea is to simplify
the Linux 5.1 wire-up of sysvipc syscalls for some 32-bit ABI, which
expected __IPC_64 to be 0x0 (thus tying its value to minimum supported
kernel version).

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

	* sysdeps/unix/sysv/linux/alpha/ipc_priv.h (__IPC_64): Remove
	definition.
	* sysdeps/unix/sysv/linux/ipc_priv.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ipc_priv.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h (__IPC_64):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/ipc_priv.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/csky/ipc_priv.h: Remove file.
	* sysdeps/unix/sysv/linux/hppa/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/ipc_priv.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h (__IPC_64): Define.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h (__IPC_64):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h (__IPC_64):
	Likewise.
	* sysdeep/unix/sysv/linux/mips/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h (__IPC_64): Likewise.
	* sysdeps/unix/sysv/linux/nios2/kernel-features.h: New file.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h [!__arch64__]
	(__IPC_64): Define.
---
 sysdeps/unix/sysv/linux/alpha/ipc_priv.h      |  2 --
 .../unix/sysv/linux/alpha/kernel-features.h   |  4 ++++
 sysdeps/unix/sysv/linux/arm/kernel-features.h |  8 +++++++
 sysdeps/unix/sysv/linux/csky/ipc_priv.h       | 21 -------------------
 sysdeps/unix/sysv/linux/hppa/ipc_priv.h       | 21 -------------------
 .../unix/sysv/linux/i386/kernel-features.h    |  7 +++++++
 sysdeps/unix/sysv/linux/ia64/ipc_priv.h       | 21 -------------------
 sysdeps/unix/sysv/linux/ipc_priv.h            |  2 --
 sysdeps/unix/sysv/linux/kernel-features.h     |  1 +
 .../unix/sysv/linux/m68k/kernel-features.h    |  8 +++++++
 .../sysv/linux/microblaze/kernel-features.h   |  7 +++++++
 .../unix/sysv/linux/mips/kernel-features.h    |  8 +++++++
 .../unix/sysv/linux/mips/mips64/ipc_priv.h    |  2 --
 sysdeps/unix/sysv/linux/nios2/ipc_priv.h      | 21 -------------------
 .../ipc_priv.h => nios2/kernel-features.h}    | 17 ++++++++++-----
 sysdeps/unix/sysv/linux/powerpc/ipc_priv.h    |  2 --
 .../unix/sysv/linux/powerpc/kernel-features.h |  8 +++++++
 sysdeps/unix/sysv/linux/riscv/ipc_priv.h      | 21 -------------------
 .../unix/sysv/linux/s390/kernel-features.h    |  8 +++++++
 sysdeps/unix/sysv/linux/sh/kernel-features.h  |  3 +++
 .../unix/sysv/linux/sparc/kernel-features.h   |  9 ++++++++
 .../unix/sysv/linux/sparc/sparc64/ipc_priv.h  |  2 --
 sysdeps/unix/sysv/linux/x86_64/ipc_priv.h     |  2 --
 23 files changed, 83 insertions(+), 122 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/csky/ipc_priv.h
 delete mode 100644 sysdeps/unix/sysv/linux/hppa/ipc_priv.h
 delete mode 100644 sysdeps/unix/sysv/linux/ia64/ipc_priv.h
 delete mode 100644 sysdeps/unix/sysv/linux/nios2/ipc_priv.h
 rename sysdeps/unix/sysv/linux/{aarch64/ipc_priv.h => nios2/kernel-features.h} (62%)
 delete mode 100644 sysdeps/unix/sysv/linux/riscv/ipc_priv.h

-- 
2.17.1

Comments

Andreas Schwab May 16, 2019, 3:38 p.m. UTC | #1
On Mai 16 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h

> index 2d2d355844..4f5c621f82 100644

> --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h

> +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h

> @@ -17,6 +17,9 @@

>     License along with the GNU C Library.  If not, see

>     <http://www.gnu.org/licenses/>.  */

>  

> +#ifndef _KERNEL_FEATURES_H

> +#define _KERNEL_FEATURES_H 1


Why do you need to add the guards (and only for some of them)?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Adhemerval Zanella Netto May 16, 2019, 6:57 p.m. UTC | #2
On 16/05/2019 12:38, Andreas Schwab wrote:
> On Mai 16 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 

>> diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h

>> index 2d2d355844..4f5c621f82 100644

>> --- a/sysdeps/unix/sysv/linux/arm/kernel-features.h

>> +++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h

>> @@ -17,6 +17,9 @@

>>     License along with the GNU C Library.  If not, see

>>     <http://www.gnu.org/licenses/>.  */

>>  

>> +#ifndef _KERNEL_FEATURES_H

>> +#define _KERNEL_FEATURES_H 1

> 

> Why do you need to add the guards (and only for some of them)?

> 

> Andreas.

> 


I added as I tried to build against the ABI and saw failures. The main
different is different than other __ASSUME flags, __IPC_64 is redefined.  
And this make compiler throw a lot of redefine error. For ARM specifically:

In file included from ../sysdeps/unix/sysv/linux/arm/kernel-features.h:23,
                 from ../sysdeps/unix/sysv/linux/lowlevellock-futex.h:25,
                 from ../sysdeps/nptl/lowlevellock.h:23,
                 from ../nptl/descr.h:29,
                 from ../sysdeps/arm/nptl/tls.h:42,
                 from ../sysdeps/unix/sysv/linux/arm/tls.h:23,
                 from ../sysdeps/unix/sysv/linux/arm/sysdep.h:33,
                 from <stdin>:2:
../sysdeps/unix/sysv/linux/kernel-features.h:83: error: "__IPC_64" redefined [-Werror]
 #define __IPC_64    0x0
 
In file included from ../sysdeps/unix/sysv/linux/sysdep.h:19,
                 from ../sysdeps/unix/sysv/linux/arm/sysdep.h:27,
                 from <stdin>:2:
../sysdeps/unix/sysv/linux/arm/kernel-features.h:58: note: this is the location of the previous definition
 #define __IPC_64   0x100

In general I think unguarded headers file are error-prone.
Andreas Schwab May 20, 2019, 7:42 a.m. UTC | #3
On Mai 16 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> In file included from ../sysdeps/unix/sysv/linux/arm/kernel-features.h:23,

>                  from ../sysdeps/unix/sysv/linux/lowlevellock-futex.h:25,

>                  from ../sysdeps/nptl/lowlevellock.h:23,

>                  from ../nptl/descr.h:29,

>                  from ../sysdeps/arm/nptl/tls.h:42,

>                  from ../sysdeps/unix/sysv/linux/arm/tls.h:23,

>                  from ../sysdeps/unix/sysv/linux/arm/sysdep.h:33,

>                  from <stdin>:2:

> ../sysdeps/unix/sysv/linux/kernel-features.h:83: error: "__IPC_64" redefined [-Werror]

>  #define __IPC_64    0x0

>  

> In file included from ../sysdeps/unix/sysv/linux/sysdep.h:19,

>                  from ../sysdeps/unix/sysv/linux/arm/sysdep.h:27,

>                  from <stdin>:2:

> ../sysdeps/unix/sysv/linux/arm/kernel-features.h:58: note: this is the location of the previous definition

>  #define __IPC_64   0x100


I think trying to put __IPC_64 in kernel-features.h is the wrong way to
solve this.

> In general I think unguarded headers file are error-prone.


kernel-features.h is special since it is chain-loaded.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Adhemerval Zanella Netto May 20, 2019, 11:53 a.m. UTC | #4
On 20/05/2019 04:42, Andreas Schwab wrote:
> On Mai 16 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 

>> In file included from ../sysdeps/unix/sysv/linux/arm/kernel-features.h:23,

>>                  from ../sysdeps/unix/sysv/linux/lowlevellock-futex.h:25,

>>                  from ../sysdeps/nptl/lowlevellock.h:23,

>>                  from ../nptl/descr.h:29,

>>                  from ../sysdeps/arm/nptl/tls.h:42,

>>                  from ../sysdeps/unix/sysv/linux/arm/tls.h:23,

>>                  from ../sysdeps/unix/sysv/linux/arm/sysdep.h:33,

>>                  from <stdin>:2:

>> ../sysdeps/unix/sysv/linux/kernel-features.h:83: error: "__IPC_64" redefined [-Werror]

>>  #define __IPC_64    0x0

>>  

>> In file included from ../sysdeps/unix/sysv/linux/sysdep.h:19,

>>                  from ../sysdeps/unix/sysv/linux/arm/sysdep.h:27,

>>                  from <stdin>:2:

>> ../sysdeps/unix/sysv/linux/arm/kernel-features.h:58: note: this is the location of the previous definition

>>  #define __IPC_64   0x100

> 

> I think trying to put __IPC_64 in kernel-features.h is the wrong way to

> solve this.


I don't a strong preference here, one option is to parametrize even more
the __IPC_64 with another flag that set/unset by kernel-features.h and
then handled by ipc-priv.h or whatever.  However I think this is more 
unnecessary complexity.

> 

>> In general I think unguarded headers file are error-prone.

> 

> kernel-features.h is special since it is chain-loaded.


Does it really to continue to be chain-loaded? It limits the way we
code it to just set/unset.

> 

> Andreas.

>
Andreas Schwab May 20, 2019, 12:20 p.m. UTC | #5
On Mai 20 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> I don't a strong preference here, one option is to parametrize even more

> the __IPC_64 with another flag that set/unset by kernel-features.h and

> then handled by ipc-priv.h or whatever.  However I think this is more 

> unnecessary complexity.


Can't you use __ASSUME_DIRECT_SYSVIPC_SYSCALLS for that?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
Adhemerval Zanella Netto May 20, 2019, 12:30 p.m. UTC | #6
On 20/05/2019 09:20, Andreas Schwab wrote:
> On Mai 20 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 

>> I don't a strong preference here, one option is to parametrize even more

>> the __IPC_64 with another flag that set/unset by kernel-features.h and

>> then handled by ipc-priv.h or whatever.  However I think this is more 

>> unnecessary complexity.

> 

> Can't you use __ASSUME_DIRECT_SYSVIPC_SYSCALLS for that?

> 


I think it feasible, I will adjust the patchset.
Adhemerval Zanella Netto May 20, 2019, 12:38 p.m. UTC | #7
On 20/05/2019 09:30, Adhemerval Zanella wrote:
> 

> 

> On 20/05/2019 09:20, Andreas Schwab wrote:

>> On Mai 20 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

>>

>>> I don't a strong preference here, one option is to parametrize even more

>>> the __IPC_64 with another flag that set/unset by kernel-features.h and

>>> then handled by ipc-priv.h or whatever.  However I think this is more 

>>> unnecessary complexity.

>>

>> Can't you use __ASSUME_DIRECT_SYSVIPC_SYSCALLS for that?

>>

> 

> I think it feasible, I will adjust the patchset.

> 


In fact the problem is __ASSUME_DIRECT_SYSVIPC_SYSCALLS does not hold
all the information.  Alpha, arm, microblaze, mips-n{32,64}, and nios
assumes the default of __ASSUME_DIRECT_SYSVIPC_SYSCALLS, but requires
__IPC_64 set to 0x100. 

While the newly added wire-up for i686, m68k, mips-o32, powerpc, s390,
and sparc requires would require __IPC_64 set to 0x100.  That's why
we will need to set __IPC_64 as architecture base or add an extra
__ASSUME flag to export this information.  I don't have a preference
here, assuming __IPC_64 is either 0x0 or 0x100 we can just set the
default value of 0x0 with a __ASSUME_SYSVIPC_DEFAULT_IPC_64 and 
undef on the required architectures to use 0x100.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/alpha/ipc_priv.h b/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
index fc5e713f42..8b91e2f9fa 100644
--- a/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/alpha/ipc_priv.h
@@ -18,8 +18,6 @@ 
 
 #include <sys/ipc.h>  /* For __key_t  */
 
-#define __IPC_64	0x100
-
 struct __old_ipc_perm
 {
   __key_t __key;		/* Key.  */
diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h
index f3298b234e..00f7d44df0 100644
--- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h
@@ -22,6 +22,10 @@ 
 
 #include_next <kernel-features.h>
 
+/* Alpha support old sysvipc even being a 64-bit architecture.  */
+#undef __IPC_64
+#define __IPC_64              0x100
+
 /* There never has been support for fstat64.  */
 #undef __ASSUME_STATFS64
 #define __ASSUME_STATFS64 0
diff --git a/sysdeps/unix/sysv/linux/arm/kernel-features.h b/sysdeps/unix/sysv/linux/arm/kernel-features.h
index 2d2d355844..4f5c621f82 100644
--- a/sysdeps/unix/sysv/linux/arm/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/arm/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 #include_next <kernel-features.h>
 
 /* The ARM kernel before 3.14.3 may or may not support
@@ -50,3 +53,8 @@ 
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS	1
+
+#undef __IPC_64
+#define __IPC_64			0x100
+
+#endif /* _KERNEL_FEATURE_H  */
diff --git a/sysdeps/unix/sysv/linux/csky/ipc_priv.h b/sysdeps/unix/sysv/linux/csky/ipc_priv.h
deleted file mode 100644
index e1beadb2a0..0000000000
--- a/sysdeps/unix/sysv/linux/csky/ipc_priv.h
+++ /dev/null
@@ -1,21 +0,0 @@ 
-/* Old SysV permission definition for Linux.  C-SKY 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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64	0x0
diff --git a/sysdeps/unix/sysv/linux/hppa/ipc_priv.h b/sysdeps/unix/sysv/linux/hppa/ipc_priv.h
deleted file mode 100644
index 5e170a9a2b..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/ipc_priv.h
+++ /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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64	0x0
diff --git a/sysdeps/unix/sysv/linux/i386/kernel-features.h b/sysdeps/unix/sysv/linux/i386/kernel-features.h
index 3ac725b5a2..5a26328d97 100644
--- a/sysdeps/unix/sysv/linux/i386/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/i386/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 /* Direct socketcalls available with kernel 4.3.  */
 #if __LINUX_KERNEL_VERSION >= 0x040300
 # define __ASSUME_SOCKET_SYSCALL             1
@@ -45,6 +48,10 @@ 
 
 /* i686 only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+#undef __IPC_64
+#define __IPC_64                        0x100
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS	1
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/ia64/ipc_priv.h b/sysdeps/unix/sysv/linux/ia64/ipc_priv.h
deleted file mode 100644
index 6b2438cd03..0000000000
--- a/sysdeps/unix/sysv/linux/ia64/ipc_priv.h
+++ /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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64	0x0
diff --git a/sysdeps/unix/sysv/linux/ipc_priv.h b/sysdeps/unix/sysv/linux/ipc_priv.h
index 7f517eb6fd..65adbb093e 100644
--- a/sysdeps/unix/sysv/linux/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/ipc_priv.h
@@ -18,8 +18,6 @@ 
 
 #include <sys/ipc.h>  /* For __key_t  */
 
-#define __IPC_64	0x100
-
 struct __old_ipc_perm
 {
   __key_t __key;			/* Key.  */
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index bc5c959f58..8fb6078de5 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -80,6 +80,7 @@ 
 /* 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
+#define __IPC_64				0x0
 
 /* 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
diff --git a/sysdeps/unix/sysv/linux/m68k/kernel-features.h b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
index 1976724362..8e81bb98ef 100644
--- a/sysdeps/unix/sysv/linux/m68k/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/m68k/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 /* Direct socketcalls available with kernel 4.3.  */
 #if __LINUX_KERNEL_VERSION >= 0x040300
 # define __ASSUME_SOCKET_SYSCALL             1
@@ -52,3 +55,8 @@ 
 
 /* m68k only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+
+#undef __IPC_64
+#define __IPC_64                        0x100
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
index 8df19400af..84b813d6ab 100644
--- a/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/microblaze/kernel-features.h
@@ -15,6 +15,8 @@ 
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
 
 /* All supported kernel versions for MicroBlaze have these syscalls.  */
 #define __ASSUME_SOCKET_SYSCALL		1
@@ -72,3 +74,8 @@ 
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS3
+
+#undef __IPC_64
+#define __IPC_64                        0x100
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/mips/kernel-features.h b/sysdeps/unix/sysv/linux/mips/kernel-features.h
index c341c3fa10..d90d87a5b0 100644
--- a/sysdeps/unix/sysv/linux/mips/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/mips/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 #include <sgidefs.h>
 
 #include_next <kernel-features.h>
@@ -27,6 +30,9 @@ 
 # undef __ASSUME_SET_ROBUST_LIST
 #endif
 
+#undef __IPC_64
+#define __IPC_64                        0x100
+
 /* Define this if your 32-bit syscall API requires 64-bit register
    pairs to start with an even-number register.  */
 #if _MIPS_SIM == _ABIO32
@@ -50,3 +56,5 @@ 
 
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS	1
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h b/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
index bb31656069..ab5db79e25 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h
@@ -18,8 +18,6 @@ 
 
 #include <sys/ipc.h>
 
-#define __IPC_64	0x100
-
 struct __old_ipc_perm
 {
   __key_t __key;		/* Key.  */
diff --git a/sysdeps/unix/sysv/linux/nios2/ipc_priv.h b/sysdeps/unix/sysv/linux/nios2/ipc_priv.h
deleted file mode 100644
index d6e6be797a..0000000000
--- a/sysdeps/unix/sysv/linux/nios2/ipc_priv.h
+++ /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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64	0x0
diff --git a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h b/sysdeps/unix/sysv/linux/nios2/kernel-features.h
similarity index 62%
rename from sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
rename to sysdeps/unix/sysv/linux/nios2/kernel-features.h
index cf55907693..813177f7b7 100644
--- a/sysdeps/unix/sysv/linux/aarch64/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/nios2/kernel-features.h
@@ -1,5 +1,6 @@ 
-/* Old SysV permission definition for Linux.  AArch64 version.
-   Copyright (C) 2016-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
@@ -13,9 +14,15 @@ 
    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
+   License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <sys/ipc.h>  /* For __key_t  */
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
 
-#define __IPC_64	0x0
+#include_next <kernel-features.h>
+
+#undef __IPC_64
+#define __IPC_64                        0x100
+
+#endif /* _KERNEL_FEATURES_H */
diff --git a/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h b/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
index 3450933f56..1c480ac0dd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/powerpc/ipc_priv.h
@@ -18,8 +18,6 @@ 
 
 #include <sys/ipc.h>  /* For __key_t  */
 
-#define __IPC_64	0x100
-
 struct __old_ipc_perm
 {
   __key_t __key;			/* Key.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
index 413a185db3..b0fd94b139 100644
--- a/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/powerpc/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 /* New syscalls added for PowerPC in 2.6.37.  */
 #define __ASSUME_SOCKET_SYSCALL	1
 #define __ASSUME_BIND_SYSCALL		1
@@ -47,5 +50,10 @@ 
 /* powerpc only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
 
+#undef __IPC_64
+#define __IPC_64                        0x100
+
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS	1
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/riscv/ipc_priv.h b/sysdeps/unix/sysv/linux/riscv/ipc_priv.h
deleted file mode 100644
index ea957a56be..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/ipc_priv.h
+++ /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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/ipc.h>  /* For __key_t  */
-
-#define __IPC_64	0x0
diff --git a/sysdeps/unix/sysv/linux/s390/kernel-features.h b/sysdeps/unix/sysv/linux/s390/kernel-features.h
index 8fdf38c454..12338c0090 100644
--- a/sysdeps/unix/sysv/linux/s390/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/s390/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 /* Direct socketcalls available with kernel 4.3.  */
 #if __LINUX_KERNEL_VERSION >= 0x040300
 # define __ASSUME_SOCKET_SYSCALL             1
@@ -48,5 +51,10 @@ 
 /* s390 only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
 
+#undef __IPC_64
+#define __IPC_64                        0x100
+
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS2
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/sh/kernel-features.h b/sysdeps/unix/sysv/linux/sh/kernel-features.h
index 767df721b8..1f8e140232 100644
--- a/sysdeps/unix/sysv/linux/sh/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sh/kernel-features.h
@@ -44,6 +44,9 @@ 
 /* sh only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
 
+#undef __IPC_64
+#define __IPC_64                        0x100
+
 /* Support for several syscalls was added in 4.8.  */
 #if __LINUX_KERNEL_VERSION < 0x040800
 # undef __ASSUME_RENAMEAT2
diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h
index f441bd811d..4cbe8399ac 100644
--- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h
@@ -17,6 +17,9 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _KERNEL_FEATURES_H
+#define _KERNEL_FEATURES_H 1
+
 #include_next <kernel-features.h>
 
 /* 32-bit SPARC kernels do not support
@@ -60,6 +63,10 @@ 
 
 /* sparc only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+#ifndef __arch64__
+# undef __IPC_64
+# define __IPC_64                            0x100
+#endif
 
 /* Support for the renameat2 syscall was added in 3.16.  */
 #if __LINUX_KERNEL_VERSION < 0x031000
@@ -79,3 +86,5 @@ 
    (INLINE_CLONE_SYSCALL).  */
 #undef __ASSUME_CLONE_DEFAULT
 #define __ASSUME_CLONE_BACKWARDS	1
+
+#endif /* _KERNEL_FEATURES_H  */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h b/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
index 8936aed022..685c25439b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
@@ -18,8 +18,6 @@ 
 
 #include <sys/ipc.h>  /* For __key_t  */
 
-#define __IPC_64	0x0
-
 struct __old_ipc_perm
 {
   __key_t __key;		/* Key.  */
diff --git a/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
index 1ac288aa65..ab44949e6d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
+++ b/sysdeps/unix/sysv/linux/x86_64/ipc_priv.h
@@ -18,8 +18,6 @@ 
 
 #include <sys/ipc.h>  /* For __key_t  */
 
-#define __IPC_64	0x0
-
 struct __old_ipc_perm
 {
   __key_t __key;		/* Key.  */