This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Even better use64bitall logic.
[metaconfig.git] / U / perl / quadfio.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 1999 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_PRId64 d_PRIi64 d_PRIu64 d_PRIo64 d_PRIx64 d_PRIX64 \
9         sPRId64 sPRIi64 sPRIu64 sPRIo64 sPRIx64 sPRIX64: \
10         quadtype i_inttypes test cat rm Setvar Compile exe_ext
11 ?MAKE:  -pick add $@ %<
12 ?S:d_PRId64:
13 ?S:     This variable conditionally defines the PERL_PRId64 symbol, which
14 ?S:     indiciates that stdio has a symbol to print 64-bit decimal numbers.
15 ?S:.
16 ?S:d_PRIi64:
17 ?S:     This variable conditionally defines the PERL_PRIi64 symbol, which
18 ?S:     indiciates that stdio has a symbol to print 64-bit decimal numbers.
19 ?S:.
20 ?S:d_PRIu64:
21 ?S:     This variable conditionally defines the PERL_PRIu64 symbol, which
22 ?S:     indiciates that stdio has a symbol to print 64-bit unsigned decimal
23 ?S:     numbers.
24 ?S:.
25 ?S:d_PRIo64:
26 ?S:     This variable conditionally defines the PERL_PRIo64 symbol, which
27 ?S:     indiciates that stdio has a symbol to print 64-bit octal numbers.
28 ?S:.
29 ?S:d_PRIx64:
30 ?S:     This variable conditionally defines the PERL_PRIx64 symbol, which
31 ?S:     indiciates that stdio has a symbol to print 64-bit hexadecimal numbers.
32 ?S:.
33 ?S:d_PRIX64:
34 ?S:     This variable conditionally defines the PERL_PRIX64 symbol, which
35 ?S:     indiciates that stdio has a symbol to print 64-bit hExADECimAl numbers.
36 ?S:.
37 ?S:sPRId64:
38 ?S:     This variable, if defined, contains the string used by stdio to
39 ?S:     format 64-bit decimal numbers (format 'd') for output.
40 ?S:.
41 ?S:sPRIi64:
42 ?S:     This variable, if defined, contains the string used by stdio to
43 ?S:     format 64-bit decimal numbers (format 'i') for output.
44 ?S:.
45 ?S:sPRIu64:
46 ?S:     This variable, if defined, contains the string used by stdio to
47 ?S:     format 64-bit unsigned decimal numbers (format 'u') for output.
48 ?S:.
49 ?S:sPRIo64:
50 ?S:     This variable, if defined, contains the string used by stdio to
51 ?S:     format 64-bit octal numbers (format 'o') for output.
52 ?S:.
53 ?S:sPRIx64:
54 ?S:     This variable, if defined, contains the string used by stdio to
55 ?S:     format 64-bit hexadecimal numbers (format 'x') for output.
56 ?S:.
57 ?S:sPRIX64:
58 ?S:     This variable, if defined, contains the string used by stdio to
59 ?S:     format 64-bit hExADECimAl numbers (format 'X') for output.
60 ?S:.
61 ?C:PERL_PRId64:
62 ?C:     This symbol, if defined, contains the string used by stdio to
63 ?C:     format 64-bit decimal numbers (format 'd') for output.
64 ?C:.
65 ?C:PERL_PRIi64:
66 ?C:     This symbol, if defined, contains the string used by stdio to
67 ?C:     format 64-bit decimal numbers (format 'i') for output.
68 ?C:.
69 ?C:PERL_PRIu64:
70 ?C:     This symbol, if defined, contains the string used by stdio to
71 ?C:     format 64-bit unsigned decimal numbers (format 'u') for output.
72 ?C:.
73 ?C:PERL_PRIo64:
74 ?C:     This symbol, if defined, contains the string used by stdio to
75 ?C:     format 64-bit octal numbers (format 'o') for output.
76 ?C:.
77 ?C:PERL_PRIx64:
78 ?C:     This symbol, if defined, contains the string used by stdio to
79 ?C:     format 64-bit hexadecimal numbers (format 'x') for output.
80 ?C:.
81 ?C:PERL_PRIX64:
82 ?C:     This symbol, if defined, contains the string used by stdio to
83 ?C:     format 64-bit hExADECimAl numbers (format 'X') for output.
84 ?C:.
85 ?H:#$d_PRId64 PERL_PRId64       $sPRId64        /**/
86 ?H:#$d_PRIi64 PERL_PRIi64       $sPRIi64        /**/
87 ?H:#$d_PRIu64 PERL_PRIu64       $sPRIu64        /**/
88 ?H:#$d_PRIo64 PERL_PRIo64       $sPRIo64        /**/
89 ?H:#$d_PRIx64 PERL_PRIx64       $sPRIx64        /**/
90 ?H:#$d_PRIx64 PERL_PRIX64       $sPRIX64        /**/
91 ?H:.
92 ?F:!try
93 ?T:yyy
94 echo " "
95
96 if $test X"$quadtype" != X; then
97
98 echo "Checking how to print 64-bit integers..." >&4
99
100 if $test X"$sPRId64" = X -a X"$quadtype" = Xint; then
101         $cat >try.c <<'EOCP'
102 #include <sys/types.h>
103 #include <stdio.h>
104 int main() {
105   int q = 12345678901;
106   printf("%ld\n", q);
107 }
108 EOCP
109         set try
110         if eval $compile; then
111                 yyy=`./try$exe_ext`
112                 case "$yyy" in
113                 12345678901)
114                         sPRId64='"d"'; sPRIi64='"i"'; sPRIu64='"u"';
115                         sPRIo64='"o"'; sPRIx64='"x"'; sPRIX64='"X"';
116                         echo "We will use %d."
117                         ;;
118                 esac
119         fi
120 fi
121
122 if $test X"$sPRId64" = X -a X"$quadtype" = Xlong; then
123         $cat >try.c <<'EOCP'
124 #include <sys/types.h>
125 #include <stdio.h>
126 int main() {
127   long q = 12345678901;
128   printf("%ld\n", q);
129 }
130 EOCP
131         set try
132         if eval $compile; then
133                 yyy=`./try$exe_ext`
134                 case "$yyy" in
135                 12345678901)
136                         sPRId64='"ld"'; sPRIi64='"li"'; sPRIu64='"lu"';
137                         sPRIo64='"lo"'; sPRIx64='"lx"'; sPRIX64='"lX"';
138                         echo "We will use %ld."
139                         ;;
140                 esac
141         fi
142 fi
143
144 if $test X"$sPRId64" = X -a X"$i_inttypes" = X"$define" -a X"$quadtype" = Xint64_t; then
145         $cat >try.c <<'EOCP'
146 #include <sys/types.h>
147 #include <inttypes.h>
148 #include <stdio.h>
149 int main() {
150   int64_t q = 12345678901;
151   printf("%" PRId64 "\n", q);
152 }
153 EOCP
154         set try
155         if eval $compile; then
156                 yyy=`./try$exe_ext`
157                 case "$yyy" in
158                 12345678901)
159                         sPRId64=PRId64; sPRIi64=PRIi64; sPRIu64=PRIu64;
160                         sPRIo64=PRIo64; sPRIx64=PRIx64; sPRIX64=PRIX64;
161                         echo "We will use the C9X style."
162                         ;;
163                 esac
164         fi
165 fi
166
167 if $test X"$sPRId64" = X -a X"$quadtype" = X"long long"; then
168         $cat >try.c <<'EOCP'
169 #include <sys/types.h>
170 #include <stdio.h>
171 int main() {
172   long long q = 12345678901LL; /* AIX cc requires the LL prefix. */
173   printf("%lld\n", q);
174 }
175 EOCP
176         set try
177         if eval $compile; then
178                 yyy=`./try$exe_ext`
179                 case "$yyy" in
180                 12345678901)
181                         sPRId64='"lld"'; sPRIi64='"lli"'; sPRIu64='"llu"';
182                         sPRIo64='"llo"'; sPRIx64='"llx"'; sPRIX64='"llX"';
183                         echo "We will use the %lld style."
184                         ;;
185                 esac
186         fi
187 fi
188
189 if $test X"$sPRId64" = X -a X"$quadtype" != X; then
190         $cat >try.c <<EOCP
191 #include <sys/types.h>
192 #include <stdio.h>
193 int main() {
194   $quadtype q = 12345678901;
195   printf("%Ld\n", q);
196 }
197 EOCP
198         set try
199         if eval $compile; then
200                 yyy=`./try$exe_ext`
201                 case "$yyy" in
202                 12345678901)
203                         sPRId64='"Ld"'; sPRIi64='"Li"'; sPRIu64='"Lu"';
204                         sPRIo64='"Lo"'; sPRIx64='"Lx"'; sPRIX64='"LX"';
205                         echo "We will use %Ld."
206                         ;;
207                 esac
208         fi
209 fi
210
211 if $test X"$sPRId64" = X -a X"$quadtype" != X; then
212         $cat >try.c <<EOCP
213 #include <sys/types.h>
214 #include <stdio.h>
215 int main() {
216   $quadtype q = 12345678901;
217   printf("%qd\n", q);
218 }
219 EOCP
220         set try
221         if eval $compile; then
222                 yyy=`./try$exe_ext`
223                 case "$yyy" in
224                 12345678901)
225                         sPRId64='"qd"'; sPRIi64='"qi"'; sPRIu64='"qu"';
226                         sPRIo64='"qo"'; sPRIx64='"qx"'; sPRIX64='"qX"';
227                         echo "We will use %qd."
228                         ;;
229                 esac
230         fi
231 fi
232
233 if $test X"$sPRId64" = X; then
234         echo "Cannot figure out how to print 64-bit integers." >&4
235 fi
236
237 $rm -f try try.*
238
239 fi
240
241 case "$sPRId64" in
242 '')     d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef"; 
243         d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIX64="$undef"; 
244         ;;
245 *)      d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define"; 
246         d_PRIo64="$define"; d_PRIx64="$define"; d_PRIX64="$define"; 
247         ;;
248 esac
249