diff mbox

Split up bits/sigstack.h

Message ID alpine.DEB.2.20.1705192017240.24190@digraph.polyomino.org.uk
State New, archived
Headers show

Commit Message

Joseph Myers May 19, 2017, 8:18 p.m. UTC
bits/sigstack.h contains four things: the legacy struct sigstack type,
the preferred stack_t type, the SS_* enum values and macros for signal
stack sizes.

These vary in different ways between glibc configurations; in
particular, the stack sizes vary much more than any of the other
pieces.  Furthermore, these pieces have different standard namespace
rules for when they should be visible (not currently visible in
conform/ results both because the relevant tests are XFAILed for
sys/ucontext.h namespace issues, and because some of the expectations
are incorrect in the same way as the headers, e.g. neither
expectations nor headers reflect that current POSIX no longer has
either the sigstack function or the sigstack structure).

To reduce duplication of identical definitions, and facilitate
namespace fixes without requiring the same feature test macro
conditions to be repeated in many versions of the same header, this
patch splits bits/sigstack.h up into four headers.  It keeps the stack
size macros, while new bits/types/struct_sigstack.h,
bits/types/stack_t.h and bits/ss_flags.h are added for the other
pieces.  bits/types/struct_sigstack.h is the same everywhere,
bits/types/stack_t.h has three variants different in the order of the
structure elements (generic = MIPS Linux, and other Linux), and
bits/ss_flags.h has generic and Linux variants.

This patch includes the new headers everywhere that included
<bits/sigstack.h>, so should cause no difference to what any public
header defines.  Subsequent namespace fixes would then remove or
condition some of those includes.

There should be no conflicts with Zack's changes to signal.h types,
beyond the trivial conflict of both making additions to
signal/Makefile's headers list; the two patches affect disjoint sets
of types and other definitions.

Tested for x86_64 and x86, and with build-many-glibcs.py.

2017-05-19  Joseph Myers  <joseph@codesourcery.com>

	* bits/ss_flags.h: New file.
	* bits/types/stack_t.h: Likewise.
	* include/bits/types/struct_sigstack.h: Likewise.
	* signal/bits/types/struct_sigstack.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/ss_flags.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/types/stack_t.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h: Likewise.
	* signal/Makefile (headers): Add bits/types/struct_sigstack.h,
	bits/types/stack_t.h and bits/ss_flags.h.
	* signal/signal.h [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8]:
	Include <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
	<bits/ss_flags.h>.
	* bits/sigstack.h (struct sigstack): Remove.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
	(struct sigstack): Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sigstack.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
	(struct sigstack): Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/arm/sys/ucontext.h: Include
	<bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
	<bits/ss_flags.h>.
	* sysdeps/generic/sys/ucontext.h: Likewise.
	* sysdeps/i386/sys/ucontext.h: Likewise.
	* sysdeps/m68k/sys/ucontext.h: Likewise.
	* sysdeps/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Likewise.

Comments

Zack Weinberg May 19, 2017, 8:27 p.m. UTC | #1
On Fri, May 19, 2017 at 4:18 PM, Joseph Myers <joseph@codesourcery.com> wrote:
>
> 2017-05-19  Joseph Myers  <joseph@codesourcery.com>
>
>         * bits/ss_flags.h: New file.
>         * bits/types/stack_t.h: Likewise.
>         * include/bits/types/struct_sigstack.h: Likewise.
>         * signal/bits/types/struct_sigstack.h: Likewise.
>         * sysdeps/unix/sysv/linux/bits/ss_flags.h: Likewise.
>         * sysdeps/unix/sysv/linux/bits/types/stack_t.h: Likewise.
>         * sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h: Likewise.
>         * signal/Makefile (headers): Add bits/types/struct_sigstack.h,
>         bits/types/stack_t.h and bits/ss_flags.h.
>         * signal/signal.h [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8]:
>         Include <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
>         <bits/ss_flags.h>.
>         * bits/sigstack.h (struct sigstack): Remove.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
>         (struct sigstack): Likewise.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/unix/sysv/linux/alpha/bits/sigstack.h (struct sigstack):
>         Likewise.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/unix/sysv/linux/bits/sigstack.h (struct sigstack):
>         Likewise.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/unix/sysv/linux/mips/bits/sigstack.h: Likewise.
>         * sysdeps/unix/sysv/linux/ia64/bits/sigstack.h (struct sigstack):
>         Likewise.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
>         (struct sigstack): Likewise.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/unix/sysv/linux/sparc/bits/sigstack.h (struct sigstack):
>         Likewise.
>         (stack_t): Likewise.
>         (SS_ONSTACK): Likewise.
>         (SS_DISABLE): Likewise.
>         * sysdeps/arm/sys/ucontext.h: Include
>         <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
>         <bits/ss_flags.h>.
>         * sysdeps/generic/sys/ucontext.h: Likewise.
>         * sysdeps/i386/sys/ucontext.h: Likewise.
>         * sysdeps/m68k/sys/ucontext.h: Likewise.
>         * sysdeps/mips/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Likewise.
>         * sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Likewise.

