Commit | Line | Data |
---|---|---|
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_strtoull: Inlibc d_longlong Compile cat run |
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:. |
0065f4af | 20 | ?F:!try |
edd6115f JH |
21 | : see if strtoull exists |
22 | set strtoull d_strtoull | |
e0d71d2f | 23 | eval $inlibc |
edd6115f | 24 | |
2bc4e3e5 JH |
25 | case "$d_longlong-$d_strtoull" in |
26 | "$define-$define") | |
27 | $cat <<EOM | |
28 | Checking whether your strtoull() works okay... | |
29 | EOM | |
30 | $cat >try.c <<'EOCP' | |
31 | #include <errno.h> | |
32 | #ifdef __hpux | |
33 | #define strtoull __strtoull | |
34 | #endif | |
35 | #include <stdio.h> | |
0065f4af | 36 | extern unsigned long long int strtoull(char *s, char **, int); |
2bc4e3e5 JH |
37 | static int bad = 0; |
38 | int check(char *s, long long eull, int een) { | |
39 | long long gull; | |
40 | errno = 0; | |
41 | gull = strtoull(s, 0, 10); | |
42 | if (!((gull == eull) && (errno == een))) | |
43 | bad++; | |
44 | } | |
45 | int main() { | |
6e4a03c9 JH |
46 | check(" 1", 1LL, 0); |
47 | check(" 0", 0LL, 0); | |
48 | check("18446744073709551615", 18446744073709551615ULL, 0); | |
49 | check("18446744073709551616", 18446744073709551615ULL, ERANGE); | |
357ef92f | 50 | #if 0 /* strtoull() for /^-/ strings is undefined. */ |
6e4a03c9 JH |
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); | |
357ef92f | 56 | #endif |
2bc4e3e5 JH |
57 | if (!bad) |
58 | printf("ok\n"); | |
59 | } | |
60 | EOCP | |
61 | set try | |
62 | if eval $compile; then | |
0f00356b | 63 | case "`$run ./try`" in |
2bc4e3e5 JH |
64 | ok) echo "Your strtoull() seems to be working okay." ;; |
65 | *) cat <<EOM >&4 | |
66 | Your strtoull() doesn't seem to be working okay. | |
67 | EOM | |
68 | d_strtoull="$undef" | |
69 | ;; | |
70 | esac | |
ee6ec6d2 MB |
71 | else |
72 | echo "(I can't seem to compile the test program--assuming it doesn't)" | |
73 | d_strtoull="$undef" | |
2bc4e3e5 JH |
74 | fi |
75 | ;; | |
76 | esac | |
77 |