This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / d_strtoll.U
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:
8 ?MAKE:d_strtoll: Inlibc d_longlong Compile cat run
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:.
20 ?T:yyy
21 ?F:!try
22 : see if strtoll exists
23 set strtoll d_strtoll
24 eval $inlibc
25
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
36 #ifdef __EMX__
37 #define strtoll _strtoll
38 #endif
39 #include <stdio.h>
40 extern long long int strtoll(char *s, char **, int);
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
65                 yyy=`$run ./try`
66                 case "$yyy" in
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                    ;;
73                 esac
74         else
75                 echo "(I can't seem to compile the test program--assuming it doesn't)"
76                 d_strtoll="$undef"
77         fi
78         ;;
79 esac
80