LGTM.

zw
diff mbox

Patch

diff --git a/bits/sigstack.h b/bits/sigstack.h
index 42143e3..3127c32 100644
--- a/bits/sigstack.h
+++ b/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    __ptr_t ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    __ptr_t ss_sp;
-    size_t ss_size;
-    int ss_flags;
-  } stack_t;
-
-
-/* Possible values for `ss_flags.'.  */
-enum
-{
-  SS_ONSTACK = 0x0001,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE = 0x0004
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minumum stack size for a signal handler.  */
 #define MINSIGSTKSZ	8192
 
diff --git a/bits/ss_flags.h b/bits/ss_flags.h
new file mode 100644
index 0000000..fa3836c
--- /dev/null
+++ b/bits/ss_flags.h
@@ -0,0 +1,35 @@ 
+/* ss_flags values for stack_t.
+   Copyright (C) 1998-2017 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 _BITS_SS_FLAGS_H
+#define _BITS_SS_FLAGS_H 1
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never include this file directly.  Use <signal.h> instead"
+#endif
+
+/* Possible values for `ss_flags.'.  */
+enum
+{
+  SS_ONSTACK = 0x0001,
+#define SS_ONSTACK	SS_ONSTACK
+  SS_DISABLE = 0x0004
+#define SS_DISABLE	SS_DISABLE
+};
+
+#endif /* bits/ss_flags.h */
diff --git a/bits/types/stack_t.h b/bits/types/stack_t.h
new file mode 100644
index 0000000..3cf0a40
--- /dev/null
+++ b/bits/types/stack_t.h
@@ -0,0 +1,33 @@ 
+/* Define stack_t.
+   Copyright (C) 1998-2017 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 __stack_t_defined
+#define __stack_t_defined 1
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Structure describing a signal stack.  */
+typedef struct sigaltstack
+  {
+    void *ss_sp;
+    size_t ss_size;
+    int ss_flags;
+  } stack_t;
+
+#endif
diff --git a/include/bits/types/struct_sigstack.h b/include/bits/types/struct_sigstack.h
new file mode 100644
index 0000000..05f1ee5
--- /dev/null
+++ b/include/bits/types/struct_sigstack.h
@@ -0,0 +1 @@ 
+#include "../../signal/bits/types/struct_sigstack.h"
diff --git a/signal/Makefile b/signal/Makefile
index b65bf6b..077aaea 100644
--- a/signal/Makefile
+++ b/signal/Makefile
@@ -24,7 +24,8 @@  include ../Makeconfig
 
 headers	:= signal.h sys/signal.h bits/signum.h bits/sigcontext.h \
 	   bits/sigaction.h bits/sigset.h bits/siginfo.h bits/sigstack.h \
-	   bits/sigthread.h
+	   bits/sigthread.h bits/types/struct_sigstack.h bits/types/stack_t.h \
+	   bits/ss_flags.h
 
 routines	:= signal raise killpg \
 		   sigaction sigprocmask kill \
diff --git a/signal/bits/types/struct_sigstack.h b/signal/bits/types/struct_sigstack.h
new file mode 100644
index 0000000..5e93ce0
--- /dev/null
+++ b/signal/bits/types/struct_sigstack.h
@@ -0,0 +1,29 @@ 
+/* Define struct sigstack.
+   Copyright (C) 1998-2017 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 __sigstack_defined
+#define __sigstack_defined 1
+
+/* Structure describing a signal stack (obsolete).  */
+struct sigstack
+  {
+    void *ss_sp;		/* Signal stack pointer.  */
+    int ss_onstack;		/* Nonzero if executing on this stack.  */
+  };
+
+#endif
diff --git a/signal/signal.h b/signal/signal.h
index 6db2d2f..d01df32 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -314,6 +314,9 @@  extern int sigreturn (struct sigcontext *__scp) __THROW;
 extern int siginterrupt (int __sig, int __interrupt) __THROW;
 
 # include <bits/sigstack.h>
+# include <bits/types/struct_sigstack.h>
+# include <bits/types/stack_t.h>
+# include <bits/ss_flags.h>
 # if defined __USE_XOPEN || defined __USE_XOPEN2K8
 /* This will define `ucontext_t' and `mcontext_t'.  */
 #  include <sys/ucontext.h>
diff --git a/sysdeps/arm/sys/ucontext.h b/sysdeps/arm/sys/ucontext.h
index 09fe418..49d6039 100644
--- a/sysdeps/arm/sys/ucontext.h
+++ b/sysdeps/arm/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 typedef int greg_t;
diff --git a/sysdeps/generic/sys/ucontext.h b/sysdeps/generic/sys/ucontext.h
index 6c475b5..052c540 100644
--- a/sysdeps/generic/sys/ucontext.h
+++ b/sysdeps/generic/sys/ucontext.h
@@ -29,6 +29,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 typedef struct sigcontext mcontext_t;
diff --git a/sysdeps/i386/sys/ucontext.h b/sysdeps/i386/sys/ucontext.h
index c632e50..241f270 100644
--- a/sysdeps/i386/sys/ucontext.h
+++ b/sysdeps/i386/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /* Type for general register.  */
diff --git a/sysdeps/m68k/sys/ucontext.h b/sysdeps/m68k/sys/ucontext.h
index cbec1db..4e5ec3b 100644
--- a/sysdeps/m68k/sys/ucontext.h
+++ b/sysdeps/m68k/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /* Type for general register.  */
diff --git a/sysdeps/mips/sys/ucontext.h b/sysdeps/mips/sys/ucontext.h
index 137246f..cb8fbcd 100644
--- a/sysdeps/mips/sys/ucontext.h
+++ b/sysdeps/mips/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 #include <sgidefs.h>
 
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h b/sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
index a1f2acc..434b24e 100644
--- a/sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    void *ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    void *ss_sp;
-    int ss_flags;
-    size_t ss_size;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minimum stack size for a signal handler.  */
 #define MINSIGSTKSZ	5120
 
diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h b/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
index 536404d..1a5fa29 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h
@@ -28,6 +28,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 #ifdef __USE_MISC
 # include <sys/procfs.h>
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/sigstack.h b/sysdeps/unix/sysv/linux/alpha/bits/sigstack.h
index bba0212..9a30c9d 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/sigstack.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    __ptr_t ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    __ptr_t ss_sp;
-    int ss_flags;
-    size_t ss_size;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minimum stack size for a signal handler.  */
 #define MINSIGSTKSZ	4096
 
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/ucontext.h b/sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
index dc76e49..912c61c 100644
--- a/sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/alpha/sys/ucontext.h
@@ -25,6 +25,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /* Type for general register.  */
diff --git a/sysdeps/unix/sysv/linux/arm/sys/ucontext.h b/sysdeps/unix/sysv/linux/arm/sys/ucontext.h
index aedeccd..8a5ea71 100644
--- a/sysdeps/unix/sysv/linux/arm/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/arm/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 #ifdef __USE_MISC
diff --git a/sysdeps/unix/sysv/linux/bits/sigstack.h b/sysdeps/unix/sysv/linux/bits/sigstack.h
index a0c3a9f..e6b6c7e 100644
--- a/sysdeps/unix/sysv/linux/bits/sigstack.h
+++ b/sysdeps/unix/sysv/linux/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    void *ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    void *ss_sp;
-    int ss_flags;
-    size_t ss_size;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minimum stack size for a signal handler.  */
 #define MINSIGSTKSZ	2048
 
diff --git a/sysdeps/unix/sysv/linux/bits/ss_flags.h b/sysdeps/unix/sysv/linux/bits/ss_flags.h
new file mode 100644
index 0000000..497b613
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/ss_flags.h
@@ -0,0 +1,35 @@ 
+/* ss_flags values for stack_t.  Linux version.
+   Copyright (C) 1998-2017 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 _BITS_SS_FLAGS_H
+#define _BITS_SS_FLAGS_H 1
+
+#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
+# error "Never include this file directly.  Use <signal.h> instead"
+#endif
+
+/* Possible values for `ss_flags'.  */
+enum
+{
+  SS_ONSTACK = 1,
+#define SS_ONSTACK	SS_ONSTACK
+  SS_DISABLE
+#define SS_DISABLE	SS_DISABLE
+};
+
+#endif /* bits/ss_flags.h */
diff --git a/sysdeps/unix/sysv/linux/bits/types/stack_t.h b/sysdeps/unix/sysv/linux/bits/types/stack_t.h
new file mode 100644
index 0000000..497e42b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/bits/types/stack_t.h
@@ -0,0 +1,33 @@ 
+/* Define stack_t.  Linux version.
+   Copyright (C) 1998-2017 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 __stack_t_defined
+#define __stack_t_defined 1
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Structure describing a signal stack.  */
+typedef struct sigaltstack
+  {
+    void *ss_sp;
+    int ss_flags;
+    size_t ss_size;
+  } stack_t;
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h b/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
index 31eb77e..50e585d 100644
--- a/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 #ifdef __USE_MISC
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h b/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
index c9a0689..c81463d 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
@@ -26,6 +26,9 @@ 
 #define __need_size_t
 #include <stddef.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 struct __ia64_fpreg
   {
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/sigstack.h b/sysdeps/unix/sysv/linux/ia64/bits/sigstack.h
index abae4c9..aabefbb 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/sigstack.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    __ptr_t ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    __ptr_t ss_sp;
-    int ss_flags;
-    size_t ss_size;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minimum stack size for a signal handler.
 
    Yes, this should be 131072 but the constant got defined incorrectly
diff --git a/sysdeps/unix/sysv/linux/ia64/sys/ucontext.h b/sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
index b2dab0e..17474a5 100644
--- a/sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/ia64/sys/ucontext.h
@@ -25,6 +25,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /*
diff --git a/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h b/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
index 3c5dce5..18ff022 100644
--- a/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /* Type for general register.  */
diff --git a/sysdeps/unix/sysv/linux/mips/bits/sigstack.h b/sysdeps/unix/sysv/linux/mips/bits/sigstack.h
deleted file mode 100644
index 215f2ff..0000000
--- a/sysdeps/unix/sysv/linux/mips/bits/sigstack.h
+++ /dev/null
@@ -1,59 +0,0 @@ 
-/* sigstack, sigaltstack definitions.
-   Copyright (C) 1998-2017 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 _BITS_SIGSTACK_H
-#define _BITS_SIGSTACK_H 1
-
-#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H
-# error "Never include this file directly.  Use <signal.h> instead"
-#endif
-
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    void *ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    void *ss_sp;
-    size_t ss_size;
-    int ss_flags;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
-/* Minimum stack size for a signal handler.  */
-#define MINSIGSTKSZ	2048
-
-/* System default stack size.  */
-#define SIGSTKSZ	8192
-
-#endif /* bits/sigstack.h */
diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h b/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h
new file mode 100644
index 0000000..ef06072
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h
@@ -0,0 +1,33 @@ 
+/* Define stack_t.  MIPS Linux version.
+   Copyright (C) 1998-2017 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 __stack_t_defined
+#define __stack_t_defined 1
+
+#define __need_size_t
+#include <stddef.h>
+
+/* Structure describing a signal stack.  */
+typedef struct sigaltstack
+  {
+    void *ss_sp;
+    size_t ss_size;
+    int ss_flags;
+  } stack_t;
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/mips/sys/ucontext.h b/sysdeps/unix/sysv/linux/mips/sys/ucontext.h
index f766dac..f933780 100644
--- a/sysdeps/unix/sysv/linux/mips/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/mips/sys/ucontext.h
@@ -26,6 +26,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 #include <sgidefs.h>
 
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h b/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
index 3b0a615..c961e5b 100644
--- a/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
@@ -28,6 +28,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /* These definitions must be in sync with the kernel.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h b/sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
index 4a36ad1..74670cb 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    void *ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    void *ss_sp;
-    int ss_flags;
-    size_t ss_size;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minimum stack size for a signal handler.  */
 #define MINSIGSTKSZ	4096
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h b/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
index c3f9622..d9fad4c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
@@ -26,6 +26,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 #if __WORDSIZE == 32
diff --git a/sysdeps/unix/sysv/linux/s390/sys/ucontext.h b/sysdeps/unix/sysv/linux/s390/sys/ucontext.h
index 9790c0c..955a8fe 100644
--- a/sysdeps/unix/sysv/linux/s390/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/s390/sys/ucontext.h
@@ -26,6 +26,9 @@ 
    by in <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 /* Type for a program status word.  */
diff --git a/sysdeps/unix/sysv/linux/sh/sys/ucontext.h b/sysdeps/unix/sysv/linux/sh/sys/ucontext.h
index 5c6a5e4..3ce381d 100644
--- a/sysdeps/unix/sysv/linux/sh/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/sh/sys/ucontext.h
@@ -27,6 +27,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 typedef int greg_t;
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/sigstack.h b/sysdeps/unix/sysv/linux/sparc/bits/sigstack.h
index 4a36ad1..74670cb 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/sigstack.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/sigstack.h
@@ -23,33 +23,6 @@ 
 # error "Never include this file directly.  Use <signal.h> instead"
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-
-/* Structure describing a signal stack (obsolete).  */
-struct sigstack
-  {
-    void *ss_sp;		/* Signal stack pointer.  */
-    int ss_onstack;		/* Nonzero if executing on this stack.  */
-  };
-
-/* Alternate, preferred interface.  */
-typedef struct sigaltstack
-  {
-    void *ss_sp;
-    int ss_flags;
-    size_t ss_size;
-  } stack_t;
-
-/* Possible values for `ss_flags'.  */
-enum
-{
-  SS_ONSTACK = 1,
-#define SS_ONSTACK	SS_ONSTACK
-  SS_DISABLE
-#define SS_DISABLE	SS_DISABLE
-};
-
 /* Minimum stack size for a signal handler.  */
 #define MINSIGSTKSZ	4096
 
diff --git a/sysdeps/unix/sysv/linux/sparc/sys/ucontext.h b/sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
index b8f3ca7..0d6cbe6 100644
--- a/sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
@@ -25,6 +25,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 #include <bits/wordsize.h>
 
diff --git a/sysdeps/unix/sysv/linux/tile/sys/ucontext.h b/sysdeps/unix/sysv/linux/tile/sys/ucontext.h
index 95e6dd6..8fc2f13 100644
--- a/sysdeps/unix/sysv/linux/tile/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/tile/sys/ucontext.h
@@ -26,6 +26,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 #ifdef __USE_MISC
 /* Get register type and register names. */
diff --git a/sysdeps/unix/sysv/linux/x86/sys/ucontext.h b/sysdeps/unix/sysv/linux/x86/sys/ucontext.h
index 6dad48f..5dd72ac 100644
--- a/sysdeps/unix/sysv/linux/x86/sys/ucontext.h
+++ b/sysdeps/unix/sysv/linux/x86/sys/ucontext.h
@@ -25,6 +25,9 @@ 
    by <signal.h>.  */
 #include <bits/sigcontext.h>
 #include <bits/sigstack.h>
+#include <bits/types/struct_sigstack.h>
+#include <bits/types/stack_t.h>
+#include <bits/ss_flags.h>
 
 
 #ifdef __x86_64__