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