Overhaul `math' representation machinery.
[u/mdw/catacomb] / configure.ac
index aca24fe..7c66807 100644 (file)
@@ -61,6 +61,70 @@ AC_SEARCH_LIBS([sqrt], [m])
 AC_SUBST([CATACOMB_LIBS], [$LIBS])
 LIBS=$mdw_ORIG_LIBS
 
+dnl Find out whether very long integer types are available.
+AC_CHECK_HEADERS([stdint.h])
+AC_SUBST([have_stdint_h])
+AC_C_LONG_LONG
+
+dnl Find the bit lengths of the obvious integer types.  This will be useful
+dnl when deciding on a representation for multiprecision integers.
+type_bits="" type_bits_sep=""
+AC_DEFUN([catacomb_UINT_BITS],
+  [mdw_UINT_BITS([$2], [$1])
+   type_bits="$type_bits$type_bits_sep('$1', $[]$1_bits)"
+   type_bits_sep=", "])
+catacomb_UINT_BITS([uchar], [unsigned char])
+catacomb_UINT_BITS([ushort], [unsigned short])
+catacomb_UINT_BITS([uint], [unsigned int])
+catacomb_UINT_BITS([ulong], [unsigned long])
+if test "$ac_cv_c_long_long" = "yes"; then
+  catacomb_UINT_BITS([ullong], [unsigned long long])
+fi
+if test "$ac_cv_header_stdint_h" = "yes"; then
+  catacomb_UINT_BITS([uintmax], [uintmax_t])
+fi
+AC_SUBST([type_bits])
+
+dnl Determine the limits of common C integer types.
+limits="" limits_sep=""
+AC_DEFUN([catacomb_COMPILE_TIME_CONSTANT],
+  [case "$2" in
+     =*)
+       $1="$2"; $1=${$1#=}
+       ;;
+     *)
+       AC_CACHE_CHECK([compile-time value of $2], [mdw_cv_constant_$3],
+                     [mdw_PROBE_CONSTANT([mdw_cv_constant_$3], [$2], [$4])])
+       $1=$mdw_cv_constant_$3
+       ;;
+   esac])
+AC_DEFUN([catacomb_LIMIT],
+[catacomb_COMPILE_TIME_CONSTANT([lo], [$2], [$1_min],
+[#include <limits.h>
+#include <stddef.h>])
+ catacomb_COMPILE_TIME_CONSTANT([hi], [$3], [$1_max],
+[#include <limits.h>
+#include <stddef.h>])
+ limits="$limits$limits_sep('$1', $lo, $hi)" limits_sep=", "])
+catacomb_LIMIT([SCHAR],                [SCHAR_MIN],    [SCHAR_MAX])
+catacomb_LIMIT([CHAR],         [CHAR_MIN],     [CHAR_MAX])
+catacomb_LIMIT([UCHAR],                [=0],           [UCHAR_MAX])
+catacomb_LIMIT([UINT8],                [=0],           [=0xff])
+catacomb_LIMIT([SHRT],         [SHRT_MIN],     [SHRT_MAX])
+catacomb_LIMIT([USHRT],                [=0],           [USHRT_MAX])
+catacomb_LIMIT([UINT16],       [=0],           [=0xffff])
+catacomb_LIMIT([INT],          [INT_MIN],      [INT_MAX])
+catacomb_LIMIT([UINT],         [=0],           [UINT_MAX])
+catacomb_LIMIT([LONG],         [LONG_MIN],     [LONG_MAX])
+catacomb_LIMIT([ULONG],                [=0],           [ULONG_MAX])
+catacomb_LIMIT([UINT32],       [=0],           [=0xffffffff])
+if test "$ac_cv_c_long_long" = "yes"; then
+  catacomb_LIMIT([LLONG],      [LLONG_MIN],    [LLONG_MAX])
+  catacomb_LIMIT([ULLONG],     [=0],           [ULLONG_MAX])
+fi
+catacomb_LIMIT([SIZET],                [=0],           [~(size_t)0])
+AC_SUBST([limits])
+
 dnl Functions used for noise-gathering.
 AC_CHECK_FUNCS([setgroups])
 AC_CACHE_CHECK([whether the freewheel noise generator will work],