comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GNAT 4.8 atomic access to 64-bit objects
Date: Fri, 15 Nov 2013 22:33:37 +0100
Date: 2013-11-15T22:33:37+01:00	[thread overview]
Message-ID: <ap60v90ea1hu$.hagui2l6id62.dlg@40tude.net> (raw)
In-Reply-To: 52867527$0$9504$9b4e6d93@newsspool1.arcor-online.net

On Fri, 15 Nov 2013 20:25:28 +0100, Georg Bauhaus wrote:

> On 15.11.13 09:44, Dmitry A. Kazakov wrote:
>> On Thu, 14 Nov 2013 21:34:26 +0100, Ludovic Brenta wrote:
> 
>>> I'd suggest you use 64-bit floating-point registers instead; i386
>>> processors have them, I think.  That has been a useful trick for a
>>> decade or so :)
>>
>> Using unchecked union or unchecked conversion?
> 
> FTR, a different 32 bit implementation (Ada 95) does not support a binary
> modulus of 64, and also, while Unchecked_Conversion passes the value 42
> from an integer register to a FPT register and back as 42, idly trying
>    type Fake is new  Long_Float;
>    pragma Atomic (Fake);
> gives
>   LRM:C.6(10), Indivisible read/update not supported for given subtype, pragma Atomic ignored

Try this:

with Interfaces;
with Ada.Unchecked_Conversion;
with Ada.Text_IO;

procedure Test is
   type T is mod 2**64;
   type Atomic_T is new Interfaces.IEEE_Float_64;
   function Load is new Ada.Unchecked_Conversion (Atomic_T, T);
   function Store is new Ada.Unchecked_Conversion (T, Atomic_T);
   X : Atomic_T;
   pragma Atomic (X);
begin
   X := Store (123);
   Ada.Text_IO.Put_Line (T'Image (Load (X)));
   X := Store (Load (X) + 1);
   Ada.Text_IO.Put_Line (T'Image (Load (X)));
end Test;

The code generated looks horrific.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2013-11-15 21:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14 15:57 GNAT 4.8 atomic access to 64-bit objects Dmitry A. Kazakov
2013-11-14 20:34 ` Ludovic Brenta
2013-11-15  8:44   ` Dmitry A. Kazakov
2013-11-15 19:25     ` Georg Bauhaus
2013-11-15 21:33       ` Dmitry A. Kazakov [this message]
2013-11-16 10:08         ` Georg Bauhaus
2013-11-16 12:02           ` Dmitry A. Kazakov
2013-11-15 19:08 ` Stefan.Lucks
2013-11-15 21:19   ` Dmitry A. Kazakov
2013-11-22  0:30     ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox