?RCS: $Id$
?RCS:
?RCS: Copyright (c) 1999 Jarkko Hietaniemi
?RCS:
?RCS: You may distribute under the terms of either the GNU General Public
?RCS: License or the Artistic License, as specified in the README file.
?RCS:
?MAKE:d_quad quadtype uquadtype quadkind: \
	longsize intsize d_longlong longlongsize d_int64_t \
	Inhdr Setvar
?MAKE:	-pick add $@ %<
?S:d_quad:
?S:	This variable, if defined, tells that there's a 64-bit integer type,
?S:	quadtype.
?S:.
?S:quadtype:
?S:	This variable defines Quad_t to be something like long, int,
?S:	long long, int64_t, or whatever type is used for 64-bit integers.
?S:.
?S:quadkind:
?S:	This variable, if defined, encodes the type of a quad:
?S:	1 = int, 2 = long, 3 = long long, 4 = int64_t.
?S:.
?S:uquadtype:
?S:	This variable defines Uquad_t to be something like unsigned long,
?S:	unsigned int, unsigned long long, uint64_t, or whatever type is
?S:	used for 64-bit integers.
?S:.
?C:HAS_QUAD:
?C:	This symbol, if defined, tells that there's a 64-bit integer type,
?C:	Quad_t, and its unsigned counterpart, Uquad_t. QUADKIND will be one
?C:	of QUAD_IS_INT, QUAD_IS_LONG, QUAD_IS_LONG_LONG, QUAD_IS_INT64_T,
?C:	or QUAD_IS___INT64.
?C:.
?H:#$d_quad HAS_QUAD	/**/
?H:?%<:#ifdef HAS_QUAD
?H:?%<:#   define Quad_t $quadtype	/**/
?H:?%<:#   define Uquad_t $uquadtype	/**/
?H:?%<:#   define QUADKIND $quadkind	/**/
?H:?%<:#   define QUAD_IS_INT	1
?H:?%<:#   define QUAD_IS_LONG	2
?H:?%<:#   define QUAD_IS_LONG_LONG	3
?H:?%<:#   define QUAD_IS_INT64_T	4
?H:?%<:#   define QUAD_IS___INT64	5
?H:?%<:#endif
?H:.
?LINT:set quadtype
?LINT:set uquadtype
: Check if 64bit ints have a quad type
echo " "
echo "Checking which 64-bit integer type we could use..." >&4
?X: We prefer quad types in order of int, long, long long, int64_t.

case "$intsize" in
8) val=int
   set quadtype
   eval $setvar
   val='"unsigned int"'
   set uquadtype
   eval $setvar
   quadkind=1
   ;;
*) case "$longsize" in
   8) val=long
      set quadtype
      eval $setvar
      val='"unsigned long"'
      set uquadtype
      eval $setvar
      quadkind=2
      ;;
   *) case "$d_longlong:$longlongsize" in
      define:8)
        val='"long long"'
        set quadtype
        eval $setvar
        val='"unsigned long long"'
        set uquadtype
        eval $setvar
        quadkind=3
        ;;
      *) case "$d_int64_t" in
         define)
           val=int64_t
           set quadtype
           eval $setvar
           val=uint64_t
           set uquadtype
           eval $setvar
           quadkind=4
           ;;
         esac
         ;;
      esac
      ;;
   esac
   ;;
esac

case "$quadtype" in
'')	echo "Alas, no 64-bit integer types in sight." >&4
	d_quad="$undef"
	;;
*)	echo "We could use '$quadtype' for 64-bit integers." >&4
	d_quad="$define"
	;;
esac

