This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add NV_PRESERVES_UV.
[metaconfig.git] / U / perl / perlxv.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:ivtype uvtype nvtype ivsize uvsize nvsize \
9         i8type u8type i16type u16type i32type u32type i64type u64type \
10         i8size u8size i16size u16size i32size u32size i64size u64size \
11         d_nvpresuv: \
12         echo rm use64bits d_quad quadtype uquadtype \
13         d_longdbl uselongdouble longdblsize doublesize \
14         charsize shortsize intsize longsize \
15         cat Compile i_inttypes exe_ext test
16 ?MAKE:  -pick add $@ %<
17 ?S:ivtype:
18 ?S:     This variable contains the C type used for Perl's IV.
19 ?S:.
20 ?S:uvtype:
21 ?S:     This variable contains the C type used for Perl's UV.
22 ?S:.
23 ?S:nvtype:
24 ?S:     This variable contains the C type used for Perl's NV.
25 ?S:.
26 ?S:i8type:
27 ?S:     This variable contains the C type used for Perl's I8.
28 ?S:.
29 ?S:u8type:
30 ?S:     This variable contains the C type used for Perl's U8.
31 ?S:.
32 ?S:i16type:
33 ?S:     This variable contains the C type used for Perl's I16.
34 ?S:.
35 ?S:u16type:
36 ?S:     This variable contains the C type used for Perl's U16.
37 ?S:.
38 ?S:i32type:
39 ?S:     This variable contains the C type used for Perl's I32.
40 ?S:.
41 ?S:u32type:
42 ?S:     This variable contains the C type used for Perl's U32.
43 ?S:.
44 ?S:i64type:
45 ?S:     This variable contains the C type used for Perl's I64.
46 ?S:.
47 ?S:u64type:
48 ?S:     This variable contains the C type used for Perl's U64.
49 ?S:.
50 ?S:ivsize:
51 ?S:     This variable is the size of an IV in bytes.
52 ?S:.
53 ?S:uvsize:
54 ?S:     This variable is the size of a UV in bytes.
55 ?S:.
56 ?S:i8size:
57 ?S:     This variable is the size of an I8 in bytes.
58 ?S:.
59 ?S:u8size:
60 ?S:     This variable is the size of an U8 in bytes.
61 ?S:.
62 ?S:i16size:
63 ?S:     This variable is the size of an I16 in bytes.
64 ?S:.
65 ?S:u16size:
66 ?S:     This variable is the size of an U16 in bytes.
67 ?S:.
68 ?S:i32size:
69 ?S:     This variable is the size of an I32 in bytes.
70 ?S:.
71 ?S:u32size:
72 ?S:     This variable is the size of an U32 in bytes.
73 ?S:.
74 ?S:i64size:
75 ?S:     This variable is the size of an I64 in bytes.
76 ?S:.
77 ?S:u64size:
78 ?S:     This variable is the size of an U64 in bytes.
79 ?S:.
80 ?S:nvsize:
81 ?S:     This variable is the size of an NV in bytes.
82 ?S:.
83 ?S:d_nvpresuv:
84 ?S:     This variable indicates whether a variable of type nvtype
85 ?S:     can preserve all the bits a variable of type uvtype.
86 ?S:.
87 ?C:IVTYPE:
88 ?C:     This symbol defines the C type used for Perl's IV.
89 ?C:.
90 ?C:UVTYPE:
91 ?C:     This symbol defines the C type used for Perl's UV.
92 ?C:.
93 ?C:I8TYPE:
94 ?C:     This symbol defines the C type used for Perl's I8.
95 ?C:.
96 ?C:U8TYPE:
97 ?C:     This symbol defines the C type used for Perl's U8.
98 ?C:.
99 ?C:I16TYPE:
100 ?C:     This symbol defines the C type used for Perl's I16.
101 ?C:.
102 ?C:U16TYPE:
103 ?C:     This symbol defines the C type used for Perl's U16.
104 ?C:.
105 ?C:I32TYPE:
106 ?C:     This symbol defines the C type used for Perl's I32.
107 ?C:.
108 ?C:U32TYPE:
109 ?C:     This symbol defines the C type used for Perl's U32.
110 ?C:.
111 ?C:I64TYPE:
112 ?C:     This symbol defines the C type used for Perl's I64.
113 ?C:.
114 ?C:U64TYPE:
115 ?C:     This symbol defines the C type used for Perl's U64.
116 ?C:.
117 ?C:NVTYPE:
118 ?C:     This symbol defines the C type used for Perl's NV.
119 ?C:.
120 ?C:IVSIZE:
121 ?C:     This symbol contains the sizeof(IV).
122 ?C:.
123 ?C:UVSIZE:
124 ?C:     This symbol contains the sizeof(UV).
125 ?C:.
126 ?C:I8SIZE:
127 ?C:     This symbol contains the sizeof(I8).
128 ?C:.
129 ?C:U8SIZE:
130 ?C:     This symbol contains the sizeof(U8).
131 ?C:.
132 ?C:I16SIZE:
133 ?C:     This symbol contains the sizeof(I16).
134 ?C:.
135 ?C:U16SIZE:
136 ?C:     This symbol contains the sizeof(U16).
137 ?C:.
138 ?C:I32SIZE:
139 ?C:     This symbol contains the sizeof(I32).
140 ?C:.
141 ?C:U32SIZE:
142 ?C:     This symbol contains the sizeof(U32).
143 ?C:.
144 ?C:I64SIZE:
145 ?C:     This symbol contains the sizeof(I64).
146 ?C:.
147 ?C:U64SIZE:
148 ?C:     This symbol contains the sizeof(U64).
149 ?C:.
150 ?C:NVSIZE:
151 ?C:     This symbol contains the sizeof(NV).
152 ?C:.
153 ?C:NV_PRESERVES_UV:
154 ?C:     This symbol, if defined, indicates that a variable of type NVTYPE
155 ?C:     can preserve all the bit of a variable of type UVSIZE.
156 ?C:.
157 ?H:#define      IVTYPE          $ivtype         /**/
158 ?H:#define      UVTYPE          $uvtype         /**/
159 ?H:#define      I8TYPE          $i8type         /**/
160 ?H:#define      U8TYPE          $u8type         /**/
161 ?H:#define      I16TYPE         $i16type        /**/
162 ?H:#define      U16TYPE         $u16type        /**/
163 ?H:#define      I32TYPE         $i32type        /**/
164 ?H:#define      U32TYPE         $u32type        /**/
165 ?H:?%<:#ifdef HAS_QUAD
166 ?H:?%<:#define  I64TYPE         $i64type        /**/
167 ?H:?%<:#define  U64TYPE         $u64type        /**/
168 ?H:?%<:#endif
169 ?H:#define      NVTYPE          $nvtype         /**/
170 ?H:#define      IVSIZE          $ivsize         /**/
171 ?H:#define      UVSIZE          $uvsize         /**/
172 ?H:#define      I8SIZE          $i8size         /**/
173 ?H:#define      U8SIZE          $u8size         /**/
174 ?H:#define      I16SIZE         $i16size        /**/
175 ?H:#define      U16SIZE         $u16size        /**/
176 ?H:#define      I32SIZE         $i32size        /**/
177 ?H:#define      U32SIZE         $u32size        /**/
178 ?H:?%<:#ifdef HAS_QUAD
179 ?H:?%<:#define  I64SIZE         $i64size        /**/
180 ?H:?%<:#define  U64SIZE         $u64size        /**/
181 ?H:?%<:#endif
182 ?H:#define      NVSIZE          $nvsize         /**/
183 ?H:#$d_nvpresuv NV_PRESERVES_UV
184 ?H:.
185 ?F:!try
186
187 echo " "
188 $echo "Choosing the C types to be used for Perl's internal types..." >&4
189
190 case "$use64bits:$d_quad:$quadtype" in
191 define:define:?*)
192         ivtype="$quadtype"
193         uvtype="$uquadtype"
194         ivsize=8
195         uvsize=8
196         ;;
197 *)      ivtype="long"
198         uvtype="unsigned long"
199         ivsize=$longsize
200         uvsize=$longsize
201         ;;
202 esac
203
204 case "$uselongdouble:$d_longdbl" in
205 define:define)
206         nvtype="long double"
207         nvsize=$longdblsize
208         ;;
209 *)      nvtype=double
210         nvsize=$doublesize
211         ;;
212 esac
213
214 $echo "(IV will be "$ivtype", $ivsize bytes)"
215 $echo "(UV will be "$uvtype", $uvsize bytes)"
216 $echo "(NV will be "$nvtype", $nvsize bytes)"
217
218 $cat >try.c <<EOCP
219 #$i_inttypes I_INTTYPES
220 #ifdef I_INTTYPES
221 #include <inttypes.h>
222 #endif
223 #include <stdio.h>
224 int main() {
225 #ifdef INT8
226    int8_t i =  INT8_MAX;
227   uint8_t u = UINT8_MAX;
228   printf("int8_t\n");
229 #endif
230 #ifdef INT16
231    int16_t i =  INT16_MAX;
232   uint16_t i = UINT16_MAX;
233   printf("int16_t\n");
234 #endif
235 #ifdef INT32
236    int32_t i =  INT32_MAX;
237   uint32_t u = UINT32_MAX;
238   printf("int32_t\n");
239 #endif
240 }
241 EOCP
242
243 case "$i8type" in
244 '')     case "$charsize" in
245         1)      i8type=char
246                 u8type="unsigned char"
247                 i8size=$charsize
248                 u8size=$charsize
249                 ;;
250         esac
251         ;;
252 esac
253 case "$i8type" in
254 '')     set try -DINT8
255         if eval $compile; then
256                 case "`./try$exe_ext`" in
257                 int8_t) i8type=int8_t
258                         u8type=uint8_t
259                         i8size=1
260                         u8size=1
261                         ;;
262                 esac
263         fi
264         ;;
265 esac
266 case "$i8type" in
267 '')     if $test $charsize -ge 1; then
268                 i8type=char
269                 u8type="unsigned char"
270                 i8size=$charsize
271                 u8size=$charsize
272         fi
273         ;;
274 esac
275
276 case "$i16type" in
277 '')     case "$shortsize" in
278         2)      i16type=short
279                 u16type="unsigned short"
280                 i16size=$shortsize
281                 u16size=$shortsize
282                 ;;
283         esac
284         ;;
285 esac
286 case "$i16type" in
287 '')     set try -DINT16
288         if eval $compile; then
289                 case "`./try$exe_ext`" in
290                 int16_t)
291                         i16type=int16_t
292                         u16type=uint16_t
293                         i16size=2
294                         u16size=2
295                         ;;
296                 esac
297         fi
298         ;;
299 esac
300 case "$i16type" in
301 '')     if $test $shortsize -ge 2; then
302                 i16type=short
303                 u16type="unsigned short"
304                 i16size=$shortsize
305                 u16size=$shortsize
306         fi
307         ;;
308 esac
309
310 case "$i32type" in
311 '')     case "$longsize" in
312         4)      i32type=long
313                 u32type="unsigned long"
314                 i32size=$longsize
315                 u32size=$longsize
316                 ;;
317         *)      case "$intsize" in
318                 4)      i32type=int
319                         u32type="unsigned int"
320                         i32size=$intsize
321                         u32size=$intsize
322                         ;;
323                 esac
324                 ;;
325         esac
326         ;;
327 esac
328 case "$i32type" in
329 '')     set try -DINT32
330         if eval $compile; then
331                 case "`./try$exe_ext`" in
332                 int32_t)
333                         i32type=int32_t
334                         u32type=uint32_t
335                         i32size=4
336                         u32size=4
337                         ;;
338                 esac
339         fi
340         ;;
341 esac
342 case "$i32type" in
343 '')     if $test $intsize -ge 4; then
344                 i32type=int
345                 u32type="unsigned int"
346                 i32size=$intsize
347                 u32size=$intsize
348         fi
349         ;;
350 esac
351
352 case "$i64type" in
353 '')     case "$d_quad:$quadtype" in
354         define:?*)
355                 i64type="$quadtype"
356                 u64type="$uquadtype"
357                 i64size=8
358                 u64size=8
359                 ;;
360         esac
361         ;;
362 esac
363
364 $echo "Checking whether your NVs can preserve your UVs..." >&4
365 $cat <<EOP >try.c
366 #include <stdio.h>
367 int main() {
368     $uvtype k = ($uvtype)~0, l;
369     $nvtype d;
370     l = k;
371     d = ($nvtype)l;
372     l = ($uvtype)d;
373     if (l == k)
374        printf("preserve\n");
375     exit(0);
376 }
377 EOP
378 set try
379 if eval $compile; then
380         case "`./try$exe_ext`" in
381         preserve) d_nvpresuv="$define" ;;
382         esac
383 fi      
384 case "$d_nvpresuv" in
385 $define) $echo "Yes, they can."  2>&1 ;;
386 *)       $echo "No, they can't." 2>&1
387          d_nvpresuv="$undef"
388          ;;
389 esac
390
391 $rm -f try.* try
392