?RCS: $Id$
?RCS:
?RCS: Copyright (c) 2000 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_strtoull: Inlibc d_longlong Compile cat run
?MAKE:	-pick add $@ %<
?S:d_strtoull:
?S:	This variable conditionally defines the HAS_STRTOULL symbol, which
?S:	indicates to the C program that the strtoull() routine is available.
?S:.
?C:HAS_STRTOULL:
?C:	This symbol, if defined, indicates that the strtoull routine is
?C:	available to convert strings to unsigned long longs.
?C:.
?H:#$d_strtoull HAS_STRTOULL		/**/
?H:.
?F:!try
: see if strtoull exists
set strtoull d_strtoull
eval $inlibc

case "$d_longlong-$d_strtoull" in
"$define-$define")
	$cat <<EOM
Checking whether your strtoull() works okay...
EOM
	$cat >try.c <<'EOCP'
#include <stdlib.h>
#include <errno.h>
#ifdef __hpux
#define strtoull __strtoull
#endif
#include <stdio.h>
static int bad = 0;
void check(const char *s, long long eull, int een) {
	long long gull;
	errno = 0;
	gull = strtoull(s, 0, 10);
	if (!((gull == eull) && (errno == een)))
		bad++;
}
int main() {
	check(" 1",                                        1LL, 0);
	check(" 0",                                        0LL, 0);
	check("18446744073709551615",  18446744073709551615ULL, 0);
	check("18446744073709551616",  18446744073709551615ULL, ERANGE);
#if 0 /* strtoull() for /^-/ strings is undefined. */
	check("-1",                    18446744073709551615ULL, 0);
	check("-18446744073709551614",                     2LL, 0);
	check("-18446744073709551615",                     1LL, 0);
	check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
	check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
#endif
	if (!bad)
		printf("ok\n");
}
EOCP
	set try
	if eval $compile; then
		case "`$run ./try`" in
		ok) echo "Your strtoull() seems to be working okay." ;;
		*) cat <<EOM >&4
Your strtoull() doesn't seem to be working okay.
EOM
		   d_strtoull="$undef"
		   ;;
		esac
	else
		echo "(I can't seem to compile the test program--assuming it doesn't)"
		d_strtoull="$undef"
	fi
	;;
esac

