1 From 44f1469daff3a0bfe67fb5839243f114ace3bad8 Mon Sep 17 00:00:00 2001
2 From: Joseph Myers <joseph@codesourcery.com>
3 Date: Mon, 5 Oct 2020 16:46:46 +0000
4 Subject: [PATCH 3/4] Fix GCC 11 -Warray-parameter warning for __sigsetjmp (bug
7 This patch fixes part of bug 26647 (-Werror=array-parameter error
8 building with GCC 11 because of __sigsetjmp being declared using an
9 array parameter in one header and a pointer parameter in another).
11 The fix is to split the struct __jmp_buf_tag definition out to a
12 separate bits/types/ header so it can be included in pthread.h, so
13 that pthread.h can declare __sigsetjmp with the type contents visible,
14 so can use an array (as in setjmp.h) rather than a pointer in the
17 Note that several other build failures with GCC 11 remain. This does
18 not fix the jmp_buf-related -Wstringop-overflow errors (also discussed
19 in bug 26647), or -Warray-parameter errors for other functions (bug
20 26686), or -Warray-bounds errors (bug 26687).
22 Tested, with older compilers, natively for x86_64 and with
23 build-many-glibc.py for aarch64-linux-gnu. Tested with
24 build-many-glibcs.py with GCC mainline for aarch64-linux-gnu that this
25 gets past the -Warray-parameter issue for __sigsetjmp (with the next
26 build failure being the other one discussed in bug 26647).
28 [Upstream: https://github.com/bminor/glibc/commit/19302b27bdacfe87e861ff46fc0fbad60dd6602d.patch]
29 Signed-off-by: Peter Seiderer <ps.report@gmx.net>
31 include/bits/types/struct___jmp_buf_tag.h | 1 +
32 setjmp/Makefile | 3 +-
33 setjmp/bits/types/struct___jmp_buf_tag.h | 37 +++++++++++++++++++++++
34 setjmp/setjmp.h | 15 +--------
35 sysdeps/nptl/pthread.h | 5 +--
36 5 files changed, 44 insertions(+), 17 deletions(-)
37 create mode 100644 include/bits/types/struct___jmp_buf_tag.h
38 create mode 100644 setjmp/bits/types/struct___jmp_buf_tag.h
40 diff --git a/include/bits/types/struct___jmp_buf_tag.h b/include/bits/types/struct___jmp_buf_tag.h
42 index 00000000..e3250150
44 +++ b/include/bits/types/struct___jmp_buf_tag.h
46 +#include <setjmp/bits/types/struct___jmp_buf_tag.h>
47 diff --git a/setjmp/Makefile b/setjmp/Makefile
48 index dcac5693..603f61d7 100644
51 @@ -22,7 +22,8 @@ subdir := setjmp
55 -headers := setjmp.h bits/setjmp.h bits/setjmp2.h
56 +headers := setjmp.h bits/setjmp.h bits/setjmp2.h \
57 + bits/types/struct___jmp_buf_tag.h
59 routines := setjmp sigjmp bsd-setjmp bsd-_setjmp \
60 longjmp __longjmp jmp-unwind
61 diff --git a/setjmp/bits/types/struct___jmp_buf_tag.h b/setjmp/bits/types/struct___jmp_buf_tag.h
63 index 00000000..9d8634f1
65 +++ b/setjmp/bits/types/struct___jmp_buf_tag.h
67 +/* Define struct __jmp_buf_tag.
68 + Copyright (C) 1991-2020 Free Software Foundation, Inc.
69 + This file is part of the GNU C Library.
71 + The GNU C Library is free software; you can redistribute it and/or
72 + modify it under the terms of the GNU Lesser General Public
73 + License as published by the Free Software Foundation; either
74 + version 2.1 of the License, or (at your option) any later version.
76 + The GNU C Library is distributed in the hope that it will be useful,
77 + but WITHOUT ANY WARRANTY; without even the implied warranty of
78 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79 + Lesser General Public License for more details.
81 + You should have received a copy of the GNU Lesser General Public
82 + License along with the GNU C Library; if not, see
83 + <https://www.gnu.org/licenses/>. */
85 +#ifndef __jmp_buf_tag_defined
86 +#define __jmp_buf_tag_defined 1
88 +#include <bits/setjmp.h> /* Get `__jmp_buf'. */
89 +#include <bits/types/__sigset_t.h>
91 +/* Calling environment, plus possibly a saved signal mask. */
94 + /* NOTE: The machine-dependent definitions of `__sigsetjmp'
95 + assume that a `jmp_buf' begins with a `__jmp_buf' and that
96 + `__mask_was_saved' follows it. Do not move these members
97 + or add others before it. */
98 + __jmp_buf __jmpbuf; /* Calling environment. */
99 + int __mask_was_saved; /* Saved the signal mask? */
100 + __sigset_t __saved_mask; /* Saved signal mask. */
104 diff --git a/setjmp/setjmp.h b/setjmp/setjmp.h
105 index 4e3443c3..c6c59f40 100644
106 --- a/setjmp/setjmp.h
107 +++ b/setjmp/setjmp.h
111 #include <bits/setjmp.h> /* Get `__jmp_buf'. */
112 -#include <bits/types/__sigset_t.h>
114 -/* Calling environment, plus possibly a saved signal mask. */
115 -struct __jmp_buf_tag
117 - /* NOTE: The machine-dependent definitions of `__sigsetjmp'
118 - assume that a `jmp_buf' begins with a `__jmp_buf' and that
119 - `__mask_was_saved' follows it. Do not move these members
120 - or add others before it. */
121 - __jmp_buf __jmpbuf; /* Calling environment. */
122 - int __mask_was_saved; /* Saved the signal mask? */
123 - __sigset_t __saved_mask; /* Saved signal mask. */
126 +#include <bits/types/struct___jmp_buf_tag.h>
128 typedef struct __jmp_buf_tag jmp_buf[1];
130 diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
131 index 8a403cbf..d4194da7 100644
132 --- a/sysdeps/nptl/pthread.h
133 +++ b/sysdeps/nptl/pthread.h
135 #include <bits/wordsize.h>
136 #include <bits/types/struct_timespec.h>
137 #include <bits/types/__sigset_t.h>
138 +#include <bits/types/struct___jmp_buf_tag.h>
142 @@ -730,8 +731,8 @@ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
145 /* Function used in the macros. */
146 -struct __jmp_buf_tag;
147 -extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
148 +extern int __sigsetjmp (struct __jmp_buf_tag __env[1],
149 + int __savemask) __THROWNL;
152 /* Mutex handling. */