This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Metaconfig changes for #8120.
[metaconfig.git] / U / perl / d_strtoull.U
CommitLineData
e0d71d2f
JH
1?RCS: $Id$
2?RCS:
3?RCS: Copyright (c) 2000 Jarkko Hietaniemi
4?RCS:
5?RCS: You may distribute under the terms of either the GNU General Public
6?RCS: License or the Artistic License, as specified in the README file.
7?RCS:
2bc4e3e5 8?MAKE:d_strtoull: Inlibc d_longlong Compile cat
e0d71d2f 9?MAKE: -pick add $@ %<
edd6115f
JH
10?S:d_strtoull:
11?S: This variable conditionally defines the HAS_STRTOULL symbol, which
12?S: indicates to the C program that the strtoull() routine is available.
e0d71d2f 13?S:.
edd6115f
JH
14?C:HAS_STRTOULL:
15?C: This symbol, if defined, indicates that the strtoull routine is
e0d71d2f
JH
16?C: available to convert strings to unsigned long longs.
17?C:.
edd6115f 18?H:#$d_strtoull HAS_STRTOULL /**/
e0d71d2f 19?H:.
2bc4e3e5 20?F:!try
edd6115f
JH
21?LINT:set d_strtoull
22: see if strtoull exists
23set strtoull d_strtoull
e0d71d2f 24eval $inlibc
edd6115f 25
2bc4e3e5
JH
26case "$d_longlong-$d_strtoull" in
27"$define-$define")
28 $cat <<EOM
29Checking whether your strtoull() works okay...
30EOM
31 $cat >try.c <<'EOCP'
32#include <errno.h>
33#ifdef __hpux
34#define strtoull __strtoull
35#endif
36#include <stdio.h>
37extern unsigned long long int strtoull(char *s, char **, int);
38static int bad = 0;
39int check(char *s, long long eull, int een) {
40 long long gull;
41 errno = 0;
42 gull = strtoull(s, 0, 10);
43 if (!((gull == eull) && (errno == een)))
44 bad++;
45}
46int main() {
6e4a03c9
JH
47 check(" 1", 1LL, 0);
48 check(" 0", 0LL, 0);
49 check("18446744073709551615", 18446744073709551615ULL, 0);
50 check("18446744073709551616", 18446744073709551615ULL, ERANGE);
51 check("-1", 18446744073709551615ULL, 0);
52 check("-18446744073709551614", 2LL, 0);
53 check("-18446744073709551615", 1LL, 0);
54 check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
55 check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
2bc4e3e5
JH
56 if (!bad)
57 printf("ok\n");
58}
59EOCP
60 set try
61 if eval $compile; then
62 case "`./try`" in
63 ok) echo "Your strtoull() seems to be working okay." ;;
64 *) cat <<EOM >&4
65Your strtoull() doesn't seem to be working okay.
66EOM
67 d_strtoull="$undef"
68 ;;
69 esac
70 fi
71 ;;
72esac
73