add JH_ATTR_NORETURN
authorJann Horn <jann@thejh.net>
Wed, 19 Mar 2014 13:13:56 +0000 (14:13 +0100)
committerJann Horn <jann@thejh.net>
Wed, 19 Mar 2014 13:13:56 +0000 (14:13 +0100)
compile.sh
error.c
header.h [new file with mode: 0644]

index 64c148d..4558464 100755 (executable)
@@ -24,6 +24,7 @@ echo "welcome. your friendly compiler will be \"$CC\" today." >&2
 echo "going ahead with CFLAGS=\"$CFLAGS\"..." >&2
 
 # generate header
 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")"
 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 ''
   
   echo ''
   echo ''
-done > gen/jh.h
+done >> gen/jh.h
 
 # preprocess all source files
 for source_file in $(ls|grep '\.c$'); do
 
 # 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) |
   (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
   
   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 (file)
--- a/error.c
+++ b/error.c
@@ -7,7 +7,7 @@
 #define GENERIC_ERROR \
   "unexpected generic failure of some kind"
 
 #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);
   if (!s) s=GENERIC_ERROR;
   if (show_errno) {
     perror(s);
diff --git a/header.h b/header.h
new file mode 100644 (file)
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