add "testme.sh --c89" and "make c89" * replace int*_t and bool by custom typedefs * the result is tested in CI
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
diff --git a/.travis.yml b/.travis.yml
index 2f94615..42960d0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -140,6 +140,7 @@ matrix:
# clang for x86-64 architecture (64-bit longs and 64-bit pointers)
- env: SANITIZER=1 CONV_WARNINGS=relaxed BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
- env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --with-m64 --with-travis-valgrind'
+ - env: SANITIZER=1 CONV_WARNINGS=strict BUILDOPTIONS='--with-cc=clang-7 --c89 --with-m64 --with-travis-valgrind'
- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-6.0 --with-m64 --with-travis-valgrind'
addons:
apt:
diff --git a/makefile b/makefile
index 179176b..be7ef0c 100644
--- a/makefile
+++ b/makefile
@@ -152,6 +152,29 @@ new_file:
perlcritic:
perlcritic *.pl doc/*.pl
+c89:
+ @echo "Applying substitutions for c89 compatibility..."
+ @sed -i \
+ -e 's/#include <stdbool.h>//g' \
+ -e 's/#include <stdint.h>/#include "tommath_c89.h"/g' \
+ -e 's/bool/mp_bool/g' \
+ -e 's/true/MP_YES/g' \
+ -e 's/false/MP_NO/g' \
+ -e 's/uint\([0-9][0-9]*\)_t/mp_u\1/g' \
+ -e 's/int\([0-9][0-9]*\)_t/mp_i\1/g' \
+ *.c *.h demo/*.c demo/*.h etc/*.c
+ @echo "/* please adapt this header to your needs */" > tommath_c89.h
+ @echo "typedef enum { MP_NO, MP_YES } mp_bool;" >> tommath_c89.h
+ @echo "typedef __INT8_TYPE__ mp_i8;" >> tommath_c89.h
+ @echo "typedef __INT16_TYPE__ mp_i16;" >> tommath_c89.h
+ @echo "typedef __INT32_TYPE__ mp_i32;" >> tommath_c89.h
+ @echo "typedef __INT64_TYPE__ mp_i64;" >> tommath_c89.h
+ @echo "typedef __UINT8_TYPE__ mp_u8;" >> tommath_c89.h
+ @echo "typedef __UINT16_TYPE__ mp_u16;" >> tommath_c89.h
+ @echo "typedef __UINT32_TYPE__ mp_u32;" >> tommath_c89.h
+ @echo "typedef __UINT64_TYPE__ mp_u64;" >> tommath_c89.h
+
+
astyle:
@echo " * run astyle on all sources"
@astyle --options=astylerc --formatted $(OBJECTS:.o=.c) tommath*.h demo/*.c etc/*.c mtest/mtest.c
diff --git a/testme.sh b/testme.sh
index 2f7235f..3375fa6 100755
--- a/testme.sh
+++ b/testme.sh
@@ -195,6 +195,7 @@ VALGRIND_OPTS=" --leak-check=full --show-leak-kinds=all --error-exitcode=1 "
#VALGRIND_OPTS=""
VALGRIND_BIN=""
CHECK_FORMAT=""
+C89=""
TUNE_CMD="./etc/tune -t -r 10 -L 3"
alive_pid=0
@@ -217,6 +218,9 @@ do
"--with-m64" | "--with-m32" | "--with-mx32")
ARCHFLAGS="$ARCHFLAGS ${1:6}"
;;
+ --c89)
+ C89="1"
+ ;;
--with-cc=*)
COMPILERS="$COMPILERS ${1#*=}"
;;
@@ -291,6 +295,8 @@ function _check_git() {
git diff-index --quiet HEAD -- . || ( echo "FAILURE: $*" && exit 1 )
}
+[[ "$C89" == "1" ]] && make c89
+
if [[ "$CHECK_FORMAT" == "1" ]]
then
make astyle