This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add support for Bitrig BSD
[metaconfig.git] / U / perl / d_strtouq.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:
0f00356b 8?MAKE:d_strtouq: Inlibc cat Compile run
e0d71d2f
JH
9?MAKE: -pick add $@ %<
10?S:d_strtouq:
11?S: This variable conditionally defines the HAS_STRTOUQ symbol, which
12?S: indicates to the C program that the strtouq() routine is available.
13?S:.
14?C:HAS_STRTOUQ:
15?C: This symbol, if defined, indicates that the strtouq routine is
16?C: available to convert strings to unsigned long longs (quads).
17?C:.
18?H:#$d_strtouq HAS_STRTOUQ /**/
19?H:.
0065f4af 20?F:!try
e0d71d2f
JH
21: see if strtouq exists
22set strtouq d_strtouq
23eval $inlibc
edd6115f 24
6e4a03c9
JH
25case "$d_strtouq" in
26"$define")
27 $cat <<EOM
28Checking whether your strtouq() works okay...
29EOM
30 $cat >try.c <<'EOCP'
31#include <errno.h>
32#include <stdio.h>
0065f4af 33extern unsigned long long int strtouq(char *s, char **, int);
6e4a03c9
JH
34static int bad = 0;
35void check(char *s, unsigned long long eull, int een) {
36 unsigned long long gull;
37 errno = 0;
38 gull = strtouq(s, 0, 10);
39 if (!((gull == eull) && (errno == een)))
40 bad++;
41}
42int main() {
43 check(" 1", 1LL, 0);
44 check(" 0", 0LL, 0);
45 check("18446744073709551615", 18446744073709551615ULL, 0);
46 check("18446744073709551616", 18446744073709551615ULL, ERANGE);
357ef92f 47#if 0 /* strtouq() for /^-/ strings is undefined. */
6e4a03c9
JH
48 check("-1", 18446744073709551615ULL, 0);
49 check("-18446744073709551614", 2LL, 0);
50 check("-18446744073709551615", 1LL, 0);
51 check("-18446744073709551616", 18446744073709551615ULL, ERANGE);
52 check("-18446744073709551617", 18446744073709551615ULL, ERANGE);
357ef92f 53#endif
6e4a03c9
JH
54 if (!bad)
55 printf("ok\n");
56 return 0;
57}
58EOCP
59 set try
60 if eval $compile; then
0f00356b 61 case "`$run ./try`" in
6e4a03c9
JH
62 ok) echo "Your strtouq() seems to be working okay." ;;
63 *) cat <<EOM >&4
64Your strtouq() doesn't seem to be working okay.
65EOM
66 d_strtouq="$undef"
67 ;;
68 esac
ee6ec6d2
MB
69 else
70 echo "(I can't seem to compile the test program--assuming it doesn't)"
71 d_strtouq="$undef"
6e4a03c9
JH
72 fi
73 ;;
74esac
75