diff options
author | Shawn Landden <shawn@churchofgit.com> | 2013-12-16 08:53:53 -0800 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-17 21:51:24 +0100 |
commit | 919ce0b7affc6fbd68598b709faf477f56c22ac1 (patch) | |
tree | b629e38d0718c37d4e8e12d5f476851ad903476e /src/shared | |
parent | 73020ab241866dce79b80cbebcaae537470c7086 (diff) |
_noreturn_ --> noreturn for C11 compat
also define noreturn w/o <stdnoreturn.h>
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/log.c | 4 | ||||
-rw-r--r-- | src/shared/log.h | 4 | ||||
-rw-r--r-- | src/shared/macro.h | 14 | ||||
-rw-r--r-- | src/shared/pager.c | 2 | ||||
-rw-r--r-- | src/shared/util.c | 2 | ||||
-rw-r--r-- | src/shared/util.h | 2 |
6 files changed, 19 insertions, 9 deletions
diff --git a/src/shared/log.c b/src/shared/log.c index 2404de85e3..2517f5d780 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -702,12 +702,12 @@ static void log_assert(int level, const char *text, const char *file, int line, } #pragma GCC diagnostic pop -_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) { +noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) { log_assert(LOG_CRIT, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting."); abort(); } -_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) { +noreturn void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) { log_assert(LOG_CRIT, text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting."); abort(); } diff --git a/src/shared/log.h b/src/shared/log.h index de0e000371..3dcfa11308 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -124,13 +124,13 @@ int log_dump_internal( const char *func, char *buffer); -_noreturn_ void log_assert_failed( +noreturn void log_assert_failed( const char *text, const char *file, int line, const char *func); -_noreturn_ void log_assert_failed_unreachable( +noreturn void log_assert_failed_unreachable( const char *text, const char *file, int line, diff --git a/src/shared/macro.h b/src/shared/macro.h index 2b5b3fdfe0..79bee0396c 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -30,7 +30,6 @@ #define _printf_(a,b) __attribute__ ((format (printf, a, b))) #define _alloc_(...) __attribute__ ((alloc_size(__VA_ARGS__))) #define _sentinel_ __attribute__ ((sentinel)) -#define _noreturn_ __attribute__((noreturn)) #define _unused_ __attribute__ ((unused)) #define _destructor_ __attribute__ ((destructor)) #define _pure_ __attribute__ ((pure)) @@ -300,7 +299,8 @@ do { \ _found; \ }) -/* Define C11 thread_local attribute even on older compilers */ +/* Define C11 thread_local attribute even on older gcc compiler + * version */ #ifndef thread_local /* * Don't break on glibc < 2.16 that doesn't define __STDC_NO_THREADS__ @@ -313,4 +313,14 @@ do { \ #endif #endif +/* Define C11 noreturn without <stdnoreturn.h> and even on older gcc + * compiler versions */ +#ifndef noreturn +#if __STDC_VERSION__ >= 201112L +#define noreturn _Noreturn +#else +#define noreturn __attribute__((noreturn)) +#endif +#endif + #include "log.h" diff --git a/src/shared/pager.c b/src/shared/pager.c index 9fa611479c..72a29f2285 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -32,7 +32,7 @@ static pid_t pager_pid = 0; -_noreturn_ static void pager_fallback(void) { +noreturn static void pager_fallback(void) { ssize_t n; do { diff --git a/src/shared/util.c b/src/shared/util.c index 80dbf73c94..2cf9fbe53e 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -3469,7 +3469,7 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) { return -EPROTO; } -_noreturn_ void freeze(void) { +noreturn void freeze(void) { /* Make sure nobody waits for us on a socket anymore */ close_all_fds(NULL, 0); diff --git a/src/shared/util.h b/src/shared/util.h index 1d178260cb..ddb35181ab 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -426,7 +426,7 @@ char *normalize_env_assignment(const char *s); int wait_for_terminate(pid_t pid, siginfo_t *status); int wait_for_terminate_and_warn(const char *name, pid_t pid); -_noreturn_ void freeze(void); +noreturn void freeze(void); bool null_or_empty(struct stat *st) _pure_; int null_or_empty_path(const char *fn); |