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_strtoll: Inlibc d_longlong Compile cat run |
e0d71d2f JH |
9 | ?MAKE: -pick add $@ %< |
10 | ?S:d_strtoll: | |
11 | ?S: This variable conditionally defines the HAS_STRTOLL symbol, which | |
12 | ?S: indicates to the C program that the strtoll() routine is available. | |
13 | ?S:. | |
14 | ?C:HAS_STRTOLL: | |
15 | ?C: This symbol, if defined, indicates that the strtoll routine is | |
16 | ?C: available to convert strings to long longs. | |
17 | ?C:. | |
18 | ?H:#$d_strtoll HAS_STRTOLL /**/ | |
19 | ?H:. | |
4df9185f | 20 | ?T:yyy |
0065f4af | 21 | ?F:!try |
e0d71d2f JH |
22 | : see if strtoll exists |
23 | set strtoll d_strtoll | |
24 | eval $inlibc | |
edd6115f | 25 | |
2bc4e3e5 JH |
26 | case "$d_longlong-$d_strtoll" in |
27 | "$define-$define") | |
28 | $cat <<EOM | |
29 | Checking whether your strtoll() works okay... | |
30 | EOM | |
31 | $cat >try.c <<'EOCP' | |
32 | #include <errno.h> | |
33 | #ifdef __hpux | |
34 | #define strtoll __strtoll | |
35 | #endif | |
4df9185f YST |
36 | #ifdef __EMX__ |
37 | #define strtoll _strtoll | |
38 | #endif | |
2bc4e3e5 | 39 | #include <stdio.h> |
0065f4af | 40 | extern long long int strtoll(char *s, char **, int); |
2bc4e3e5 JH |
41 | static int bad = 0; |
42 | int check(char *s, long long ell, int een) { | |
43 | long long gll; | |
44 | errno = 0; | |
45 | gll = strtoll(s, 0, 10); | |
46 | if (!((gll == ell) && (errno == een))) | |
47 | bad++; | |
48 | } | |
49 | int main() { | |
50 | check(" 1", 1LL, 0); | |
51 | check(" 0", 0LL, 0); | |
52 | check("-1", -1LL, 0); | |
53 | check("-9223372036854775808", -9223372036854775808LL, 0); | |
54 | check("-9223372036854775808", -9223372036854775808LL, 0); | |
55 | check(" 9223372036854775807", 9223372036854775807LL, 0); | |
56 | check("-9223372036854775808", -9223372036854775808LL, 0); | |
57 | check(" 9223372036854775808", 9223372036854775807LL, ERANGE); | |
58 | check("-9223372036854775809", -9223372036854775808LL, ERANGE); | |
59 | if (!bad) | |
60 | printf("ok\n"); | |
61 | } | |
62 | EOCP | |
63 | set try | |
64 | if eval $compile; then | |
0f00356b | 65 | yyy=`$run ./try` |
4df9185f | 66 | case "$yyy" in |
2bc4e3e5 JH |
67 | ok) echo "Your strtoll() seems to be working okay." ;; |
68 | *) cat <<EOM >&4 | |
69 | Your strtoll() doesn't seem to be working okay. | |
70 | EOM | |
71 | d_strtoll="$undef" | |
72 | ;; | |
77ef11cc | 73 | esac |
4df9185f YST |
74 | else |
75 | echo "(I can't seem to compile the test program--assuming it doesn't)" | |
76 | d_strtoll="$undef" | |
2bc4e3e5 JH |
77 | fi |
78 | ;; | |
79 | esac | |
80 |