1From 79f93ac5cb91cd9cbb02b503dcf428880f2cddf1 Mon Sep 17 00:00:00 2001 2From: Joseph Myers <joseph@codesourcery.com> 3Date: Mon, 5 Oct 2020 16:46:46 +0000 4Subject: [PATCH 04/20] Fix GCC 11 -Warray-parameter warning for __sigsetjmp 5 (bug 26647) 6 7This patch fixes part of bug 26647 (-Werror=array-parameter error 8building with GCC 11 because of __sigsetjmp being declared using an 9array parameter in one header and a pointer parameter in another). 10 11The fix is to split the struct __jmp_buf_tag definition out to a 12separate bits/types/ header so it can be included in pthread.h, so 13that pthread.h can declare __sigsetjmp with the type contents visible, 14so can use an array (as in setjmp.h) rather than a pointer in the 15declaration. 16 17Note that several other build failures with GCC 11 remain. This does 18not fix the jmp_buf-related -Wstringop-overflow errors (also discussed 19in bug 26647), or -Warray-parameter errors for other functions (bug 2026686), or -Warray-bounds errors (bug 26687). 21 22Tested, with older compilers, natively for x86_64 and with 23build-many-glibc.py for aarch64-linux-gnu. Tested with 24build-many-glibcs.py with GCC mainline for aarch64-linux-gnu that this 25gets past the -Warray-parameter issue for __sigsetjmp (with the next 26build failure being the other one discussed in bug 26647). 27 28(cherry picked from commit 19302b27bdacfe87e861ff46fc0fbad60dd6602d) 29Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 30--- 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 39 40diff --git a/include/bits/types/struct___jmp_buf_tag.h b/include/bits/types/struct___jmp_buf_tag.h 41new file mode 100644 42index 00000000..e3250150 43--- /dev/null 44+++ b/include/bits/types/struct___jmp_buf_tag.h 45@@ -0,0 +1 @@ 46+#include <setjmp/bits/types/struct___jmp_buf_tag.h> 47diff --git a/setjmp/Makefile b/setjmp/Makefile 48index dc2fcc62..f4da258b 100644 49--- a/setjmp/Makefile 50+++ b/setjmp/Makefile 51@@ -22,7 +22,8 @@ subdir := setjmp 52 53 include ../Makeconfig 54 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 58 59 routines := setjmp sigjmp bsd-setjmp bsd-_setjmp \ 60 longjmp __longjmp jmp-unwind 61diff --git a/setjmp/bits/types/struct___jmp_buf_tag.h b/setjmp/bits/types/struct___jmp_buf_tag.h 62new file mode 100644 63index 00000000..9d8634f1 64--- /dev/null 65+++ b/setjmp/bits/types/struct___jmp_buf_tag.h 66@@ -0,0 +1,37 @@ 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. 70+ 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. 75+ 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. 80+ 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/>. */ 84+ 85+#ifndef __jmp_buf_tag_defined 86+#define __jmp_buf_tag_defined 1 87+ 88+#include <bits/setjmp.h> /* Get `__jmp_buf'. */ 89+#include <bits/types/__sigset_t.h> 90+ 91+/* Calling environment, plus possibly a saved signal mask. */ 92+struct __jmp_buf_tag 93+ { 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. */ 101+ }; 102+ 103+#endif 104diff --git a/setjmp/setjmp.h b/setjmp/setjmp.h 105index 1a244c4c..b6c7664b 100644 106--- a/setjmp/setjmp.h 107+++ b/setjmp/setjmp.h 108@@ -27,20 +27,7 @@ 109 __BEGIN_DECLS 110 111 #include <bits/setjmp.h> /* Get `__jmp_buf'. */ 112-#include <bits/types/__sigset_t.h> 113- 114-/* Calling environment, plus possibly a saved signal mask. */ 115-struct __jmp_buf_tag 116- { 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. */ 124- }; 125- 126+#include <bits/types/struct___jmp_buf_tag.h> 127 128 typedef struct __jmp_buf_tag jmp_buf[1]; 129 130diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h 131index df049abf..5b35f5fc 100644 132--- a/sysdeps/nptl/pthread.h 133+++ b/sysdeps/nptl/pthread.h 134@@ -27,6 +27,7 @@ 135 #include <bits/setjmp.h> 136 #include <bits/wordsize.h> 137 #include <bits/types/struct_timespec.h> 138+#include <bits/types/struct___jmp_buf_tag.h> 139 140 141 /* Detach state. */ 142@@ -740,8 +741,8 @@ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) 143 #endif 144 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; 150 151 152 /* Mutex handling. */ 153-- 1542.20.1 155 156