summaryrefslogtreecommitdiff
path: root/project/config
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-12-22 19:05:43 -0500
committermidipix <writeonce@midipix.org>2018-12-22 19:14:28 -0500
commitea008a754fd6b24ef545329abea9431d5a5d18b0 (patch)
tree578078691e6e32bf49fa76b1c26760b56871e24b /project/config
parentcbf55d337c89e8822e7e98b93b528127aa7c4cab (diff)
downloadsbpython3-ea008a754fd6b24ef545329abea9431d5a5d18b0.tar.bz2
sbpython3-ea008a754fd6b24ef545329abea9431d5a5d18b0.tar.xz
project: custom config: test for x87, x64, and IEEE properties at config time.
Diffstat (limited to 'project/config')
-rw-r--r--project/config/cfgdefs.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/project/config/cfgdefs.sh b/project/config/cfgdefs.sh
index 560afa6..adbfc33 100644
--- a/project/config/cfgdefs.sh
+++ b/project/config/cfgdefs.sh
@@ -141,6 +141,50 @@ cfgdefs_perform_common_tests()
mb_cfgtest_headers='pthread.h'
cfgtest_type_size 'pthread_t'
+ # toolchain
+ cfgtest_newline
+ cfgtest_comment 'toolchain'
+
+ # x87
+ mb_code_snippet=''
+ mb_code_snippet="$mb_code_snippet "'void fn(void)'
+ mb_code_snippet="$mb_code_snippet "'{__asm__ __volatile__ ("fnstcw pcw");'
+ mb_code_snippet="$mb_code_snippet "' __asm__ __volatile__ ("fldcw pcw");}'
+
+ if cfgtest_code_snippet "$mb_code_snippet"; then
+ cfgtest_cflags_append '-DHAVE_GCC_ASM_FOR_X87'
+ fi
+
+ # x64
+ mb_code_snippet=''
+ mb_code_snippet="$mb_code_snippet "'void fn(void)'
+ mb_code_snippet="$mb_code_snippet "'{__asm__ __volatile__ ("callq *%rax");}'
+
+ if cfgtest_code_snippet "$mb_code_snippet"; then
+ cfgtest_cflags_append '-DHAVE_GCC_ASM_FOR_X64'
+ fi
+
+ # IEEE 754: little endian / big endian
+ if $mb_cfgtest_cc -E -dM - < /dev/null \
+ | grep '__BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__' \
+ > /dev/null; then
+ cfgtest_cflags_append '-DDOUBLE_IS_LITTLE_ENDIAN_IEEE754'
+
+ elif $mb_cfgtest_cc -E -dM - < /dev/null \
+ | grep '__BYTE_ORDER__ __ORDER_BIG_ENDIAN__' \
+ > /dev/null; then
+ cfgtest_cflags_append '-DDOUBLE_IS_BIG_ENDIAN_IEEE754'
+
+ else
+ cfgtest_newline
+ cfgtest_comment 'cfgdefs.sh: cannot detect little/big endian,'
+ cfgtest_comment 'cfgtest.sh: so defined both macros below.'
+ cfgtest_newline
+
+ cfgtest_cflags_append '-DDOUBLE_IS_LITTLE_ENDIAN_IEEE754'
+ cfgtest_cflags_append '-DDOUBLE_IS_BIG_ENDIAN_IEEE754'
+ fi
+
# getrandom: easier to simply test,
# than to test whether we need to test
# (and then test).