From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14231 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Matthew Maurer Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Use __attribute__((noreturn)) for function pointer Date: Fri, 14 Jun 2019 09:50:45 -0700 Message-ID: References: <20190614164738.GI1506@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="00000000000042b7d2058b4b73c5" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="43016"; mail-complaints-to="usenet@blaine.gmane.org" To: musl@lists.openwall.com Original-X-From: musl-return-14247-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jun 14 18:51:12 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hbpPz-000B4r-8L for gllmg-musl@m.gmane.org; Fri, 14 Jun 2019 18:51:11 +0200 Original-Received: (qmail 21604 invoked by uid 550); 14 Jun 2019 16:51:09 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 21579 invoked from network); 14 Jun 2019 16:51:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=sSUCTTvICMYaMw4NKusqQK0cFxdwmyaTBJ+CYJbN/vU=; b=saMVougVAvF1HKEQOfSNSviEpasfo2jEwH2OZ8R4N8botfRVLaV6riT8dOFMBGLP4G zEpNZD2US0X/a2BoH3Bw+oF+RQhrlLFk0r8ZFmoOEWo1UJ0gL5d2/KsWUpmhiDGveoJX 3QG6iVOAvZPNqVQgPWh1Jwy8AOdl827DyL41y52NWXPNunTA3+OE3Eg4aepatNP8fcdH z3AD0QiwtBBNZrVb0pRCXtTwPYOiZz7JIQkz/1CDft8QUriGx6FB3WBjcLtcuxsARLbF v5HmxJ6fewJGMFk7wTaMNVQ5i8p9pYUz0a49ovmovqY9WX9ib58HImX44U3fzIeNTePC PHJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=sSUCTTvICMYaMw4NKusqQK0cFxdwmyaTBJ+CYJbN/vU=; b=q8eVr2g1/MLbaYlcktXFiBjDFycQ8SiuEFiO0ax0NRHq1UFgWDdNr3+mgv3wPG30+G mORsSM9W1n/JUshA+9eqV/mmvYk0WlB+kFEIqjFyZuJiu836z6Hn+XPRY0AOhwnZPSNs wyrmE58dcZhFx9BDZ8QM1widjpYAknYlvNz+CNQ7pQx2w4nTCo0Cx7KDBe5wLsRE1zOm MQ3Th01Opz4iOgtwFKJ63ZfvcRA+cPoyfKfDh8tdRxiX96dSl+LN7t9pxE/VsmLvkcRJ I19TOzEI8HQQuv8UFX73CndBGACy7IR28frOSnwBRWZ86hCdleCuUj9dHLdxZ1PF63C2 5SWw== X-Gm-Message-State: APjAAAV1HbAYNgxvcmAtG9RIGMrn32BvBvXv6e471vwEXjihpNFPpvOs pBLLtX3/DX1FEg3KnFvIPKenFL5KrvmvNHCtixvm5ZYw X-Google-Smtp-Source: APXvYqw6InFQ0tNOzmA1gHskremSPfgYE1eis3JZU9HUSJX71hZETmD2sy6WBFIfHMkIbvUEDto4zV/nZ8/ndEfObaE= X-Received: by 2002:aca:4ad2:: with SMTP id x201mr2506810oia.129.1560531056075; Fri, 14 Jun 2019 09:50:56 -0700 (PDT) In-Reply-To: <20190614164738.GI1506@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:14231 Archived-At: --00000000000042b7d2058b4b73c5 Content-Type: multipart/alternative; boundary="00000000000042b7ce058b4b73c3" --00000000000042b7ce058b4b73c3 Content-Type: text/plain; charset="UTF-8" Done. On Fri, Jun 14, 2019 at 9:47 AM Rich Felker wrote: > On Fri, Jun 14, 2019 at 09:42:09AM -0700, Matthew Maurer wrote: > > _Noreturn doesn't actually exist in C99 - that's a C11ism. Even in C11, > it > > cannot be used on a function pointer type. > > __attribute__((noreturn)) is a GNU C extension (which we're allowed to > use, > > unlike C11), and is allowed to be placed on function pointer types. > > > From adeca3acc1e4c1b727e8524542c201b436ba8a5b Mon Sep 17 00:00:00 2001 > > From: Matthew Maurer > > Date: Thu, 13 Jun 2019 12:33:38 -0700 > > Subject: [PATCH] Use __attribute__((noreturn)) for function pointer > > > > _Noreturn is a C11 construct, and may only be used at the site of a > > function definition. > > __attribute__((noreturn)) is a GNU C extension which may be used on > > function pointers. > > GCC with any standard permits _Noreturn in the position it's used > > (likely because it implements it in terms of attribute noreturn), but > > Clang will reject it for any standard past C11, and warn pre-C11. > > > > Musl is written in C99 with GNU C extensions, so > > __attribute__((noreturn)) is both more correct in that sense and allows > > us to compile with Clang set to higher language standards. > > --- > > src/internal/dynlink.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h > > index cbe0a6fe..d2bf6b41 100644 > > --- a/src/internal/dynlink.h > > +++ b/src/internal/dynlink.h > > @@ -95,7 +95,7 @@ struct fdpic_dummy_loadmap { > > #define DYN_CNT 32 > > > > typedef void (*stage2_func)(unsigned char *, size_t *); > > -typedef _Noreturn void (*stage3_func)(size_t *); > > +typedef __attribute__((noreturn)) void (*stage3_func)(size_t *); > > > > hidden void *__dlsym(void *restrict, const char *restrict, void > *restrict); > > > > -- > > 2.22.0.410.gd8fdbe21b5-goog > > > > Just remove it. There's no sense having nonstandard C here for > something that's completely inconsequential. It wasn't important, and > probably the only reason I wrote it was wrongly thinking the function > pointer type had to match the _Noreturn of the function definition. > > Rich > --00000000000042b7ce058b4b73c3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Done.

On Fri, Jun 14, 2019 at 9:47 AM Rich Felker <dalias@libc.org> wrote:
On Fri, Jun 14, 2019 at 09:42:= 09AM -0700, Matthew Maurer wrote:
> _Noreturn doesn't actually exist in C99 - that's a C11ism. Eve= n in C11, it
> cannot be used on a function pointer type.
> __attribute__((noreturn)) is a GNU C extension (which we're allowe= d to use,
> unlike C11), and is allowed to be placed on function pointer types.
> From adeca3acc1e4c1b727e8524542c201b436ba8a5b Mon Sep 17 00:00:00 2001=
> From: Matthew Maurer <mmaurer@google.com>
> Date: Thu, 13 Jun 2019 12:33:38 -0700
> Subject: [PATCH] Use __attribute__((noreturn)) for function pointer >
> _Noreturn is a C11 construct, and may only be used at the site of a > function definition.
> __attribute__((noreturn)) is a GNU C extension which may be used on > function pointers.
> GCC with any standard permits _Noreturn in the position it's used<= br> > (likely because it implements it in terms of attribute noreturn), but<= br> > Clang will reject it for any standard past C11, and warn pre-C11.
>
> Musl is written in C99 with GNU C extensions, so
> __attribute__((noreturn)) is both more correct in that sense and allow= s
> us to compile with Clang set to higher language standards.
> ---
>=C2=A0 src/internal/dynlink.h | 2 +-
>=C2=A0 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/internal/dynlink.h b/src/internal/dynlink.h
> index cbe0a6fe..d2bf6b41 100644
> --- a/src/internal/dynlink.h
> +++ b/src/internal/dynlink.h
> @@ -95,7 +95,7 @@ struct fdpic_dummy_loadmap {
>=C2=A0 #define DYN_CNT 32
>=C2=A0
>=C2=A0 typedef void (*stage2_func)(unsigned char *, size_t *);
> -typedef _Noreturn void (*stage3_func)(size_t *);
> +typedef __attribute__((noreturn)) void (*stage3_func)(size_t *);
>=C2=A0
>=C2=A0 hidden void *__dlsym(void *restrict, const char *restrict, void = *restrict);
>=C2=A0
> --
> 2.22.0.410.gd8fdbe21b5-goog
>

Just remove it. There's no sense having nonstandard C here for
something that's completely inconsequential. It wasn't important, a= nd
probably the only reason I wrote it was wrongly thinking the function
pointer type had to match the _Noreturn of the function definition.

Rich
--00000000000042b7ce058b4b73c3-- --00000000000042b7d2058b4b73c5 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Do-not-use-_Noreturn-for-a-function-pointer.patch" Content-Disposition: attachment; filename="0001-Do-not-use-_Noreturn-for-a-function-pointer.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jwwbw1kk0 RnJvbSBmMzFlMDY0ZTdiMjE3NWU1YTIwNTUyYjZiMmE2MjdmNTQxMWQ5YjlmIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNYXR0aGV3IE1hdXJlciA8bW1hdXJlckBnb29nbGUuY29tPgpE YXRlOiBUaHUsIDEzIEp1biAyMDE5IDEyOjMzOjM4IC0wNzAwClN1YmplY3Q6IFtQQVRDSF0gRG8g bm90IHVzZSBfTm9yZXR1cm4gZm9yIGEgZnVuY3Rpb24gcG9pbnRlcgoKX05vcmV0dXJuIGlzIGEg QzExIGNvbnN0cnVjdCwgYW5kIG1heSBvbmx5IGJlIHVzZWQgYXQgdGhlIHNpdGUgb2YgYQpmdW5j dGlvbiBkZWZpbml0aW9uLgotLS0KIHNyYy9pbnRlcm5hbC9keW5saW5rLmggfCAyICstCiAxIGZp bGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDEgZGVsZXRpb24oLSkKCmRpZmYgLS1naXQgYS9z cmMvaW50ZXJuYWwvZHlubGluay5oIGIvc3JjL2ludGVybmFsL2R5bmxpbmsuaAppbmRleCBjYmUw YTZmZS4uMTY1YmJlZGIgMTAwNjQ0Ci0tLSBhL3NyYy9pbnRlcm5hbC9keW5saW5rLmgKKysrIGIv c3JjL2ludGVybmFsL2R5bmxpbmsuaApAQCAtOTUsNyArOTUsNyBAQCBzdHJ1Y3QgZmRwaWNfZHVt bXlfbG9hZG1hcCB7CiAjZGVmaW5lIERZTl9DTlQgMzIKIAogdHlwZWRlZiB2b2lkICgqc3RhZ2Uy X2Z1bmMpKHVuc2lnbmVkIGNoYXIgKiwgc2l6ZV90ICopOwotdHlwZWRlZiBfTm9yZXR1cm4gdm9p ZCAoKnN0YWdlM19mdW5jKShzaXplX3QgKik7Cit0eXBlZGVmIHZvaWQgKCpzdGFnZTNfZnVuYyko c2l6ZV90ICopOwogCiBoaWRkZW4gdm9pZCAqX19kbHN5bSh2b2lkICpyZXN0cmljdCwgY29uc3Qg Y2hhciAqcmVzdHJpY3QsIHZvaWQgKnJlc3RyaWN0KTsKIAotLSAKMi4yMi4wLjQxMC5nZDhmZGJl MjFiNS1nb29nCgo= --00000000000042b7d2058b4b73c5--