| Store | Cart

Re: [perl #123113] [PATCH] Add optional GCC-only support for using long doubles on Win32

From: demerphq <deme...@gmail.com>
Thu, 27 Nov 2014 10:26:37 +0100
On 21 November 2014 at 08:16, <sisy...@optusnet.com.au> wrote:

> -----Original Message----- From: sisy...@optusnet.com.au> Sent: Friday, November 21, 2014 4:58 PM> To: perl...@perl.org> Cc: perl...@perl.org> Subject: Re: [perl #123113] [PATCH] Add optional GCC-only support for> using long doubles on Win32>>>  The 64-bit build is worse.>>>> Hang on, looks like sizeof(long double) differs between 32-bit and 64-bit> MinGW compilers:>> This script:>> ###############################> use warnings;> use Config;> use Inline C => <<'EOC';>> void foo() {> printf("%u %u\n", LDBL_DIG, LDBL_MANT_DIG);> printf("%u %u\n", sizeof(long double), sizeof(NV));> }>> EOC>> foo();> print "$Config{longdblsize} $Config{nvsize}\n";> ###############################>> on 32-bit ld perl-5.21.6 outputs:>> 18 64> 12 12> 12 12>> but on 64-bit ld perl-5.21.6 outputs:>> 18 64> 16 16> 12 12>> I don't know how that will affect the way 64-bit perl runs, but it's an> anomaly that should be fixed for the next release anyway.>> I wonder why sizeof(long double) differs between 32-bit and 64-bit> mingw-w64 compilers ??>

It is not a mingw issue, it is an x86 issue. I dont recall exactly the
details but on x86 it is either an OS setting, or a compiler setting as to
whether a long double is represented as a simple double or if it is
represented as an extended precision 80 bit value. I have a hazy
recollection that Linux and Windows use the extended precision mode, and
FreeBSD derivatives use the plain double representation.

Where the compiler does use the extended precisions floats it store them
differently on 32 and 64 bit architectures. On 32 bit it is stored in 12
bytes (3 x 32 bit words), and in 64 bit builds it is stored in 16 bytes (2
x 64 bit words). Either way the compiler and the CPU only use 10 bytes of
what is stored. (In some contexts this means either representation can
"leak" sensitive data as the compiler does not clear the unused bytes.)

Yves




-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Recent Messages in this Thread
sisy...@optusnet.com.au Nov 21, 2014 07:16 am
sisy...@optusnet.com.au Nov 21, 2014 07:34 am
Steve Hay Nov 21, 2014 06:41 pm
demerphq Nov 27, 2014 09:26 am
Messages in this thread