hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
From 19e311cc1dac23c9d072bce3cbca148e90e797eb Mon Sep 17 00:00:00 2001
From: Joseph Myers <joseph@codesourcery.com>
Date: Mon, 5 Oct 2020 16:46:46 +0000
Subject: [PATCH 04/19] Fix GCC 11 -Warray-parameter warning for __sigsetjmp
 (bug 26647)
 
This patch fixes part of bug 26647 (-Werror=array-parameter error
building with GCC 11 because of __sigsetjmp being declared using an
array parameter in one header and a pointer parameter in another).
 
The fix is to split the struct __jmp_buf_tag definition out to a
separate bits/types/ header so it can be included in pthread.h, so
that pthread.h can declare __sigsetjmp with the type contents visible,
so can use an array (as in setjmp.h) rather than a pointer in the
declaration.
 
Note that several other build failures with GCC 11 remain.  This does
not fix the jmp_buf-related -Wstringop-overflow errors (also discussed
in bug 26647), or -Warray-parameter errors for other functions (bug
26686), or -Warray-bounds errors (bug 26687).
 
Tested, with older compilers, natively for x86_64 and with
build-many-glibc.py for aarch64-linux-gnu.  Tested with
build-many-glibcs.py with GCC mainline for aarch64-linux-gnu that this
gets past the -Warray-parameter issue for __sigsetjmp (with the next
build failure being the other one discussed in bug 26647).
 
(cherry picked from commit 19302b27bdacfe87e861ff46fc0fbad60dd6602d)
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 include/bits/types/struct___jmp_buf_tag.h |  1 +
 setjmp/Makefile                           |  3 +-
 setjmp/bits/types/struct___jmp_buf_tag.h  | 37 +++++++++++++++++++++++
 setjmp/setjmp.h                           | 15 +--------
 sysdeps/nptl/pthread.h                    |  5 +--
 5 files changed, 44 insertions(+), 17 deletions(-)
 create mode 100644 include/bits/types/struct___jmp_buf_tag.h
 create mode 100644 setjmp/bits/types/struct___jmp_buf_tag.h
 
diff --git a/include/bits/types/struct___jmp_buf_tag.h b/include/bits/types/struct___jmp_buf_tag.h
new file mode 100644
index 00000000..e3250150
--- /dev/null
+++ b/include/bits/types/struct___jmp_buf_tag.h
@@ -0,0 +1 @@
+#include <setjmp/bits/types/struct___jmp_buf_tag.h>
diff --git a/setjmp/Makefile b/setjmp/Makefile
index 2eea8355..ec6b66a8 100644
--- a/setjmp/Makefile
+++ b/setjmp/Makefile
@@ -22,7 +22,8 @@ subdir    := setjmp
 
 include ../Makeconfig
 
-headers    := setjmp.h bits/setjmp.h bits/setjmp2.h
+headers    := setjmp.h bits/setjmp.h bits/setjmp2.h \
+       bits/types/struct___jmp_buf_tag.h
 
 routines    := setjmp sigjmp bsd-setjmp bsd-_setjmp \
            longjmp __longjmp jmp-unwind
diff --git a/setjmp/bits/types/struct___jmp_buf_tag.h b/setjmp/bits/types/struct___jmp_buf_tag.h
new file mode 100644
index 00000000..9d8634f1
--- /dev/null
+++ b/setjmp/bits/types/struct___jmp_buf_tag.h
@@ -0,0 +1,37 @@
+/* Define struct __jmp_buf_tag.
+   Copyright (C) 1991-2020 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    __jmp_buf_tag_defined
+#define    __jmp_buf_tag_defined 1
+
+#include <bits/setjmp.h>        /* Get `__jmp_buf'.  */
+#include <bits/types/__sigset_t.h>
+
+/* Calling environment, plus possibly a saved signal mask.  */
+struct __jmp_buf_tag
+  {
+    /* NOTE: The machine-dependent definitions of `__sigsetjmp'
+       assume that a `jmp_buf' begins with a `__jmp_buf' and that
+       `__mask_was_saved' follows it.  Do not move these members
+       or add others before it.  */
+    __jmp_buf __jmpbuf;        /* Calling environment.  */
+    int __mask_was_saved;    /* Saved the signal mask?  */
+    __sigset_t __saved_mask;    /* Saved signal mask.  */
+  };
+
+#endif
diff --git a/setjmp/setjmp.h b/setjmp/setjmp.h
index 3d09c98c..351f9461 100644
--- a/setjmp/setjmp.h
+++ b/setjmp/setjmp.h
@@ -27,20 +27,7 @@
 __BEGIN_DECLS
 
 #include <bits/setjmp.h>        /* Get `__jmp_buf'.  */
-#include <bits/types/__sigset_t.h>
-
-/* Calling environment, plus possibly a saved signal mask.  */
-struct __jmp_buf_tag
-  {
-    /* NOTE: The machine-dependent definitions of `__sigsetjmp'
-       assume that a `jmp_buf' begins with a `__jmp_buf' and that
-       `__mask_was_saved' follows it.  Do not move these members
-       or add others before it.  */
-    __jmp_buf __jmpbuf;        /* Calling environment.  */
-    int __mask_was_saved;    /* Saved the signal mask?  */
-    __sigset_t __saved_mask;    /* Saved signal mask.  */
-  };
-
+#include <bits/types/struct___jmp_buf_tag.h>
 
 typedef struct __jmp_buf_tag jmp_buf[1];
 
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index 704a3c48..579e9168 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -27,6 +27,7 @@
 #include <bits/setjmp.h>
 #include <bits/wordsize.h>
 #include <bits/types/struct_timespec.h>
+#include <bits/types/struct___jmp_buf_tag.h>
 
 
 /* Detach state.  */
@@ -740,8 +741,8 @@ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
 #endif
 
 /* Function used in the macros.  */
-struct __jmp_buf_tag;
-extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
+extern int __sigsetjmp (struct __jmp_buf_tag __env[1],
+            int __savemask) __THROWNL;
 
 
 /* Mutex handling.  */
-- 
2.20.1