1 ?RCS: $Id: perlxv.U,v 1.1 2000/08/31 17:53:56 jhi Exp jhi $
3 ?RCS: Copyright (c) 1999 Jarkko Hietaniemi
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.
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_nv_preserves_uv nv_preserves_uv_bits: \
12 echo rm use64bitint d_quad quadtype uquadtype \
13 d_longdbl uselongdouble longdblsize doublesize \
14 charsize shortsize intsize longsize i_stdlib \
15 cat Compile i_inttypes test d_volatile signal_t run
16 ?MAKE: -pick add $@ %<
18 ?S: This variable contains the C type used for Perl's IV.
21 ?S: This variable contains the C type used for Perl's UV.
24 ?S: This variable contains the C type used for Perl's NV.
27 ?S: This variable contains the C type used for Perl's I8.
30 ?S: This variable contains the C type used for Perl's U8.
33 ?S: This variable contains the C type used for Perl's I16.
36 ?S: This variable contains the C type used for Perl's U16.
39 ?S: This variable contains the C type used for Perl's I32.
42 ?S: This variable contains the C type used for Perl's U32.
45 ?S: This variable contains the C type used for Perl's I64.
48 ?S: This variable contains the C type used for Perl's U64.
51 ?S: This variable is the size of an IV in bytes.
54 ?S: This variable is the size of a UV in bytes.
57 ?S: This variable is the size of an I8 in bytes.
60 ?S: This variable is the size of an U8 in bytes.
63 ?S: This variable is the size of an I16 in bytes.
66 ?S: This variable is the size of an U16 in bytes.
69 ?S: This variable is the size of an I32 in bytes.
72 ?S: This variable is the size of an U32 in bytes.
75 ?S: This variable is the size of an I64 in bytes.
78 ?S: This variable is the size of an U64 in bytes.
81 ?S: This variable is the size of an NV in bytes.
84 ?S: This variable indicates whether a variable of type nvtype
85 ?S: can preserve all the bits a variable of type uvtype.
87 ?S:nv_preserves_uv_bits:
88 ?S: This variable indicates how many of bits type uvtype
89 ?S: a variable nvtype can preserve.
92 ?C: This symbol defines the C type used for Perl's IV.
95 ?C: This symbol defines the C type used for Perl's UV.
98 ?C: This symbol defines the C type used for Perl's I8.
101 ?C: This symbol defines the C type used for Perl's U8.
104 ?C: This symbol defines the C type used for Perl's I16.
107 ?C: This symbol defines the C type used for Perl's U16.
110 ?C: This symbol defines the C type used for Perl's I32.
113 ?C: This symbol defines the C type used for Perl's U32.
116 ?C: This symbol defines the C type used for Perl's I64.
119 ?C: This symbol defines the C type used for Perl's U64.
122 ?C: This symbol defines the C type used for Perl's NV.
125 ?C: This symbol contains the sizeof(IV).
128 ?C: This symbol contains the sizeof(UV).
131 ?C: This symbol contains the sizeof(I8).
134 ?C: This symbol contains the sizeof(U8).
137 ?C: This symbol contains the sizeof(I16).
140 ?C: This symbol contains the sizeof(U16).
143 ?C: This symbol contains the sizeof(I32).
146 ?C: This symbol contains the sizeof(U32).
149 ?C: This symbol contains the sizeof(I64).
152 ?C: This symbol contains the sizeof(U64).
155 ?C: This symbol contains the sizeof(NV).
158 ?C: This symbol, if defined, indicates that a variable of type NVTYPE
159 ?C: can preserve all the bits of a variable of type UVTYPE.
161 ?C:NV_PRESERVES_UV_BITS:
162 ?C: This symbol contains the number of bits a variable of type NVTYPE
163 ?C: can preserve of a variable of type UVTYPE.
165 ?H:#define IVTYPE $ivtype /**/
166 ?H:#define UVTYPE $uvtype /**/
167 ?H:#define I8TYPE $i8type /**/
168 ?H:#define U8TYPE $u8type /**/
169 ?H:#define I16TYPE $i16type /**/
170 ?H:#define U16TYPE $u16type /**/
171 ?H:#define I32TYPE $i32type /**/
172 ?H:#define U32TYPE $u32type /**/
173 ?H:?%<:#ifdef HAS_QUAD
174 ?H:?%<:#define I64TYPE $i64type /**/
175 ?H:?%<:#define U64TYPE $u64type /**/
177 ?H:#define NVTYPE $nvtype /**/
178 ?H:#define IVSIZE $ivsize /**/
179 ?H:#define UVSIZE $uvsize /**/
180 ?H:#define I8SIZE $i8size /**/
181 ?H:#define U8SIZE $u8size /**/
182 ?H:#define I16SIZE $i16size /**/
183 ?H:#define U16SIZE $u16size /**/
184 ?H:#define I32SIZE $i32size /**/
185 ?H:#define U32SIZE $u32size /**/
186 ?H:?%<:#ifdef HAS_QUAD
187 ?H:?%<:#define I64SIZE $i64size /**/
188 ?H:?%<:#define U64SIZE $u64size /**/
190 ?H:#define NVSIZE $nvsize /**/
191 ?H:#$d_nv_preserves_uv NV_PRESERVES_UV
192 ?H:#define NV_PRESERVES_UV_BITS $nv_preserves_uv_bits
193 ?H:?%<:#if UVSIZE == 8
194 ?H:?%<:# ifdef BYTEORDER
195 ?H:?%<:# if BYTEORDER == 0x1234
196 ?H:?%<:# undef BYTEORDER
197 ?H:?%<:# define BYTEORDER 0x12345678
199 ?H:?%<:# if BYTEORDER == 0x4321
200 ?H:?%<:# undef BYTEORDER
201 ?H:?%<:# define BYTEORDER 0x87654321
210 $echo "Choosing the C types to be used for Perl's internal types..." >&4
212 case "$use64bitint:$d_quad:$quadtype" in
220 uvtype="unsigned long"
226 case "$uselongdouble:$d_longdbl" in
236 $echo "(IV will be "$ivtype", $ivsize bytes)"
237 $echo "(UV will be "$uvtype", $uvsize bytes)"
238 $echo "(NV will be "$nvtype", $nvsize bytes)"
241 #$i_inttypes I_INTTYPES
243 #include <inttypes.h>
249 uint8_t u = UINT8_MAX;
253 int16_t i = INT16_MAX;
254 uint16_t i = UINT16_MAX;
258 int32_t i = INT32_MAX;
259 uint32_t u = UINT32_MAX;
266 '') case "$charsize" in
268 u8type="unsigned char"
277 if eval $compile; then
278 case "`$run ./try`" in
279 int8_t) i8type=int8_t
289 '') if $test $charsize -ge 1; then
291 u8type="unsigned char"
299 '') case "$shortsize" in
301 u16type="unsigned short"
310 if eval $compile; then
311 case "`$run ./try`" in
323 '') if $test $shortsize -ge 2; then
325 u16type="unsigned short"
333 '') case "$longsize" in
335 u32type="unsigned long"
339 *) case "$intsize" in
341 u32type="unsigned int"
352 if eval $compile; then
353 case "`$run ./try`" in
365 '') if $test $intsize -ge 4; then
367 u32type="unsigned int"
375 '') case "$d_quad:$quadtype" in
386 $echo "Checking how many bits of your UVs your NVs can preserve..." >&4
387 : volatile so that the compiler has to store it out to memory.
388 if test X"$d_volatile" = X"$define"; then
397 #include <sys/types.h>
400 $volatile int bletched = 0;
401 $signal_t blech(s) int s; { bletched = 1; }
409 signal(SIGFPE, blech);
412 for (i = 0; i < n; i++) {
413 u = u << 1 | ($uvtype)1;
419 d = ($nvtype)(u - 1);
420 if (($uvtype)d != (u - 1))
428 printf("%d\n", ((i == n) ? -n : i));
434 d_nv_preserves_uv="$undef"
435 if eval $compile; then
436 nv_preserves_uv_bits="`$run ./try`"
438 case "$nv_preserves_uv_bits" in
440 nv_preserves_uv_bits=`expr 0 - $nv_preserves_uv_bits`
441 $echo "Your NVs can preserve all $nv_preserves_uv_bits bits of your UVs." 2>&1
442 d_nv_preserves_uv="$define"
444 [1-9]*) $echo "Your NVs can preserve only $nv_preserves_uv_bits bits of your UVs." 2>&1
445 d_nv_preserves_uv="$undef" ;;
446 *) $echo "Can't figure out how many bits your NVs preserve." 2>&1
447 nv_preserves_uv_bits="$undef" ;;