1AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], 2[changequote(<<, >>)dnl 3dnl The name to #define. 4define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl 5dnl The cache variable name. 6define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl 7changequote([, ])dnl 8AC_MSG_CHECKING(size of $1) 9AC_CACHE_VAL(AC_CV_NAME, 10[for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of prevalence. 11 AC_TRY_COMPILE([#include "confdefs.h" 12#include <sys/types.h> 13$2 14], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) 15 if test x$AC_CV_NAME != x ; then break; fi 16done 17]) 18if test x$AC_CV_NAME = x ; then 19 AC_MSG_ERROR([cannot determine a size for $1]) 20fi 21AC_MSG_RESULT($AC_CV_NAME) 22AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) 23undefine([AC_TYPE_NAME])dnl 24undefine([AC_CV_NAME])dnl 25]) 26 27AC_DEFUN([AC_C_BIGENDIAN_CROSS], 28[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian, 29[ac_cv_c_bigendian=unknown 30# See if sys/param.h defines the BYTE_ORDER macro. 31AC_TRY_COMPILE([#include <sys/types.h> 32#include <sys/param.h>], [ 33#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN 34 bogus endian macros 35#endif], [# It does; now see whether it defined to BIG_ENDIAN or not. 36AC_TRY_COMPILE([#include <sys/types.h> 37#include <sys/param.h>], [ 38#if BYTE_ORDER != BIG_ENDIAN 39 not big endian 40#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)]) 41if test $ac_cv_c_bigendian = unknown; then 42AC_TRY_RUN([main () { 43 /* Are we little or big endian? From Harbison&Steele. */ 44 union 45 { 46 long l; 47 char c[sizeof (long)]; 48 } u; 49 u.l = 1; 50 exit (u.c[sizeof (long) - 1] == 1); 51}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, 52[ echo $ac_n "cross-compiling... " 2>&AC_FD_MSG ]) 53fi]) 54if test $ac_cv_c_bigendian = unknown; then 55AC_MSG_CHECKING(to probe for byte ordering) 56[ 57cat >conftest.c <<EOF 58short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; 59short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; 60void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; } 61short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; 62short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; 63void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; } 64int main() { _ascii (); _ebcdic (); return 0; } 65EOF 66] if test -f conftest.c ; then 67 if ${CC-cc} ${CFLAGS} conftest.c -o conftest.o && test -f conftest.o ; then 68 if test `grep -l BIGenDianSyS conftest.o` ; then 69 echo $ac_n ' big endian probe OK, ' 1>&AC_FD_MSG 70 ac_cv_c_bigendian=yes 71 fi 72 if test `grep -l LiTTleEnDian conftest.o` ; then 73 echo $ac_n ' little endian probe OK, ' 1>&AC_FD_MSG 74 if test $ac_cv_c_bigendian = yes ; then 75 ac_cv_c_bigendian=unknown; 76 else 77 ac_cv_c_bigendian=no 78 fi 79 fi 80 echo $ac_n 'guessing bigendian ... ' >&AC_FD_MSG 81 fi 82 fi 83AC_MSG_RESULT($ac_cv_c_bigendian) 84fi 85if test $ac_cv_c_bigendian = yes; then 86 AC_DEFINE(WORDS_BIGENDIAN, 1, [whether byteorder is bigendian]) 87 AC_DEFINE(HOST_WORDS_BIG_ENDIAN, 1, 88 [Define if the host machine stores words of multi-word integers in 89 big-endian order.]) 90 BYTEORDER=4321 91else 92 BYTEORDER=1234 93fi 94AC_DEFINE_UNQUOTED(BYTEORDER, $BYTEORDER, [1234 = LIL_ENDIAN, 4321 = BIGENDIAN]) 95if test $ac_cv_c_bigendian = unknown; then 96 AC_MSG_ERROR(unknown endianess - sorry, please pre-set ac_cv_c_bigendian) 97fi 98]) 99