|
Message-ID: <20120905200235.1a83ec1a@gmail.com> Date: Wed, 5 Sep 2012 20:02:35 +0200 From: philomath <philomath868@...il.com> To: musl@...ts.openwall.com Subject: Re: [PATCH] Add _Noreturn specifier to functions specified as such by ISO C11 Hi, Here is an updated version, addressing the issues rich mentioned. Should I add _Noreturn to other functions too (such as the various a_crash versions, *err*, etc)? --- 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. --- include/setjmp.h | 9 ++++++++- include/stdlib.h | 15 +++++++++++---- src/exit/_Exit.c | 2 +- src/exit/abort.c | 2 +- src/exit/exit.c | 2 +- src/exit/quick_exit.c | 2 +- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/setjmp.h b/include/setjmp.h index 7dc7276..321d859 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -28,8 +28,15 @@ void _longjmp (jmp_buf, int); #endif +#if __STDC_VERSION__ >= 201112L +#elif defined(__GNUC__) +#define _Noreturn __attribute__((__noreturn__)) +#else +#define _Noreturn +#endif + int setjmp (jmp_buf); -void longjmp (jmp_buf, int); +_Noreturn void longjmp (jmp_buf, int); #define setjmp setjmp #define longjmp longjmp diff --git a/include/stdlib.h b/include/stdlib.h index 1749cb3..03dee19 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -40,12 +40,19 @@ void *realloc (void *, size_t); void free (void *); void *aligned_alloc(size_t alignment, size_t size); -void abort (void); +#if __STDC_VERSION__ >= 201112L +#elif defined(__GNUC__) +#define _Noreturn __attribute__((__noreturn__)) +#else +#define _Noreturn +#endif + +_Noreturn void abort (void); int atexit (void (*) (void)); -void exit (int); -void _Exit (int); +_Noreturn void exit (int); +_Noreturn void _Exit (int); int at_quick_exit (void (*) (void)); -void quick_exit (int); +_Noreturn void quick_exit (int); char *getenv (const char *); diff --git a/src/exit/_Exit.c b/src/exit/_Exit.c index 6ceb143..c00a2ff 100644 --- a/src/exit/_Exit.c +++ b/src/exit/_Exit.c @@ -1,7 +1,7 @@ #include <stdlib.h> #include "syscall.h" -void _Exit(int ec) +_Noreturn void _Exit(int ec) { __syscall(SYS_exit_group, ec); __syscall(SYS_exit, ec); diff --git a/src/exit/abort.c b/src/exit/abort.c index c5b9e52..203dd35 100644 --- a/src/exit/abort.c +++ b/src/exit/abort.c @@ -2,7 +2,7 @@ #include <signal.h> #include "syscall.h" -void abort(void) +_Noreturn void abort(void) { raise(SIGABRT); raise(SIGKILL); diff --git a/src/exit/exit.c b/src/exit/exit.c index e4aeaf1..e4932b5 100644 --- a/src/exit/exit.c +++ b/src/exit/exit.c @@ -14,7 +14,7 @@ weak_alias(dummy, __funcs_on_exit); weak_alias(dummy, __flush_on_exit); weak_alias(dummy, __seek_on_exit); -void exit(int code) +_Noreturn void exit(int code) { static int lock; diff --git a/src/exit/quick_exit.c b/src/exit/quick_exit.c index 18d5288..1175d80 100644 --- a/src/exit/quick_exit.c +++ b/src/exit/quick_exit.c @@ -6,7 +6,7 @@ static void dummy() { } weak_alias(dummy, __funcs_on_quick_exit); -void quick_exit(int code) +_Noreturn void quick_exit(int code) { static int lock; while (a_swap(&lock, 1)) __syscall(SYS_pause); -- 1.7.12
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.