| Message ID | 20250930144920.1023532-2-joel@rtems.org |
|---|---|
| State | New |
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> 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 5104D385843D for <patchwork@sourceware.org>; Tue, 30 Sep 2025 14:51:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5104D385843D X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by sourceware.org (Postfix) with ESMTPS id 5A39E385843D for <newlib@sourceware.org>; Tue, 30 Sep 2025 14:49:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A39E385843D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5A39E385843D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.180 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759243798; cv=none; b=oG81FobwiC3hj5fEkWfTfkAhvHAJnIov0806jZnGuqDJZQRZJjsvhab9Fz4q76vMEsBfuccNxX07junH1/sZm1/MIRIBccaG73vtkEh1GaGY6dIeqCTtQTGarngkopOWgleuzEEI5UEgkn1rq7BP6w53nmPvXoqduazpdZ0H8uA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1759243798; c=relaxed/simple; bh=PA1cNcTP1+h/dY4PyYqUt2iL7M8WmVAC+bEszMD2cWU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=oBYOq9SxR41nwHKBuevYtf3lE+A05Wwv+XTYiQR1/HXh5XWg9zxw/DxBQTR+mApuL/3npJRdfOIaciPC0Yyfd8ZcXVQiI9FoU3vfL9EA6M7xVKyYaqVE2hS+ZkHCJEhfutYRcxMptH7/KPoaRGMc9i2a46KkeMrXSCa1yI6Dx5U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A39E385843D Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-743ba48eb71so86337997b3.1 for <newlib@sourceware.org>; Tue, 30 Sep 2025 07:49:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759243797; x=1759848597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5FZw4e/HRtH5bbePIqN1w2EiNEuMCMglSF1Sead8Of0=; b=gATB85iLqjIygP5ZFJMJ41GcuGmMfvQykbJcY5u/5hfTB36Evj68HzjzJMqaO4+ct0 pfZMtEp2uZpUK54n8CzpmbVM/nTFpWNgY02shf4YI3x+1YmKKrxx0VIjd0zyfMCz59JM R4IUAm40Yn/8gv3DkHdc57OC0yaMsKfyPz8+S9FnicZow1ROMRdkNM7DMTHJw+aP0FvP O9n+drL2iKvvCQaWf7EegyeLL8Kisq+D1IgeiJXjWiAQkNRi3+C2EF9uc0YskRu3NpYk ZPrRCAEcTAH9fhYaEHPetziUdqYWCrja53pv2zL7LZm+ProKPFIl4X86fJzQ21Um1NYo pAsg== X-Gm-Message-State: AOJu0YxZB5qZmX8DhspxTEN+tB3YjiGV1pW6hxVZbbS7Wt+WBpbOd/dg oZxTCxMpxIBqycKEOKQU3FuIY6KAyOvNm2Zyoy0EIETAO926jEQluMf/Z+s72A== X-Gm-Gg: ASbGncvRVKURVJmnBuvru2RHrIaCbVmu+Tp1LIvSh37K0VDROsRe00CXphcl44g+C1O //hOmNk38Ljt51gIX06rnxSkyQ1kHKQchpqE1ug7jlLrHFR3d7w3OOvj5I8P4Xu4BBZp9aqDaOG voUQO5wyj5kYvqJ3WdgDF14rVfsdEXjJmCWoWEHUPfKXM4+55elq09CFrLONmO1Q9SbuDa9LFap 9XPeLSEv5ft1S7ZVYRTUR1+Jy9fJb2y1aY7hkz9hhbECHF4z/SyBDSRSVT48p597X3ufvD1VWPj 92jGTYcreTs1OeG5IRPezntAo3dLGNqCT06s8m9oKtFlC4alarbO8Cq4be9S8uGKloyu/dmE/3w lMGROCbUASZ8VTlFOGuVsBPwUymCuSQDTvIgP7AiT7hT8uFB4+eWhqtKTi82tpfWc2TdqvUkVyF lRDhR+khsE7AhJzAEIxPd5 X-Google-Smtp-Source: AGHT+IFYGuLZ6DYCyct8a0wwhnuLCWY7vZWsOOOknMC2WZA3JmpKX1KdOV6SoEseuqA/R61AY8oVwQ== X-Received: by 2002:a53:b74e:0:b0:637:cde3:c6f6 with SMTP id 956f58d0204a3-63b6ff0b3b0mr161740d50.10.1759243796572; Tue, 30 Sep 2025 07:49:56 -0700 (PDT) Received: from gitlab.oarcorp.com (d27-96-189-151.evv.wideopenwest.com. [96.27.151.189]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-636d5b1d881sm3509105d50.19.2025.09.30.07.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Sep 2025 07:49:56 -0700 (PDT) From: Joel Sherrill <joel@rtems.org> To: newlib@sourceware.org Cc: Joel Sherrill <joel@rtems.org> Subject: [PATCH 1/1] newlib/libc/include/setjmp.h: Add returns_twice attribute to setjmp() Date: Tue, 30 Sep 2025 09:49:19 -0500 Message-ID: <20250930144920.1023532-2-joel@rtems.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250930144920.1023532-1-joel@rtems.org> References: <20250930144920.1023532-1-joel@rtems.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3037.3 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
Add returns_twice attribute to setjmp()
|
|
Commit Message
Joel Sherrill
Sept. 30, 2025, 2:49 p.m. UTC
The setjmp() function needs this attribute to help GCC avoid false positives for the -Wclobbered warning. The -Wclobbered warning is part of -Wextra. --- newlib/libc/include/setjmp.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Comments
Hi Joel, On 2025-09-30 16:49, Joel Sherrill wrote: > The setjmp() function needs this attribute to help GCC avoid false > positives for the -Wclobbered warning. The -Wclobbered warning is > part of -Wextra. > --- > newlib/libc/include/setjmp.h | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h > index a2830b275..5c16321a4 100644 > --- a/newlib/libc/include/setjmp.h > +++ b/newlib/libc/include/setjmp.h > @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) > #else > void longjmp (jmp_buf __jmpb, int __retval); > #endif > -int setjmp (jmp_buf __jmpb); > + > +#ifdef __GNUC__ > +int setjmp (jmp_buf __jmpb) > + __attribute__ ((returns_twice));; I suppose you only want a single semi-colon here. > +#else I think you should also drop the empty "#else" block. Kind regards, Torbjörn > +#endif > > _END_STD_C >
On 2025-10-01 01:22, Torbjorn SVENSSON wrote: > On 2025-09-30 16:49, Joel Sherrill wrote: >> The setjmp() function needs this attribute to help GCC avoid false >> positives for the -Wclobbered warning. The -Wclobbered warning is >> part of -Wextra. >> --- >> newlib/libc/include/setjmp.h | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h >> index a2830b275..5c16321a4 100644 >> --- a/newlib/libc/include/setjmp.h >> +++ b/newlib/libc/include/setjmp.h >> @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) >> #else >> void longjmp (jmp_buf __jmpb, int __retval); >> #endif >> -int setjmp (jmp_buf __jmpb); >> + >> +#ifdef __GNUC__ >> +int setjmp (jmp_buf __jmpb) >> + __attribute__ ((returns_twice));; > I suppose you only want a single semi-colon here. >> +#else > I think you should also drop the empty "#else" block. >> +#endif >> _END_STD_C Shouldn't the conditional be around the attribute only? -int setjmp (jmp_buf __jmpb); +int setjmp (jmp_buf __jmpb) +#ifdef __GNUC__ + __attribute__ ((returns_twice)) +#endif + ;
On Wed, Oct 1, 2025 at 2:23 AM Torbjorn SVENSSON < torbjorn.svensson@foss.st.com> wrote: > Hi Joel, > > On 2025-09-30 16:49, Joel Sherrill wrote: > > The setjmp() function needs this attribute to help GCC avoid false > > positives for the -Wclobbered warning. The -Wclobbered warning is > > part of -Wextra. > > --- > > newlib/libc/include/setjmp.h | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h > > index a2830b275..5c16321a4 100644 > > --- a/newlib/libc/include/setjmp.h > > +++ b/newlib/libc/include/setjmp.h > > @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) > > #else > > void longjmp (jmp_buf __jmpb, int __retval); > > #endif > > -int setjmp (jmp_buf __jmpb); > > + > > +#ifdef __GNUC__ > > +int setjmp (jmp_buf __jmpb) > > + __attribute__ ((returns_twice));; > > I suppose you only want a single semi-colon here. > Yes. Thanks. > > > +#else > > I think you should also drop the empty "#else" block. > It was supposed to have a setjmp() prototype without the attribute. This is following the pattern above with longjmp() which has it this way. v2 will fix these. --joel > > Kind regards, > Torbjörn > > > +#endif > > > > _END_STD_C > > > >
On Wed, Oct 1, 2025 at 4:03 AM Brian Inglis <Brian.Inglis@systematicsw.ab.ca> wrote: > On 2025-10-01 01:22, Torbjorn SVENSSON wrote: > > On 2025-09-30 16:49, Joel Sherrill wrote: > >> The setjmp() function needs this attribute to help GCC avoid false > >> positives for the -Wclobbered warning. The -Wclobbered warning is > >> part of -Wextra. > >> --- > >> newlib/libc/include/setjmp.h | 7 ++++++- > >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h > >> index a2830b275..5c16321a4 100644 > >> --- a/newlib/libc/include/setjmp.h > >> +++ b/newlib/libc/include/setjmp.h > >> @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) > >> #else > >> void longjmp (jmp_buf __jmpb, int __retval); > >> #endif > >> -int setjmp (jmp_buf __jmpb); > >> + > >> +#ifdef __GNUC__ > >> +int setjmp (jmp_buf __jmpb) > >> + __attribute__ ((returns_twice));; > > I suppose you only want a single semi-colon here. > >> +#else > > I think you should also drop the empty "#else" block. > >> +#endif > >> _END_STD_C > > Shouldn't the conditional be around the attribute only? > That's not the way setjmp() was. It has this (tabs lost with copy and paste): #ifdef __GNUC__ void longjmp (jmp_buf __jmpb, int __retval) __attribute__ ((__noreturn__)); #else void longjmp (jmp_buf __jmpb, int __retval); #endif I just copied the style of what was there. > > -int setjmp (jmp_buf __jmpb); > +int setjmp (jmp_buf __jmpb) > +#ifdef __GNUC__ > + __attribute__ ((returns_twice)) > +#endif > + ; > > Do you want longjmp() changed to match this also? --joel > -- > Take care. Thanks, Brian Inglis Calgary, Alberta, Canada > > La perfection est atteinte Perfection is achieved > non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to > add > mais lorsqu'il n'y a plus rien à retrancher but when there is no more to > cut > -- Antoine de Saint-Exupéry >
On 01/10/2025 08:22, Torbjorn SVENSSON wrote: > Hi Joel, > > On 2025-09-30 16:49, Joel Sherrill wrote: >> The setjmp() function needs this attribute to help GCC avoid false >> positives for the -Wclobbered warning. The -Wclobbered warning is >> part of -Wextra. >> --- >> newlib/libc/include/setjmp.h | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h >> index a2830b275..5c16321a4 100644 >> --- a/newlib/libc/include/setjmp.h >> +++ b/newlib/libc/include/setjmp.h >> @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) >> #else >> void longjmp (jmp_buf __jmpb, int __retval); >> #endif >> -int setjmp (jmp_buf __jmpb); >> + >> +#ifdef __GNUC__ >> +int setjmp (jmp_buf __jmpb) >> + __attribute__ ((returns_twice));; > > I suppose you only want a single semi-colon here. > >> +#else > > I think you should also drop the empty "#else" block. > > Kind regards, > Torbjörn > >> +#endif >> _END_STD_C >> > ansidecl.h provides some infrastructure to handle all this. Wouldn't it be better to follow that model? In particular you can then arrange for your macro to check the actual GCC version. R.
On 2025-10-02 07:57, Joel Sherrill wrote: > > > On Wed, Oct 1, 2025 at 4:03 AM Brian Inglis <Brian.Inglis@systematicsw.ab.ca > <mailto:Brian.Inglis@systematicsw.ab.ca>> wrote: > > On 2025-10-01 01:22, Torbjorn SVENSSON wrote: > > On 2025-09-30 16:49, Joel Sherrill wrote: > >> The setjmp() function needs this attribute to help GCC avoid false > >> positives for the -Wclobbered warning. The -Wclobbered warning is > >> part of -Wextra. > >> --- > >> newlib/libc/include/setjmp.h | 7 ++++++- > >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h > >> index a2830b275..5c16321a4 100644 > >> --- a/newlib/libc/include/setjmp.h > >> +++ b/newlib/libc/include/setjmp.h > >> @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) > >> #else > >> void longjmp (jmp_buf __jmpb, int __retval); > >> #endif > >> -int setjmp (jmp_buf __jmpb); > >> + > >> +#ifdef __GNUC__ > >> +int setjmp (jmp_buf __jmpb) > >> + __attribute__ ((returns_twice));; > > I suppose you only want a single semi-colon here. > >> +#else > > I think you should also drop the empty "#else" block. > >> +#endif > >> _END_STD_C > > Shouldn't the conditional be around the attribute only? > > > That's not the way setjmp() was. It has this (tabs lost with copy and paste): > > #ifdef __GNUC__ > void longjmp (jmp_buf __jmpb, int __retval) > __attribute__ ((__noreturn__)); > #else > void longjmp (jmp_buf __jmpb, int __retval); > #endif > > I just copied the style of what was there. > > > -int setjmp (jmp_buf __jmpb); > +int setjmp (jmp_buf __jmpb) > +#ifdef __GNUC__ > + __attribute__ ((returns_twice)) > +#endif > + ; > > > Do you want longjmp() changed to match this also? Your choice - it's just a matter of style: Cygwin tweaks do this a lot, leaving as much of the existing code alone as possible, avoiding duplication and having to check for changes in two lines if something changes, especially if derived from an upstream original.
diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h index a2830b275..5c16321a4 100644 --- a/newlib/libc/include/setjmp.h +++ b/newlib/libc/include/setjmp.h @@ -17,7 +17,12 @@ void longjmp (jmp_buf __jmpb, int __retval) #else void longjmp (jmp_buf __jmpb, int __retval); #endif -int setjmp (jmp_buf __jmpb); + +#ifdef __GNUC__ +int setjmp (jmp_buf __jmpb) + __attribute__ ((returns_twice));; +#else +#endif _END_STD_C