Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More debug; cosmetics
[simgrid.git] / acmacro / gras_arch.m4
index 146f649..d652120 100644 (file)
@@ -1,3 +1,4 @@
+# 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
@@ -43,6 +44,22 @@ AC_DEFINE_UNQUOTED(TYPE_NAME, $GRAS_CHECK_SIZEOF_RES, [The number of bytes in ty
 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
@@ -74,6 +91,10 @@ if test x$unsigned != x$signed ; then
   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. 
@@ -102,6 +123,9 @@ union {
         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));
 
@@ -135,7 +159,7 @@ AC_DEFUN([GRAS_ARCH],
 # 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)
@@ -162,8 +186,10 @@ trace="${trace}:${ac_cv_sizeof_char}.${ac_cv_sizeof_short_int}.${ac_cv_sizeof_in
 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)])
@@ -175,3 +201,4 @@ AC_DEFINE_UNQUOTED(GRAS_THISARCH_NAME,"$gras_arch_name",[defines the GRAS archit
 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