diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-01-27 21:46:44 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-01-27 21:46:44 -0500 |
| commit | 678c7a2e221c4de467055d324bc79d62e7bec6db (patch) | |
| tree | 062ffefe58fb90289fa09b3c84fd69b9aeb8a2da | |
| parent | 63be8a77d8bd79573403b85faa92f2a503a6687e (diff) | |
add forward-compatibility macros
| -rwxr-xr-x | mkh.sh | 35 |
1 files changed, 32 insertions, 3 deletions
@@ -40,6 +40,26 @@ for i in $@; do echo $i >> $HEADER.$(classify_source $i) done +#if [ POSIX ]; then +cat <<-EOF > /dev/null + #if (!defined _POSIX_C_SOURCE) && (defined _XOPEN_SOURCE) + # if (_XOPEN_SOURCE >= 700) + # define _POSIX_C_SOURCE 200809L + # elif (_XOPEN_SOURCE >= 600) + # define _POSIX_C_SOURCE 200112L + # elif (_XOPEN_SOURCE >= 500) + # define _POSIX_C_SOURCE 199506L + # else + # define _POSIX_C_SOURCE 2 + # endif + #endif + + #ifdef _POSIX_C_SOURCE + # define _POSIX_SOURCE + #endif +EOF +#fi + if [ -f $HEADER.MACRO ]; then for i in $(sort $HEADER.MACRO); do grep ' *extern.*;$' $i @@ -108,10 +128,17 @@ fi if [ -f $HEADER.FUNCTION ]; then if grep -q restrict $(cat $HEADER.FUNCTION); then - printf '#if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L\n' - printf '#define restrict\n' - printf '#endif\n\n' + printf '#if (!defined __STDC_VERSION__) || (__STDC_VERSION__ < 199909L)\n' + printf '#define restrict\n' + printf '#endif\n\n' + fi + + if grep -q _Noreturn $(cat $HEADER.FUNCTION); then + printf '#if (!defined __STDC_VERSION__) || (__STDC_VERSION__ < 200112L)\n' + printf '#define _Noreturn\n' + printf '#endif\n\n' fi + for i in $(sort $HEADER.FUNCTION); do printf '%s;\n' "$(sed -e "/{/q" $i | tail -n2 | head -n1)" done @@ -119,4 +146,6 @@ if [ -f $HEADER.FUNCTION ]; then rm -f $HEADER.FUNCTION fi +rm -f $HEADER.REFERENCE + printf '\n#endif\n' |
