[dmd-internals] longdouble and splitting off typedefs in mars.h

Iain Buclaw ibuclaw at ubuntu.com
Thu Jul 26 23:55:10 PDT 2012


On 18 July 2012 19:13, Iain Buclaw <ibuclaw at ubuntu.com> wrote:
> On 18 July 2012 18:46, Rainer Schuetze <r.sagitario at gmx.de> wrote:
>> On 18.07.2012 09:13, Iain Buclaw wrote:
>>>
>>> Hi,
>>>
>>> I have recently started moving across longdouble.h, and the use of
>>> ldouble() over into GDC's copy of the D frontend from upstream DMD.  I
>>> see there's an (attempted?) implementation for GDC already in
>>> longdouble.h
>>>
>>>
>>> https://github.com/D-Programming-Language/dmd/blob/master/src/root/longdouble.h#L16
>>
>>
>> This was just guesswork, as I could not try it out.
>>
>> I wonder why the real_t implementation is necessary at all, as GCC seems to
>> be capable of 80-bit floating points with "long double". At least that is
>> how DMD is built on posix systems. So maybe you can also use the !_MSC_VER
>> branch of the conditional.
>>
>>
>
> It's there because there are a variety of representations for floating
> point numbers. This means that in a cross-compiler the representation
> of floating point numbers in the compiled program may be different
> from that used in the machine doing the compilation.  Therefore, a
> cross compiler cannot safely use the host machine's floating point
> arithmetic; it must emulate the target's arithmetic. To ensure
> consistency, GCC always uses emulation to work with floating point
> values, even when the host and target floating point formats are
> identical.
>

I've actually found no harm putting it in the gdc real_t header
instead. So don't need the longdouble header afterall. :)

https://github.com/D-Programming-GDC/GDC/commit/d3dc166ff6f533712b07e05570cb9995c29b441b#L2R101


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the dmd-internals mailing list