From 3d58cb9a66f19d279fd1643f531a3f2f6cc4dcb3 Mon Sep 17 00:00:00 2001 From: bernhardheld Date: Sat, 8 Mar 2003 14:56:42 +0000 Subject: [PATCH] * src/configure.in: check for endianess (even while cross-compiling) * src/configure: check for endianess (even while cross-compiling) * src/configure_in.h: check for endianess (even while cross-compiling) * src/avr/gen.c: remove old endianess stuff * src/mcs51/gen.c: remove old endianess stuff * src/ds390/gen.c: remove old endianess stuff * src/pic/gen.c: remove old endianess stuff * src/pic/genarith.c: remove old endianess stuff * src/pic/glue.c: fix endianess check * src/pic16/gen.c: remove old endianess stuff * src/pic16/genarith.c: remove old endianess stuff * src/pic16/glue.c: fix endianess check * src/xa51/gen.c: remove old endianess stuff * src/z80/gen.c: fix endianess check * src/SDCCglue.c: fix endianess check git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2346 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 25 +- configure | 635 +++++++++---------------------------------- configure.in | 3 +- sdccconf_in.h | 5 +- src/SDCCglue.c | 2 +- src/avr/gen.c | 17 -- src/ds390/gen.c | 17 -- src/mcs51/gen.c | 17 -- src/pic/gen.c | 17 -- src/pic/genarith.c | 17 -- src/pic/glue.c | 4 +- src/pic16/gen.c | 17 -- src/pic16/genarith.c | 17 -- src/pic16/glue.c | 4 +- src/xa51/gen.c | 17 -- src/z80/gen.c | 6 +- 16 files changed, 154 insertions(+), 666 deletions(-) diff --git a/ChangeLog b/ChangeLog index c178840c..b3a342a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,28 @@ +2003-03-08 Bernhard Held + + * src/configure.in: check for endianess (even while cross-compiling) + * src/configure: check for endianess (even while cross-compiling) + * src/configure_in.h: check for endianess (even while cross-compiling) + * src/avr/gen.c: remove old endianess stuff + * src/mcs51/gen.c: remove old endianess stuff + * src/ds390/gen.c: remove old endianess stuff + * src/pic/gen.c: remove old endianess stuff + * src/pic/genarith.c: remove old endianess stuff + * src/pic/glue.c: fix endianess check + * src/pic16/gen.c: remove old endianess stuff + * src/pic16/genarith.c: remove old endianess stuff + * src/pic16/glue.c: fix endianess check + * src/xa51/gen.c: remove old endianess stuff + * src/z80/gen.c: fix endianess check + * src/SDCCglue.c: fix endianess check + 2003-03-08 Bernhard Held * src/SDCCsymt.h: use appropriate data-types on host for SDCC's int and long - * configure: find appropriate data-types on host for SDCC's int and long - * configure.in: find appropriate data-types on host for SDCC's int and long - * sdccconf_in.h: find appropriate data-types on host for SDCC's int and long + * src/configure: find appropriate data-types on host for SDCC's int and long + * src/configure.in: find appropriate data-types on host for SDCC's int and long + * src/sdccconf_in.h: find appropriate data-types on host for SDCC's int and long * src/xa51/gen.c: use %d, not %ld for 4 byte variables - * sdcc_vc_in.h: use appropriate data-types on host for SDCC's int and long 2003-03-07 diff --git a/configure b/configure index 4cdd8c45..7b72ebd2 100755 --- a/configure +++ b/configure @@ -3727,234 +3727,6 @@ fi done -for ac_header in endian.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -ac_header_compiler=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc in - yes:no ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; - no:yes ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in machine/endian.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 -else - # Is the header compilable? -echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -ac_header_compiler=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6 - -# Is the header present? -echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -#include <$ac_header> -_ACEOF -if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 - (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 - cat conftest.$ac_ext >&5 - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6 - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc in - yes:no ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; - no:yes ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; -esac -echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 -if eval "test \"\${$as_ac_Header+set}\" = set"; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=$ac_header_preproc" -fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - for ac_header in malloc.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -6647,140 +6419,85 @@ cat >>confdefs.h <<_ACEOF _ACEOF -echo "$as_me:$LINENO: checking for long long" >&5 -echo $ECHO_N "checking for long long... $ECHO_C" >&6 -if test "${ac_cv_type_long_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -$ac_includes_default -int -main () + if $CXX -v 2>&1|grep "mingw" >/dev/null 2>&1; then + ac_cv_sizeof_char=1 + ac_cv_sizeof_short=2 + ac_cv_sizeof_int=4 + ac_cv_sizeof_long=4 + else + : # FIXME + fi +#echo +fi + +type_name() { -if ((long long *) 0) - return 0; -if (sizeof (long long)) - return 0; - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_type_long_long=yes -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -ac_cv_type_long_long=no -fi -rm -f conftest.$ac_objext conftest.$ac_ext -fi -echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 -echo "${ECHO_T}$ac_cv_type_long_long" >&6 + if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then + echo "char" + exit + fi + if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then + echo "short" + exit + fi + if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then + echo "int" + exit + fi + if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then + echo "long" + exit + fi + echo "long" +} -echo "$as_me:$LINENO: checking size of long long" >&5 -echo $ECHO_N "checking size of long long... $ECHO_C" >&6 -if test "${ac_cv_sizeof_long_long+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$ac_cv_type_long_long" = yes; then - # The cast to unsigned long works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= 0)]; -test_array [0] = 0 +echo "$as_me:$LINENO: checking type name for byte" >&5 +echo $ECHO_N "checking type name for byte... $ECHO_C" >&6 +TYPE_BYTE=`type_name 1` +echo "$as_me:$LINENO: result: $TYPE_BYTE" >&5 +echo "${ECHO_T}$TYPE_BYTE" >&6 +echo "$as_me:$LINENO: checking type name for word" >&5 +echo $ECHO_N "checking type name for word... $ECHO_C" >&6 +TYPE_WORD=`type_name 2` +echo "$as_me:$LINENO: result: $TYPE_WORD" >&5 +echo "${ECHO_T}$TYPE_WORD" >&6 +echo "$as_me:$LINENO: checking type name for dword" >&5 +echo $ECHO_N "checking type name for dword... $ECHO_C" >&6 +TYPE_DWORD=`type_name 4` +echo "$as_me:$LINENO: result: $TYPE_DWORD" >&5 +echo "${ECHO_T}$TYPE_DWORD" >&6 +cat >>confdefs.h <<_ACEOF +#define TYPE_BYTE $TYPE_BYTE +_ACEOF - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define TYPE_WORD $TYPE_WORD _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_lo=0 ac_mid=0 - while :; do - cat >conftest.$ac_ext <<_ACEOF -#line $LINENO "configure" -#include "confdefs.h" -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; -test_array [0] = 0 - ; - return 0; -} +cat >>confdefs.h <<_ACEOF +#define TYPE_DWORD $TYPE_DWORD _ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_hi=$ac_mid; break -else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 -ac_lo=`expr $ac_mid + 1` - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid + 1` -fi -rm -f conftest.$ac_objext conftest.$ac_ext - done + + +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 else - echo "$as_me: failed program was:" >&5 -cat conftest.$ac_ext >&5 + # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" -$ac_includes_default +#include +#include + int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) < 0)]; -test_array [0] = 0 +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif ; return 0; @@ -6798,17 +6515,19 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=-1 ac_mid=-1 - while :; do - cat >conftest.$ac_ext <<_ACEOF + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" -$ac_includes_default +#include +#include + int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) >= $ac_mid)]; -test_array [0] = 0 +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif ; return 0; @@ -6826,40 +6545,33 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_lo=$ac_mid; break + ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -ac_hi=`expr '(' $ac_mid ')' - 1` - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - ac_mid=`expr 2 '*' $ac_mid` +ac_cv_c_bigendian=no fi rm -f conftest.$ac_objext conftest.$ac_ext - done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -ac_lo= ac_hi= -fi -rm -f conftest.$ac_objext conftest.$ac_ext -fi -rm -f conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" -$ac_includes_default +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () { -static int test_array [1 - 2 * !(((long) (sizeof (long long))) <= $ac_mid)]; -test_array [0] = 0 - + _ascii (); _ebcdic (); ; return 0; } @@ -6876,59 +6588,37 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_hi=$ac_mid + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -ac_lo=`expr '(' $ac_mid ')' + 1` fi rm -f conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in -?*) ac_cv_sizeof_long_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77" >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77" >&2;} - { (exit 1); exit 1; }; } ;; -esac -else - if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling" >&5 -echo "$as_me: error: cannot run test program while cross compiling" >&2;} - { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" -$ac_includes_default -long longval () { return (long) (sizeof (long long)); } -unsigned long ulongval () { return (long) (sizeof (long long)); } -#include -#include int main () { - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - exit (1); - if (((long) (sizeof (long long))) < 0) - { - long i = longval (); - if (i != ((long) (sizeof (long long)))) - exit (1); - fprintf (f, "%ld\n", i); - } - else - { - unsigned long i = ulongval (); - if (i != ((long) (sizeof (long long)))) - exit (1); - fprintf (f, "%lu\n", i); - } - exit (ferror (f) || fclose (f) != 0); - - ; - return 0; + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); } _ACEOF rm -f conftest$ac_exeext @@ -6942,114 +6632,37 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then - ac_cv_sizeof_long_long=`cat conftest.val` + ac_cv_c_bigendian=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long), 77" >&5 -echo "$as_me: error: cannot compute sizeof (long long), 77" >&2;} - { (exit 1); exit 1; }; } +ac_cv_c_bigendian=yes fi rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -rm -f conftest.val -else - ac_cv_sizeof_long_long=0 -fi -fi -echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 -echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6 -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long -_ACEOF - - -else - if $CXX -v 2>&1|grep "mingw" >/dev/null 2>&1; then - ac_cv_sizeof_char=1 - ac_cv_sizeof_short=2 - ac_cv_sizeof_int=4 - ac_cv_sizeof_long=4 - ac_cv_sizeof_long_long=4 - else - : # FIXME - fi -#echo -fi - -type_name() -{ - if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then - echo "char" - exit - fi - if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then - echo "short" - exit - fi - if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then - echo "int" - exit - fi - if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then - echo "long" - exit - fi - echo "long" -} - -echo "$as_me:$LINENO: checking type name for byte" >&5 -echo $ECHO_N "checking type name for byte... $ECHO_C" >&6 -TYPE_BYTE=`type_name 1` -echo "$as_me:$LINENO: result: $TYPE_BYTE" >&5 -echo "${ECHO_T}$TYPE_BYTE" >&6 -echo "$as_me:$LINENO: checking type name for word" >&5 -echo $ECHO_N "checking type name for word... $ECHO_C" >&6 -TYPE_WORD=`type_name 2` -echo "$as_me:$LINENO: result: $TYPE_WORD" >&5 -echo "${ECHO_T}$TYPE_WORD" >&6 -echo "$as_me:$LINENO: checking type name for dword" >&5 -echo $ECHO_N "checking type name for dword... $ECHO_C" >&6 -TYPE_DWORD=`type_name 4` -echo "$as_me:$LINENO: result: $TYPE_DWORD" >&5 -echo "${ECHO_T}$TYPE_DWORD" >&6 -cat >>confdefs.h <<_ACEOF -#define TYPE_BYTE $TYPE_BYTE -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define TYPE_WORD $TYPE_WORD -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define TYPE_DWORD $TYPE_DWORD -_ACEOF - - -if echo $TYPE_DWORD|grep short >/dev/null; then - A="h" -elif echo $TYPE_DWORD|grep long >/dev/null; then - A="l" -else - A="" -fi - -if echo $TYPE_WORD|grep short >/dev/null; then M="h" -elif echo $TYPE_WORD|grep long >/dev/null; then M="l" -else M="" +rm -f conftest.$ac_objext conftest.$ac_ext fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) -cat >>confdefs.h <<_ACEOF -#define _A_ "${A}" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define _M_ "${M}" +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 _ACEOF - + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac # diff --git a/configure.in b/configure.in index e59d955c..e46aae40 100755 --- a/configure.in +++ b/configure.in @@ -64,8 +64,6 @@ AC_LANG_C AC_HEADER_STDC AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(unistd.h) -AC_CHECK_HEADERS(endian.h) -AC_CHECK_HEADERS(machine/endian.h) AC_CHECK_HEADERS(malloc.h) AC_CHECK_HEADERS(sys/isa_defs.h) AC_CHECK_HEADERS(sys/socket.h) @@ -233,6 +231,7 @@ AC_DEFINE_UNQUOTED(TYPE_BYTE, $TYPE_BYTE) AC_DEFINE_UNQUOTED(TYPE_WORD, $TYPE_WORD) AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD) +AC_C_BIGENDIAN # # diff --git a/sdccconf_in.h b/sdccconf_in.h index 0facfd7f..2cbf3305 100644 --- a/sdccconf_in.h +++ b/sdccconf_in.h @@ -24,9 +24,6 @@ #undef STD_DS390_LIB #undef STD_XA51_LIB #undef HAVE_SYS_SOCKET_H -#undef HAVE_SYS_ISA_DEFS_H -#undef HAVE_ENDIAN_H -#undef HAVE_MACHINE_ENDIAN_H #undef HAVE_STRERROR #undef HAVE_VSNPRINTF @@ -41,6 +38,8 @@ #define TYPE_UWORD unsigned TYPE_WORD #define TYPE_UDWORD unsigned TYPE_DWORD +#undef WORDS_BIGENDIAN + #undef OPT_DISABLE_MCS51 #undef OPT_DISABLE_GBZ80 #undef OPT_DISABLE_Z80 diff --git a/src/SDCCglue.c b/src/SDCCglue.c index c4ef6f2f..906c8382 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -145,7 +145,7 @@ aopLiteralLong (value * val, int offset, int size) /* it is type float */ fl.f = (float) floatFromVal (val); -#ifdef _BIG_ENDIAN +#ifdef WORDS_BIGENDIAN tsprintf (buffer, sizeof(buffer), "!immedbyte", fl.c[3 - offset]); #else diff --git a/src/avr/gen.c b/src/avr/gen.c index 06c7476a..62329c50 100644 --- a/src/avr/gen.c +++ b/src/avr/gen.c @@ -31,23 +31,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/ds390/gen.c b/src/ds390/gen.c index 132fe8ee..c35fc6f4 100644 --- a/src/ds390/gen.c +++ b/src/ds390/gen.c @@ -36,23 +36,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #define BETTER_LITERAL_SHIFT char *aopLiteral (value * val, int offset); diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 770dc876..9ef6d91e 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -38,23 +38,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/pic/gen.c b/src/pic/gen.c index 665d8b27..44f440f8 100644 --- a/src/pic/gen.c +++ b/src/pic/gen.c @@ -36,23 +36,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/pic/genarith.c b/src/pic/genarith.c index 241ca2f3..f998a7c4 100644 --- a/src/pic/genarith.c +++ b/src/pic/genarith.c @@ -40,23 +40,6 @@ #define __FUNCTION__ __FILE__ #endif -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/pic/glue.c b/src/pic/glue.c index e50b255c..76cf3814 100644 --- a/src/pic/glue.c +++ b/src/pic/glue.c @@ -29,7 +29,7 @@ #include "newalloc.h" -#ifdef _BIG_ENDIAN +#ifdef WORDS_BIGENDIAN #define _ENDIAN(x) (3-x) #else #define _ENDIAN(x) (x) @@ -86,7 +86,7 @@ int pic14aopLiteral (value *val, int offset) /* it is type float */ fl.f = (float) floatFromVal(val); -#ifdef _BIG_ENDIAN +#ifdef WORDS_BIGENDIAN return fl.c[3-offset]; #else return fl.c[offset]; diff --git a/src/pic16/gen.c b/src/pic16/gen.c index d9265bce..422ad251 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -37,23 +37,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/pic16/genarith.c b/src/pic16/genarith.c index 0c8f6ff3..218c263a 100644 --- a/src/pic16/genarith.c +++ b/src/pic16/genarith.c @@ -41,23 +41,6 @@ #define __FUNCTION__ __FILE__ #endif -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/pic16/glue.c b/src/pic16/glue.c index c49b5173..7e7d1c7e 100644 --- a/src/pic16/glue.c +++ b/src/pic16/glue.c @@ -29,7 +29,7 @@ #include "newalloc.h" -#ifdef _BIG_ENDIAN +#ifdef WORDS_BIGENDIAN #define _ENDIAN(x) (3-x) #else #define _ENDIAN(x) (x) @@ -86,7 +86,7 @@ int pic16aopLiteral (value *val, int offset) /* it is type float */ fl.f = (float) floatFromVal(val); -#ifdef _BIG_ENDIAN +#ifdef WORDS_BIGENDIAN return fl.c[3-offset]; #else return fl.c[offset]; diff --git a/src/xa51/gen.c b/src/xa51/gen.c index fdd1a3c2..3313b880 100755 --- a/src/xa51/gen.c +++ b/src/xa51/gen.c @@ -35,23 +35,6 @@ #include "SDCCglobl.h" #include "newalloc.h" -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#else -#ifdef HAVE_MACHINE_ENDIAN_H -#include -#else -#ifdef HAVE_ENDIAN_H -#include -#else -#if !defined(__BORLANDC__) && !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__) -#warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN" -#warning "If you running sdcc on an INTEL 80x86 Platform you are okay" -#endif -#endif -#endif -#endif - #include "common.h" #include "SDCCpeeph.h" #include "ralloc.h" diff --git a/src/z80/gen.c b/src/z80/gen.c index 7e2f401b..b5f0afc9 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -93,10 +93,6 @@ #define STRCASECMP strcasecmp #endif -#ifdef HAVE_SYS_ISA_DEFS_H -#include -#endif - #include "z80.h" #include "SDCCglobl.h" #include "SDCCpeeph.h" @@ -1144,7 +1140,7 @@ aopGetLitWordLong (asmop * aop, int offset, bool with_hash) /* it is type float */ fl.f = (float) floatFromVal (val); -#ifdef _BIG_ENDIAN +#ifdef WORDS_BIGENDIAN i = fl.c[3-offset] | (fl.c[3-offset-1]<<8); #else i = fl.c[offset] | (fl.c[offset+1]<<8); -- 2.30.2