2 dnl GRAS_DO_CHECK_SIZEOF: Get the size of a datatype (even in cross-compile)
4 dnl 2: extra include lines
5 dnl 3: extra sizes to test
6 dnl ("adapted" from openldap)
8 AC_DEFUN([GRAS_DO_CHECK_SIZEOF],
9 [changequote(<<, >>)dnl
10 dnl The cache variable name (and of the result).
11 define(<<GRAS_CHECK_SIZEOF_RES>>, translit(ac_cv_sizeof_$1, [ *()], [_pLR]))dnl
13 AC_CACHE_VAL(GRAS_CHECK_SIZEOF_RES,
14 [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence.
15 AC_TRY_COMPILE([#include "confdefs.h"
16 #include <sys/types.h>
18 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], GRAS_CHECK_SIZEOF_RES=$ac_size)
19 if test x$GRAS_CHECK_SIZEOF_RES != x ; then break; fi
25 dnl GRAS_CHECK_SIZEOF: Get the size of a datatype (even in cross-compile), with msg display, and define the result
27 dnl 2: extra include lines
28 dnl 3: extra sizes to test
29 dnl ("adapted" from openldap)
31 AC_DEFUN([GRAS_CHECK_SIZEOF],
32 [AC_MSG_CHECKING(size of $1)
33 GRAS_DO_CHECK_SIZEOF($1,$2)
34 if test x$GRAS_CHECK_SIZEOF_RES = x ; then
35 AC_MSG_ERROR([cannot determine a size for $1])
37 AC_MSG_RESULT($GRAS_CHECK_SIZEOF_RES)
38 changequote(<<, >>)dnl
39 dnl The name to #define.
40 define(<<TYPE_NAME>>, translit(sizeof_$1, [a-z *()], [A-Z_P__]))dnl
42 AC_DEFINE_UNQUOTED(TYPE_NAME, $GRAS_CHECK_SIZEOF_RES, [The number of bytes in type $1])
43 undefine([TYPE_NAME])dnl
48 dnl GRAS_SIGNED_SIZEOF: Get the size of the datatype, and make sure that
49 dnl signed, unsigned and unspecified have the same size
51 AC_DEFUN([GRAS_SIGNED_SIZEOF],
52 [AC_MSG_CHECKING(size of $1)
53 GRAS_DO_CHECK_SIZEOF($1,$2)
54 unspecif=$GRAS_CHECK_SIZEOF_RES
55 if test x$unspecif = x ; then
56 AC_MSG_ERROR([cannot determine a size for $1])
59 GRAS_DO_CHECK_SIZEOF(signed $1,$2)
60 signed=$GRAS_CHECK_SIZEOF_RES
61 if test x$signed = x ; then
62 AC_MSG_ERROR([cannot determine a size for signed $1])
64 if test x$unspecif != x$signed ; then
65 AC_MSG_ERROR(['signed $1' and '$1' have different sizes ! ($signed != $unspecif)])
68 GRAS_DO_CHECK_SIZEOF(unsigned $1,$2)
69 unsigned=$GRAS_CHECK_SIZEOF_RES
70 if test x$unsigned = x ; then
71 AC_MSG_ERROR([cannot determine a size for unsigned $1])
73 if test x$unsigned != x$signed ; then
74 AC_MSG_ERROR(['signed $1' and 'unsigned $1' have different sizes ! ($signed != $unsigned)])
77 AC_MSG_RESULT($GRAS_CHECK_SIZEOF_RES)
78 changequote(<<, >>)dnl
79 dnl The name to #define.
80 define(<<TYPE_NAME>>, translit(sizeof_$1, [a-z *()], [A-Z_P__]))dnl
82 AC_DEFINE_UNQUOTED(TYPE_NAME, $GRAS_CHECK_SIZEOF_RES, [The number of bytes in type $1])
83 undefine([TYPE_NAME])dnl
87 dnl End of CHECK_SIGNED_SIZEOF
90 dnl CHECK_IEEE_FP: determines if floating points are IEEE754 compliant
91 dnl (inspired from NWS code)
93 AC_DEFUN([CHECK_IEEE_FP],
94 [AC_MSG_CHECKING(if floating point datatypes are IEEE 754 compliant)
95 AC_TRY_COMPILE([#include "confdefs.h"
98 unsigned char bytes[sizeof(double)];
102 unsigned char bytes[sizeof(float)];
105 memset(&doubleTester, 0, sizeof(doubleTester));
106 memset(&floatTester, 0, sizeof(floatTester));
108 doubleTester.bytes[GRAS_BIGENDIAN ? sizeof(double) - 1 : 0]=192;
109 doubleTester.bytes[GRAS_BIGENDIAN ? sizeof(double) - 2 : 1] =
110 (sizeof(double) == 4) ? 128 :
111 (sizeof(double) == 8) ? 16 :
112 (sizeof(double) == 16) ? 1 : 0;
113 if (doubleTester.testFP != -4.0) return 1;
115 floatTester.bytes[GRAS_BIGENDIAN ? sizeof(float) - 1 : 0]=192;
116 floatTester.bytes[GRAS_BIGENDIAN ? sizeof(float) - 2 : 1] =
117 (sizeof(float) == 4) ? 128 :
118 (sizeof(float) == 8) ? 16 :
119 (sizeof(float) == 16) ? 1 : 0;
120 if (floatTester.testFP != -4.0) return 1;
122 return 0;],[IEEE_FP=yes
123 AC_DEFINE(IEEE_FP,1,[defines if this architecture floating point types are IEEE754 compliant])
125 AC_MSG_ERROR([GRAS works only for little or big endian systems (yet)])])dnl end of AC_TRY_COMPILE
126 AC_MSG_RESULT($IEEE_FP)
127 ])dnl end of CHECK_IEEE_FP
131 dnl *************************8
133 AC_DEFUN([GRAS_ARCH],
135 # Check for the architecture
136 AC_C_BIGENDIAN(endian=1,endian=0,AC_MSG_ERROR([GRAS works only for little or big endian systems (yet)]))
137 AC_DEFINE_UNQUOTED(GRAS_BIGENDIAN,$endian,[define if big endian])
139 GRAS_SIGNED_SIZEOF(char)
140 GRAS_SIGNED_SIZEOF(short int)
141 GRAS_SIGNED_SIZEOF(int)
142 GRAS_SIGNED_SIZEOF(long int)
143 GRAS_SIGNED_SIZEOF(long long int)
146 GRAS_CHECK_SIZEOF(void *)
147 GRAS_CHECK_SIZEOF(void (*) (void))
149 GRAS_CHECK_SIZEOF(float)
150 GRAS_CHECK_SIZEOF(double)
153 AC_MSG_CHECKING(the GRAS signature of this architecture)
154 if test x$endian = x1 ; then
160 trace="$trace_endian"
161 trace="${trace}:${ac_cv_sizeof_char}.${ac_cv_sizeof_short_int}.${ac_cv_sizeof_int}.${ac_cv_sizeof_long_int}.${ac_cv_sizeof_long_long_int}"
162 trace="${trace}:${ac_cv_sizeof_void_p}.${ac_cv_sizeof_void_LpR_LvoidR}"
163 trace="${trace}:${ac_cv_sizeof_float}.${ac_cv_sizeof_double}"
165 l:1.2.4.4.8:4.4:4.8) gras_arch=0; gras_arch_name=i386;;
167 if test x$gras_arch = xunknown ; then
168 AC_MSG_RESULT([damnit ($trace)])
169 AC_MSG_ERROR([Impossible to determine the GRAS architecture signature.
170 Please report this architecture trace ($trace) and what it corresponds to.])
172 echo "$as_me:$LINENO: GRAS trace of this machine: $trace" >&AS_MESSAGE_LOG_FD
173 AC_DEFINE_UNQUOTED(GRAS_THISARCH_NAME,"$gras_arch_name",[defines the GRAS architecture name of this machine])
174 AC_DEFINE_UNQUOTED(GRAS_THISARCH,$gras_arch,[defines the GRAS architecture signature of this machine])
175 AC_MSG_RESULT($gras_arch ($gras_arch_name))