Possible bug in atomicOp

Robert Jacques sandford at jhu.edu
Mon Oct 25 08:24:03 PDT 2010


On Mon, 25 Oct 2010 00:08:03 -0400, Don <nospam at nospam.com> wrote:

> Robert Jacques wrote:
>> On Sat, 23 Oct 2010 15:50:30 -0400, Sean Kelly <sean at invisibleduck.org>  
>> wrote:
>>>>>
>>>>> Basically, atomicLoad (which atomicOp uses) always returns in ALU
>>>> > registers.
>>>>> Floating point numbers need to be returned in floating point
>>>> > registers.
>>>>> Therefore, a NaN always gets returned from atomicLoad!double, and a
>>>> > NaN isn't
>>>>> equal to anything.
>>>>
>>>> So shouldn't there be a static assert to prevent one from using
>>>> atomicOp with floats and doubles? Or should atomicLoad be implemented
>>>> to support floats and doubles?
>>>
>>> The former in the short term and the latter in the long term.
>>  Well, here's the assembler to load a value onto the FP stack:
>> float  __int2float  (ref int  x) { asm { fld float  ptr [EAX]; } }
>> double __long2double(ref long x) { asm { fld double ptr [EAX]; } }
>
> That should be:
> fild dword ptr [EAX];
> fild qword ptr [EAX];

Opps. I should have named them __int_as_float and __long_as_double. The  
point was to find an efficient way to return an int or double in register  
on the x87 stack.


More information about the Digitalmars-d mailing list