From 0a31efe016d28d5f3bee6c24591831149d760650 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Wed, 7 Dec 2011 15:25:48 +0000 Subject: Implement quick_exit() / at_quick_exit() from C++11 / C1x. Also add a __noreturn macro and modify the other exiting functions to use it. The __noreturn macro, unlike __dead2, must be used BEFORE the function. This is in line with the C and C++ specifications that place _Noreturn (c1x) and [[noreturn]] (C++11) in front of the functions. As with __dead2, this macro falls back to using the GCC attribute. Unfortunately, clang currently sets the same value for the C version macro in C99 and C1x modes, so these functions are hidden by default. At some point before 10.0, I need to go through the headers and clean up the C1x / C++11 visibility. Reviewed by: brooks (mentor) --- include/stdlib.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index 3c26dfb0fcfb..d7e49d028bc4 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -76,7 +76,7 @@ extern int __mb_cur_max; extern int ___mb_cur_max(void); #define MB_CUR_MAX (___mb_cur_max()) -void abort(void) __dead2; +__noreturn void abort(void); int abs(int) __pure2; int atexit(void (*)(void)); double atof(const char *); @@ -86,7 +86,7 @@ void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); void *calloc(size_t, size_t) __malloc_like; div_t div(int, int) __pure2; -void exit(int) __dead2; +__noreturn void exit(int); void free(void *); char *getenv(const char *); long labs(long) __pure2; @@ -145,9 +145,17 @@ unsigned long long strtoull(const char * __restrict, char ** __restrict, int); #endif /* __LONG_LONG_SUPPORTED */ -void _Exit(int) __dead2; +__noreturn void _Exit(int); #endif /* __ISO_C_VISIBLE >= 1999 */ +/* + * If we're in a mode greater than C99, expose C1x functions. + */ +#if __ISO_C_VISIBLE > 1999 +__noreturn void quick_exit(int) +int +at_quick_exit(void (*func)(void)); +#endif /* __ISO_C_VISIBLE > 1999 */ /* * Extensions made by POSIX relative to C. We don't know yet which edition * of POSIX made these extensions, so assume they've always been there until -- cgit v1.2.3