From patchwork Thu Oct 1 22:47:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 40630 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70C22398B8B5; Thu, 1 Oct 2020 22:47:46 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 142C8398B885 for ; Thu, 1 Oct 2020 22:47:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 142C8398B885 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: 5Gi+rI/rz3cnKBnQ2EmI2W1ZkQQsQRNBajExCzFiz44g/Ttih8gR6fMXrczuUf3Nh9KTDA1P6q +WqWomFDZZKpwZPOWgI1/iRco4Tqu+TY7BL8d9WOtkeOTW8L7K2HPHezM3mV2PDEaKSGqtGYsb gz2yyYBHwNzaOFYzlyh60tpPpKTrdqW92y/v2cWaNmupTjbIYbiiSrJql8H7f62nv5dj93kHja GpIjydNApsBkFAoMMKI/JTAgGVe1bpTg2iQhTHY8zQNqWZdbP9++8MdB+b6+GFI9/mvsewoa9c ywM= X-IronPort-AV: E=Sophos;i="5.77,325,1596528000"; d="scan'208";a="53485741" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 01 Oct 2020 14:47:42 -0800 IronPort-SDR: piqcsGUezrUKHr+6J5ak/jZe5IZzTsiblHUkCPT+/WgRavC7JP1WuhL54BZzRW+K8HLa+7jgT4 5N0lHXmadq+AV4ZbgPIA9Pe9Vmk51gbkcBieP6JRS13p/eOO0UkgC/09LL1u8P26afQGg0ICtX w4kx+6xZfMQNYa5JkF+Td73ByNOeebpaN17yiOvZau+a08E+dKMd5bCPqZ370v4BmqgOek0kOv 56E4pSMOsMrxHCzRCPZDuzHZdcum6eQ7IKNGgg6aUn9qf5s6S6/i04v0UmTHb3Lv52cZbrvYID /TE= Date: Thu, 1 Oct 2020 22:47:37 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Subject: Fix GCC 11 -Warray-parameter warning for __sigsetjmp (bug 26647) Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3131.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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). Reviewed-by: Adhemerval Zanella 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 0000000000..e3250150da --- /dev/null +++ b/include/bits/types/struct___jmp_buf_tag.h @@ -0,0 +1 @@ +#include diff --git a/setjmp/Makefile b/setjmp/Makefile index dcac56932d..603f61d76e 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 0000000000..9d8634f1e4 --- /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 + . */ + +#ifndef __jmp_buf_tag_defined +#define __jmp_buf_tag_defined 1 + +#include /* Get `__jmp_buf'. */ +#include + +/* 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 4e3443c37e..c6c59f4094 100644 --- a/setjmp/setjmp.h +++ b/setjmp/setjmp.h @@ -27,20 +27,7 @@ __BEGIN_DECLS #include /* Get `__jmp_buf'. */ -#include - -/* 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 typedef struct __jmp_buf_tag jmp_buf[1]; diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h index 8a403cbf36..d4194da776 100644 --- a/sysdeps/nptl/pthread.h +++ b/sysdeps/nptl/pthread.h @@ -28,6 +28,7 @@ #include #include #include +#include /* Detach state. */ @@ -730,8 +731,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. */