diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 9956cf5dd2..d3e4752f77 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,16 @@ +2005-05-06 Kelley Cook + + * aclocal.m4 (AC_DEFINE_NOAUTOHEADER): Remove. + * configure.ac: Replace any AC_DEFINE_NOAUTOHEADER with AC_DEFINE. + * configure: Regenerate. + +2005-05-06 Kelley Cook + + * configure.ac: Use AC_C_BIGENDIAN instead of AC_C_BIGENDIAN_CROSS. + Use AC_CHECK_SIZEOF instead of AC_COMPILE_CHECK_SIZEOF. + * aclocal.m4: Don't include accross.m4. + * configure, config.in: Regenerate. + 2005-04-25 Kaveh R. Ghazi * fopen_unlocked.c (unlock_std_streams): New. diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4 index f33e0c6218..0b49d03212 100644 --- a/libiberty/aclocal.m4 +++ b/libiberty/aclocal.m4 @@ -1,4 +1,3 @@ -sinclude(../config/accross.m4) sinclude(../config/acx.m4) sinclude(../config/no-executables.m4) @@ -120,15 +119,6 @@ if test $libiberty_cv_decl_needed_$1 = yes; then fi ])dnl -# Work around a bug in autoheader. This can go away when we switch to -# autoconf >2.50. The use of define instead of AC_DEFUN is -# deliberate. -define(AC_DEFINE_NOAUTOHEADER, -[cat >> confdefs.h <<\EOF -[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1) -EOF -]) - # We always want a C version of alloca() compiled into libiberty, # because native-compiler support for the real alloca is so !@#$% # unreliable that GCC has decided to use it only when being compiled diff --git a/libiberty/config.in b/libiberty/config.in index 1d8414bd40..82643b7c32 100644 --- a/libiberty/config.in +++ b/libiberty/config.in @@ -1,8 +1,5 @@ /* config.in. Generated from configure.ac by autoheader. */ -/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ -#undef BYTEORDER - /* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. This function is required for alloca.c support on those systems. */ #undef CRAY_STACKSEG_END @@ -343,10 +340,6 @@ /* Define to 1 if you have the `__fsetlocking' function. */ #undef HAVE___FSETLOCKING -/* Define if the host machine stores words of multi-word integers in - big-endian order. */ -#undef HOST_WORDS_BIG_ENDIAN - /* Define if canonicalize_file_name is not declared in system header files. */ #undef NEED_DECLARATION_CANONICALIZE_FILE_NAME @@ -389,7 +382,8 @@ /* Define to an unsigned 64-bit type available in the compiler. */ #undef UNSIGNED_64BIT_TYPE -/* whether byteorder is bigendian */ +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN /* Define to empty if `const' does not conform to ANSI C. */ diff --git a/libiberty/configure b/libiberty/configure index d9c5425642..b7d3e5b5ce 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -3217,8 +3217,7 @@ 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 - ac_cv_c_bigendian=unknown -# See if sys/param.h defines the BYTE_ORDER macro. + # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF @@ -3227,13 +3226,14 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include + int main () { - #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN bogus endian macros #endif + ; return 0; } @@ -3269,13 +3269,14 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include + int main () { - #if BYTE_ORDER != BIG_ENDIAN not big endian #endif + ; return 0; } @@ -3314,11 +3315,69 @@ else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 +# 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 +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +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 () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 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); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (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); }; } && + { 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 + 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 +sed 's/^/| /' conftest.$ac_ext >&5 + fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -if test $ac_cv_c_bigendian = unknown; then -if test "$cross_compiling" = yes; then - echo $ac_n "cross-compiling... " 2>&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -3326,7 +3385,9 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -main () { +int +main () +{ /* Are we little or big endian? From Harbison&Steele. */ union { @@ -3360,67 +3421,26 @@ fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi +rm -f conftest.err 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 -if test $ac_cv_c_bigendian = unknown; then -echo "$as_me:$LINENO: checking to probe for byte ordering" >&5 -echo $ECHO_N "checking to probe for byte ordering... $ECHO_C" >&6 - -cat >conftest.c <&6 - ac_cv_c_bigendian=yes - fi - if test `grep -l LiTTleEnDian conftest.o` ; then - echo $ac_n ' little endian probe OK, ' 1>&6 - if test $ac_cv_c_bigendian = yes ; then - ac_cv_c_bigendian=unknown; - else - ac_cv_c_bigendian=no - fi - fi - echo $ac_n 'guessing bigendian ... ' >&6 - fi - fi -echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6 -fi -if test $ac_cv_c_bigendian = yes; then +case $ac_cv_c_bigendian in + yes) cat >>confdefs.h <<\_ACEOF #define WORDS_BIGENDIAN 1 _ACEOF - - -cat >>confdefs.h <<\_ACEOF -#define HOST_WORDS_BIG_ENDIAN 1 -_ACEOF - - BYTEORDER=4321 -else - BYTEORDER=1234 -fi - -cat >>confdefs.h <<_ACEOF -#define BYTEORDER $BYTEORDER -_ACEOF - -if test $ac_cv_c_bigendian = unknown; then - { { echo "$as_me:$LINENO: error: unknown endianess - sorry, please pre-set ac_cv_c_bigendian" >&5 -echo "$as_me: error: unknown endianess - sorry, please pre-set ac_cv_c_bigendian" >&2;} - { (exit 1); exit 1; }; } -fi + ;; + 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 @@ -5384,9 +5404,9 @@ _ACEOF # dont have to check them here. # Of the functions in $checkfuncs, newlib only has strerror. - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_STRERROR 1 -EOF +_ACEOF setobjs=yes @@ -5428,13 +5448,13 @@ fi case "${host}" in *-*-cygwin* | *-*-mingw*) - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_ERRLIST 1 -EOF +_ACEOF - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_NERR 1 -EOF +_ACEOF ;; esac @@ -5546,9 +5566,9 @@ _ACEOF # don't have to check them here. # Of the functions in $checkfuncs, VxWorks only has strerror. - cat >> confdefs.h <<\EOF + cat >>confdefs.h <<\_ACEOF #define HAVE_STRERROR 1 -EOF +_ACEOF setobjs=yes diff --git a/libiberty/configure.ac b/libiberty/configure.ac index 92362d0b8b..b11fafbcae 100644 --- a/libiberty/configure.ac +++ b/libiberty/configure.ac @@ -130,7 +130,7 @@ AC_SUBST(OUTPUT_OPTION) AC_C_CONST AC_C_INLINE -AC_C_BIGENDIAN_CROSS +AC_C_BIGENDIAN dnl When we start using libtool: dnl Default to a non shared library. This may be overridden by the @@ -328,7 +328,7 @@ if test -n "${with_target_subdir}"; then # dont have to check them here. # Of the functions in $checkfuncs, newlib only has strerror. - AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) + AC_DEFINE(HAVE_STRERROR) setobjs=yes @@ -367,8 +367,8 @@ AC_SUBST(target_header_dir) case "${host}" in *-*-cygwin* | *-*-mingw*) - AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST) - AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR) + AC_DEFINE(HAVE_SYS_ERRLIST) + AC_DEFINE(HAVE_SYS_NERR) ;; esac @@ -406,7 +406,7 @@ if test -z "${setobjs}"; then # don't have to check them here. # Of the functions in $checkfuncs, VxWorks only has strerror. - AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR) + AC_DEFINE(HAVE_STRERROR) setobjs=yes ;;