+# BEGIN OF GRAS ARCH CHECK
dnl
dnl GRAS_DO_CHECK_SIZEOF: Get the size of a datatype (even in cross-compile)
dnl 1: type tested
undefine([TYPE_NAME])dnl
])
+dnl
+dnl GRAS_TWO_COMPLIMENT: Make sure the type is two-compliment
+dnl
+AC_DEFUN([GRAS_TWO_COMPLIMENT],
+[
+AC_TRY_COMPILE([#include "confdefs.h"
+union {
+ signed $1 testInt;
+ unsigned char bytes[sizeof($1)];
+} intTester;
+],[
+ intTester.testInt = -2;
+ return ((unsigned int)intTester.bytes[0] +
+ (unsigned int)intTester.bytes[sizeof($1) - 1]) != 509;
+],[],[AC_MSG_ERROR([GRAS works only two-compliment integers (yet)])])dnl end of AC_TRY_COMPILE
+])
dnl
dnl GRAS_SIGNED_SIZEOF: Get the size of the datatype, and make sure that
AC_MSG_ERROR(['signed $1' and 'unsigned $1' have different sizes ! ($signed != $unsigned)])
fi
+dnl Make sure we don't run on a non-two-compliment arch, since we dunno
+dnl convert them
+GRAS_TWO_COMPLIMENT($1)
+
AC_MSG_RESULT($GRAS_CHECK_SIZEOF_RES)
changequote(<<, >>)dnl
dnl The name to #define.
unsigned char bytes[sizeof(float)];
} floatTester;
],[
+if (sizeof(double) != 8 || sizeof(float) != 4)
+ return 1;
+
memset(&doubleTester, 0, sizeof(doubleTester));
memset(&floatTester, 0, sizeof(floatTester));
# Check for the architecture
AC_C_BIGENDIAN(endian=1,endian=0,AC_MSG_ERROR([GRAS works only for little or big endian systems (yet)]))
AC_DEFINE_UNQUOTED(GRAS_BIGENDIAN,$endian,[define if big endian])
-
+
GRAS_SIGNED_SIZEOF(char)
GRAS_SIGNED_SIZEOF(short int)
GRAS_SIGNED_SIZEOF(int)
trace="${trace}:${ac_cv_sizeof_void_p}.${ac_cv_sizeof_void_LpR_LvoidR}"
trace="${trace}:${ac_cv_sizeof_float}.${ac_cv_sizeof_double}"
case $trace in
- l:1.2.4.4.8:4.4:4.8) gras_arch=0; gras_arch_name=i386;;
- B:1.2.4.4.8:4.4:4.8) gras_arch=1; gras_arch_name=ppc;;
+ l:1.2.4.4.8:4.4:4.8) gras_arch=0; gras_arch_name=little32;;
+ l:1.2.4.8.8:8.8:4.8) gras_arch=1; gras_arch_name=little64;;
+ B:1.2.4.4.8:4.4:4.8) gras_arch=2; gras_arch_name=big32;;
+ B:1.2.4.8.8:8.8:4.8) gras_arch=3; gras_arch_name=big64;;
esac
if test x$gras_arch = xunknown ; then
AC_MSG_RESULT([damnit ($trace)])
AC_DEFINE_UNQUOTED(GRAS_THISARCH,$gras_arch,[defines the GRAS architecture signature of this machine])
AC_MSG_RESULT($gras_arch ($gras_arch_name))
])
+# END OF GRAS ARCH CHECK