From ae2ab6ade88f182910ae59abfbf69ef0ce64c273 Mon Sep 17 00:00:00 2001 From: Jann Horn Date: Wed, 19 Mar 2014 14:13:56 +0100 Subject: [PATCH 1/1] add JH_ATTR_NORETURN --- compile.sh | 4 +++- error.c | 2 +- header.h | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 header.h diff --git a/compile.sh b/compile.sh index 64c148d..4558464 100755 --- a/compile.sh +++ b/compile.sh @@ -24,6 +24,7 @@ echo "welcome. your friendly compiler will be \"$CC\" today." >&2 echo "going ahead with CFLAGS=\"$CFLAGS\"..." >&2 # generate header +cat header.h > gen/jh.h for source_file in $(ls|grep '\.c$'); do echo "extracting header data from $source_file..." >&2 source_name="$(sed 's|\.c$||' <<< "$source_file")" @@ -38,7 +39,7 @@ for source_file in $(ls|grep '\.c$'); do echo '' echo '' -done > gen/jh.h +done >> gen/jh.h # preprocess all source files for source_file in $(ls|grep '\.c$'); do @@ -52,6 +53,7 @@ for source_file in $(ls|grep '\.c$'); do (set +e +o pipefail; grep -v '^PUBLIC_CONST '; exit 0) | sed 's|^PUBLIC_FN ||g' | (set +e +o pipefail; grep -v '^HEADER '; exit 0) | + sed 's| *JH_ATTR_[A-Z_]*||g' | cat >> "gen/realc/$source_name.c" if [ $? -ne 0 ]; then exit 1; fi diff --git a/error.c b/error.c index 91ee45e..3860944 100644 --- a/error.c +++ b/error.c @@ -7,7 +7,7 @@ #define GENERIC_ERROR \ "unexpected generic failure of some kind" -PUBLIC_FN void xperror(const char *s, int show_errno) { +PUBLIC_FN void xperror(const char *s, int show_errno) JH_ATTR_NORETURN { if (!s) s=GENERIC_ERROR; if (show_errno) { perror(s); diff --git a/header.h b/header.h new file mode 100644 index 0000000..faf6756 --- /dev/null +++ b/header.h @@ -0,0 +1,6 @@ +/***** COMPILER-SPECIFIC STUFF *****/ +#ifdef __GNUC__ + #define JH_ATTR_NORETURN __attribute__ ((noreturn)) +#else + #define JH_ATTR_NORETURN /* nothing */ +#endif -- 2.20.1