1*4882a593SmuzhiyunFrom 79f93ac5cb91cd9cbb02b503dcf428880f2cddf1 Mon Sep 17 00:00:00 2001
2*4882a593SmuzhiyunFrom: Joseph Myers <joseph@codesourcery.com>
3*4882a593SmuzhiyunDate: Mon, 5 Oct 2020 16:46:46 +0000
4*4882a593SmuzhiyunSubject: [PATCH 04/20] Fix GCC 11 -Warray-parameter warning for __sigsetjmp
5*4882a593Smuzhiyun (bug 26647)
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunThis patch fixes part of bug 26647 (-Werror=array-parameter error
8*4882a593Smuzhiyunbuilding with GCC 11 because of __sigsetjmp being declared using an
9*4882a593Smuzhiyunarray parameter in one header and a pointer parameter in another).
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunThe fix is to split the struct __jmp_buf_tag definition out to a
12*4882a593Smuzhiyunseparate bits/types/ header so it can be included in pthread.h, so
13*4882a593Smuzhiyunthat pthread.h can declare __sigsetjmp with the type contents visible,
14*4882a593Smuzhiyunso can use an array (as in setjmp.h) rather than a pointer in the
15*4882a593Smuzhiyundeclaration.
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunNote that several other build failures with GCC 11 remain.  This does
18*4882a593Smuzhiyunnot fix the jmp_buf-related -Wstringop-overflow errors (also discussed
19*4882a593Smuzhiyunin bug 26647), or -Warray-parameter errors for other functions (bug
20*4882a593Smuzhiyun26686), or -Warray-bounds errors (bug 26687).
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunTested, with older compilers, natively for x86_64 and with
23*4882a593Smuzhiyunbuild-many-glibc.py for aarch64-linux-gnu.  Tested with
24*4882a593Smuzhiyunbuild-many-glibcs.py with GCC mainline for aarch64-linux-gnu that this
25*4882a593Smuzhiyungets past the -Warray-parameter issue for __sigsetjmp (with the next
26*4882a593Smuzhiyunbuild failure being the other one discussed in bug 26647).
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun(cherry picked from commit 19302b27bdacfe87e861ff46fc0fbad60dd6602d)
29*4882a593SmuzhiyunSigned-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
30*4882a593Smuzhiyun---
31*4882a593Smuzhiyun include/bits/types/struct___jmp_buf_tag.h |  1 +
32*4882a593Smuzhiyun setjmp/Makefile                           |  3 +-
33*4882a593Smuzhiyun setjmp/bits/types/struct___jmp_buf_tag.h  | 37 +++++++++++++++++++++++
34*4882a593Smuzhiyun setjmp/setjmp.h                           | 15 +--------
35*4882a593Smuzhiyun sysdeps/nptl/pthread.h                    |  5 +--
36*4882a593Smuzhiyun 5 files changed, 44 insertions(+), 17 deletions(-)
37*4882a593Smuzhiyun create mode 100644 include/bits/types/struct___jmp_buf_tag.h
38*4882a593Smuzhiyun create mode 100644 setjmp/bits/types/struct___jmp_buf_tag.h
39*4882a593Smuzhiyun
40*4882a593Smuzhiyundiff --git a/include/bits/types/struct___jmp_buf_tag.h b/include/bits/types/struct___jmp_buf_tag.h
41*4882a593Smuzhiyunnew file mode 100644
42*4882a593Smuzhiyunindex 00000000..e3250150
43*4882a593Smuzhiyun--- /dev/null
44*4882a593Smuzhiyun+++ b/include/bits/types/struct___jmp_buf_tag.h
45*4882a593Smuzhiyun@@ -0,0 +1 @@
46*4882a593Smuzhiyun+#include <setjmp/bits/types/struct___jmp_buf_tag.h>
47*4882a593Smuzhiyundiff --git a/setjmp/Makefile b/setjmp/Makefile
48*4882a593Smuzhiyunindex dc2fcc62..f4da258b 100644
49*4882a593Smuzhiyun--- a/setjmp/Makefile
50*4882a593Smuzhiyun+++ b/setjmp/Makefile
51*4882a593Smuzhiyun@@ -22,7 +22,8 @@ subdir	:= setjmp
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun include ../Makeconfig
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun-headers	:= setjmp.h bits/setjmp.h bits/setjmp2.h
56*4882a593Smuzhiyun+headers	:= setjmp.h bits/setjmp.h bits/setjmp2.h \
57*4882a593Smuzhiyun+	   bits/types/struct___jmp_buf_tag.h
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun routines	:= setjmp sigjmp bsd-setjmp bsd-_setjmp \
60*4882a593Smuzhiyun 		   longjmp __longjmp jmp-unwind
61*4882a593Smuzhiyundiff --git a/setjmp/bits/types/struct___jmp_buf_tag.h b/setjmp/bits/types/struct___jmp_buf_tag.h
62*4882a593Smuzhiyunnew file mode 100644
63*4882a593Smuzhiyunindex 00000000..9d8634f1
64*4882a593Smuzhiyun--- /dev/null
65*4882a593Smuzhiyun+++ b/setjmp/bits/types/struct___jmp_buf_tag.h
66*4882a593Smuzhiyun@@ -0,0 +1,37 @@
67*4882a593Smuzhiyun+/* Define struct __jmp_buf_tag.
68*4882a593Smuzhiyun+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
69*4882a593Smuzhiyun+   This file is part of the GNU C Library.
70*4882a593Smuzhiyun+
71*4882a593Smuzhiyun+   The GNU C Library is free software; you can redistribute it and/or
72*4882a593Smuzhiyun+   modify it under the terms of the GNU Lesser General Public
73*4882a593Smuzhiyun+   License as published by the Free Software Foundation; either
74*4882a593Smuzhiyun+   version 2.1 of the License, or (at your option) any later version.
75*4882a593Smuzhiyun+
76*4882a593Smuzhiyun+   The GNU C Library is distributed in the hope that it will be useful,
77*4882a593Smuzhiyun+   but WITHOUT ANY WARRANTY; without even the implied warranty of
78*4882a593Smuzhiyun+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
79*4882a593Smuzhiyun+   Lesser General Public License for more details.
80*4882a593Smuzhiyun+
81*4882a593Smuzhiyun+   You should have received a copy of the GNU Lesser General Public
82*4882a593Smuzhiyun+   License along with the GNU C Library; if not, see
83*4882a593Smuzhiyun+   <https://www.gnu.org/licenses/>.  */
84*4882a593Smuzhiyun+
85*4882a593Smuzhiyun+#ifndef	__jmp_buf_tag_defined
86*4882a593Smuzhiyun+#define	__jmp_buf_tag_defined 1
87*4882a593Smuzhiyun+
88*4882a593Smuzhiyun+#include <bits/setjmp.h>		/* Get `__jmp_buf'.  */
89*4882a593Smuzhiyun+#include <bits/types/__sigset_t.h>
90*4882a593Smuzhiyun+
91*4882a593Smuzhiyun+/* Calling environment, plus possibly a saved signal mask.  */
92*4882a593Smuzhiyun+struct __jmp_buf_tag
93*4882a593Smuzhiyun+  {
94*4882a593Smuzhiyun+    /* NOTE: The machine-dependent definitions of `__sigsetjmp'
95*4882a593Smuzhiyun+       assume that a `jmp_buf' begins with a `__jmp_buf' and that
96*4882a593Smuzhiyun+       `__mask_was_saved' follows it.  Do not move these members
97*4882a593Smuzhiyun+       or add others before it.  */
98*4882a593Smuzhiyun+    __jmp_buf __jmpbuf;		/* Calling environment.  */
99*4882a593Smuzhiyun+    int __mask_was_saved;	/* Saved the signal mask?  */
100*4882a593Smuzhiyun+    __sigset_t __saved_mask;	/* Saved signal mask.  */
101*4882a593Smuzhiyun+  };
102*4882a593Smuzhiyun+
103*4882a593Smuzhiyun+#endif
104*4882a593Smuzhiyundiff --git a/setjmp/setjmp.h b/setjmp/setjmp.h
105*4882a593Smuzhiyunindex 1a244c4c..b6c7664b 100644
106*4882a593Smuzhiyun--- a/setjmp/setjmp.h
107*4882a593Smuzhiyun+++ b/setjmp/setjmp.h
108*4882a593Smuzhiyun@@ -27,20 +27,7 @@
109*4882a593Smuzhiyun __BEGIN_DECLS
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun #include <bits/setjmp.h>		/* Get `__jmp_buf'.  */
112*4882a593Smuzhiyun-#include <bits/types/__sigset_t.h>
113*4882a593Smuzhiyun-
114*4882a593Smuzhiyun-/* Calling environment, plus possibly a saved signal mask.  */
115*4882a593Smuzhiyun-struct __jmp_buf_tag
116*4882a593Smuzhiyun-  {
117*4882a593Smuzhiyun-    /* NOTE: The machine-dependent definitions of `__sigsetjmp'
118*4882a593Smuzhiyun-       assume that a `jmp_buf' begins with a `__jmp_buf' and that
119*4882a593Smuzhiyun-       `__mask_was_saved' follows it.  Do not move these members
120*4882a593Smuzhiyun-       or add others before it.  */
121*4882a593Smuzhiyun-    __jmp_buf __jmpbuf;		/* Calling environment.  */
122*4882a593Smuzhiyun-    int __mask_was_saved;	/* Saved the signal mask?  */
123*4882a593Smuzhiyun-    __sigset_t __saved_mask;	/* Saved signal mask.  */
124*4882a593Smuzhiyun-  };
125*4882a593Smuzhiyun-
126*4882a593Smuzhiyun+#include <bits/types/struct___jmp_buf_tag.h>
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun typedef struct __jmp_buf_tag jmp_buf[1];
129*4882a593Smuzhiyun
130*4882a593Smuzhiyundiff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
131*4882a593Smuzhiyunindex df049abf..5b35f5fc 100644
132*4882a593Smuzhiyun--- a/sysdeps/nptl/pthread.h
133*4882a593Smuzhiyun+++ b/sysdeps/nptl/pthread.h
134*4882a593Smuzhiyun@@ -27,6 +27,7 @@
135*4882a593Smuzhiyun #include <bits/setjmp.h>
136*4882a593Smuzhiyun #include <bits/wordsize.h>
137*4882a593Smuzhiyun #include <bits/types/struct_timespec.h>
138*4882a593Smuzhiyun+#include <bits/types/struct___jmp_buf_tag.h>
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun /* Detach state.  */
142*4882a593Smuzhiyun@@ -740,8 +741,8 @@ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
143*4882a593Smuzhiyun #endif
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun /* Function used in the macros.  */
146*4882a593Smuzhiyun-struct __jmp_buf_tag;
147*4882a593Smuzhiyun-extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
148*4882a593Smuzhiyun+extern int __sigsetjmp (struct __jmp_buf_tag __env[1],
149*4882a593Smuzhiyun+			int __savemask) __THROWNL;
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun /* Mutex handling.  */
153*4882a593Smuzhiyun--
154*4882a593Smuzhiyun2.20.1
155*4882a593Smuzhiyun
156