From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Add _Noreturn specifier to functions specified as such by ISO C11
Date: Wed, 5 Sep 2012 10:18:24 -0400 [thread overview]
Message-ID: <20120905141824.GS27715@brightrain.aerifal.cx> (raw)
In-Reply-To: <20120905135311.43281a54@gmail.com>
On Wed, Sep 05, 2012 at 01:53:11PM +0200, philomath wrote:
> Since the _Noreturn identifier is not in the user's namespace, we can use it
> directly. in case it's not a keyword (i.e. pre-C11), it is defined as
> __attribute__((__noreturn__)) on GCC (where it is implemented since version
> 2.95), and empty elsewhere.
>
> There are some more interfaces and functions that could make use of this
> specifier, here are only those specified in the C11 standard.
>
> ---
> include/setjmp.h | 10 ++++--
> include/stdlib.h | 15 ++++++---
> src/exit/_Exit.c | 10 +++++-
> src/exit/abort.c | 10 +++++-
> src/exit/exit.c | 10 +++++-
> src/exit/quick_exit.c | 10 +++++-
> 6 files changed, 30 insertions(+), 9 deletions(-)
>
> diff --git a/include/setjmp.h b/include/setjmp.h
> index 7dc7276..6db4786 100644
> --- a/include/setjmp.h
> +++ b/include/setjmp.h
> @@ -27,9 +27,15 @@ int _setjmp (jmp_buf);
> void _longjmp (jmp_buf, int);
> #endif
>
> -
> +#if __STDC_VERSION__ < 201112L
> +# if __GNUC__
> +# define _Noreturn __attribute__((__noreturn__))
> +# else
> +# define _Noreturn
> +# endif
> +#endif
Is there a way you can make the logic work without nested #ifs? If
not, please at least use consistent style (no spaces after #) with the
rest of the headers, but I'd prefer if we could nesting altogether.
Perhaps..
#if __STDC_VERSION__ >= 201112L
#elif defined(__GNUC__)
#define _Noreturn __attribute__((__noreturn__))
#else
#define _Noreturn
#endif
> diff --git a/src/exit/_Exit.c b/src/exit/_Exit.c
> index 6ceb143..ea85e4a 100644
> --- a/src/exit/_Exit.c
> +++ b/src/exit/_Exit.c
> @@ -1,7 +1,15 @@
> #include <stdlib.h>
> #include "syscall.h"
>
> -void _Exit(int ec)
> +#if __STDC_VERSION__ < 201112L
> +# if __GNUC__
> +# define _Noreturn __attribute__((__noreturn__))
> +# else
> +# define _Noreturn
> +# endif
> +#endif
Why is this duplicated in the source files? The headers already
handled it, so _Noreturn is already defined if needed; it can just be
used as if this were always C11 code.
BTW, this brings up the point that we should be checking for support
for -std=c11 or -std=c1x and using those if available, and only
falling back to -std=c99 if not.
Rich
next prev parent reply other threads:[~2012-09-05 14:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 11:53 philomath
2012-09-05 14:18 ` Rich Felker [this message]
2012-09-05 18:02 ` philomath
2012-09-06 3:12 ` Rich Felker
2012-09-06 14:02 ` philomath
2012-09-06 16:19 ` Rich Felker
2012-09-07 1:34 ` Anthony J. Bentley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120905141824.GS27715@brightrain.aerifal.cx \
--to=dalias@aerifal.cx \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).