From cd33456b7662ca549fe2eb272884d9d056137064 Mon Sep 17 00:00:00 2001 From: Sen Han <00hnes@gmail.com> Date: Fri, 27 Jul 2018 17:27:43 +0800 Subject: [PATCH] change `asm` to `__asm__` to support cc's `--std=c99` flag (from issue https://github.com/hnes/libaco/issues/16, proposed by Theo Schlossnagle @postwait) --- .travis.yml | 11 +++++++++++ aco.c | 2 ++ aco.h | 6 +++--- make.sh | 29 +++++++++++++++-------------- test_aco_benchmark.c | 2 ++ 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 420bb66..10cd36a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ script: - if [ "$TRAVIS_OS_NAME" = "osx" ] ; then brew install gnu-sed --with-default-names; fi - if [ "$TRAVIS_OS_NAME" = "linux" ] ; then sudo apt-get install -qq -y libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential valgrind gcc-multilib g++-multilib libc6-dbg libc6-dbg:i386 ; fi - date + - export EXTRA_CFLAGS="" - echo "" - bash test.sh version_check=1.2.3 - echo "" @@ -26,6 +27,16 @@ script: - mkdir output ; bash make.sh -o no-valgrind ; ls output ; ls output | wc -l ; cd output ; bash ../test.sh ; cd .. ; rm -fr output - echo "" - if [ "$TRAVIS_OS_NAME" = "linux" ] ; then mkdir output ; bash make.sh -o no-valgrind -o no-m32 ; ls output ; ls output | wc -l ; cd output ; bash ../test.sh ; cd .. ; rm -fr output; fi + - echo "" + - export EXTRA_CFLAGS="--std=c99" + - echo "" + - if [ "$TRAVIS_OS_NAME" = "linux" ] ; then mkdir output ; bash make.sh ; ls output ; ls output | wc -l ; cd output ; bash ../test.sh ; cd .. ; rm -fr output; fi + - echo "" + - if [ "$TRAVIS_OS_NAME" = "linux" ] ; then mkdir output ; bash make.sh -o no-m32 ; ls output ; ls output | wc -l ; cd output ; bash ../test.sh ; cd .. ; rm -fr output; fi + - echo "" + - mkdir output ; bash make.sh -o no-valgrind ; ls output ; ls output | wc -l ; cd output ; bash ../test.sh ; cd .. ; rm -fr output + - echo "" + - if [ "$TRAVIS_OS_NAME" = "linux" ] ; then mkdir output ; bash make.sh -o no-valgrind -o no-m32 ; ls output ; ls output | wc -l ; cd output ; bash ../test.sh ; cd .. ; rm -fr output; fi - echo "" ; date matrix: diff --git a/aco.c b/aco.c index 40c0770..8320603 100644 --- a/aco.c +++ b/aco.c @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#define _GNU_SOURCE + #include "aco.h" #include #include diff --git a/aco.h b/aco.h index e18af80..9afc5be 100644 --- a/aco.h +++ b/aco.h @@ -159,11 +159,11 @@ extern void aco_runtime_test(void); extern void aco_thread_init(aco_cofuncp_t last_word_co_fp); -extern void* acosw(aco_t* from_co, aco_t* to_co) asm("acosw"); // asm +extern void* acosw(aco_t* from_co, aco_t* to_co) __asm__("acosw"); // asm -extern void aco_save_fpucw_mxcsr(void* p) asm("aco_save_fpucw_mxcsr"); // asm +extern void aco_save_fpucw_mxcsr(void* p) __asm__("aco_save_fpucw_mxcsr"); // asm -extern void aco_funcp_protector_asm(void) asm("aco_funcp_protector_asm"); // asm +extern void aco_funcp_protector_asm(void) __asm__("aco_funcp_protector_asm"); // asm extern void aco_funcp_protector(void); diff --git a/make.sh b/make.sh index 05bb69b..de7cd4f 100644 --- a/make.sh +++ b/make.sh @@ -14,7 +14,7 @@ OUTPUT_DIR="./output" CFLAGS="-g -O2 -Wall -Werror" -EXTRA_CFLAGS="" +#EXTRA_CFLAGS="" OUTPUT_SUFFIX="" makecc="cc" if [ "$CC" ] @@ -71,10 +71,11 @@ function build_f(){ declare build_cmd declare tmp_ret declare skip_flag - echo "OUTPUT_DIR: $OUTPUT_DIR" - echo "CFLAGS: $CFLAGS" - echo "EXTRA_CFLAGS: $EXTRA_CFLAGS" - echo "OUTPUT_SUFFIX: $OUTPUT_SUFFIX" + echo "OUTPUT_DIR: $OUTPUT_DIR" + echo "CFLAGS: $CFLAGS" + echo "EXTRA_CFLAGS: $EXTRA_CFLAGS" + echo "ACO_EXTRA_CFLAGS: $ACO_EXTRA_CFLAGS" + echo "OUTPUT_SUFFIX: $OUTPUT_SUFFIX" echo "$app_list" | grep -Po '.+$' | while read read_in do file=`echo $read_in | grep -Po "^[^\s]+"` @@ -84,7 +85,7 @@ function build_f(){ continue fi #echo "<$file>:<$cflags>:$OUTPUT_DIR:$CFLAGS:$EXTRA_CFLAGS:$OUTPUT_SUFFIX" - build_cmd="$makecc $CFLAGS $EXTRA_CFLAGS acosw.S aco.c $file.c $cflags -o $OUTPUT_DIR/$file$OUTPUT_SUFFIX" + build_cmd="$makecc $CFLAGS $ACO_EXTRA_CFLAGS $EXTRA_CFLAGS acosw.S aco.c $file.c $cflags -o $OUTPUT_DIR/$file$OUTPUT_SUFFIX" skip_flag="" if [ "$gl_opt_no_m32" ] then @@ -182,18 +183,18 @@ tra "echo;echo build has been interrupted" # the matrix of the build config for later testing # -m32 -DACO_CONFIG_SHARE_FPU_MXCSR_ENV -DACO_USE_VALGRIND # 0 0 0 -EXTRA_CFLAGS="" OUTPUT_SUFFIX="..no_valgrind.standaloneFPUenv" build_f +ACO_EXTRA_CFLAGS="" OUTPUT_SUFFIX="..no_valgrind.standaloneFPUenv" build_f # 0 0 1 -EXTRA_CFLAGS="-DACO_USE_VALGRIND" OUTPUT_SUFFIX="..valgrind.standaloneFPUenv" build_f +ACO_EXTRA_CFLAGS="-DACO_USE_VALGRIND" OUTPUT_SUFFIX="..valgrind.standaloneFPUenv" build_f # 0 1 0 -EXTRA_CFLAGS="-DACO_CONFIG_SHARE_FPU_MXCSR_ENV" OUTPUT_SUFFIX="..no_valgrind.shareFPUenv" build_f +ACO_EXTRA_CFLAGS="-DACO_CONFIG_SHARE_FPU_MXCSR_ENV" OUTPUT_SUFFIX="..no_valgrind.shareFPUenv" build_f # 0 1 1 -EXTRA_CFLAGS="-DACO_CONFIG_SHARE_FPU_MXCSR_ENV -DACO_USE_VALGRIND" OUTPUT_SUFFIX="..valgrind.shareFPUenv" build_f +ACO_EXTRA_CFLAGS="-DACO_CONFIG_SHARE_FPU_MXCSR_ENV -DACO_USE_VALGRIND" OUTPUT_SUFFIX="..valgrind.shareFPUenv" build_f # 1 0 0 -EXTRA_CFLAGS="-m32" OUTPUT_SUFFIX="..m32.no_valgrind.standaloneFPUenv" build_f +ACO_EXTRA_CFLAGS="-m32" OUTPUT_SUFFIX="..m32.no_valgrind.standaloneFPUenv" build_f # 1 0 1 -EXTRA_CFLAGS="-m32 -DACO_USE_VALGRIND" OUTPUT_SUFFIX="..m32.valgrind.standaloneFPUenv" build_f +ACO_EXTRA_CFLAGS="-m32 -DACO_USE_VALGRIND" OUTPUT_SUFFIX="..m32.valgrind.standaloneFPUenv" build_f # 1 1 0 -EXTRA_CFLAGS="-m32 -DACO_CONFIG_SHARE_FPU_MXCSR_ENV" OUTPUT_SUFFIX="..m32.no_valgrind.shareFPUenv" build_f +ACO_EXTRA_CFLAGS="-m32 -DACO_CONFIG_SHARE_FPU_MXCSR_ENV" OUTPUT_SUFFIX="..m32.no_valgrind.shareFPUenv" build_f # 1 1 1 -EXTRA_CFLAGS="-m32 -DACO_CONFIG_SHARE_FPU_MXCSR_ENV -DACO_USE_VALGRIND" OUTPUT_SUFFIX="..m32.valgrind.shareFPUenv" build_f +ACO_EXTRA_CFLAGS="-m32 -DACO_CONFIG_SHARE_FPU_MXCSR_ENV -DACO_USE_VALGRIND" OUTPUT_SUFFIX="..m32.valgrind.shareFPUenv" build_f diff --git a/test_aco_benchmark.c b/test_aco_benchmark.c index 55cdc8f..07fa7fc 100644 --- a/test_aco_benchmark.c +++ b/test_aco_benchmark.c @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#define _GNU_SOURCE + #include "aco.h" #include #include