From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GNAT 4.8 atomic access to 64-bit objects Date: Fri, 15 Nov 2013 22:33:37 +0100 Organization: cbb software GmbH Message-ID: References: <1neco99j6szmk$.ayjyo0uds8a5.dlg@40tude.net> <87k3gahgdp.fsf@ludovic-brenta.org> <17hrkmg61tzsa.10xsgmupjcz79$.dlg@40tude.net> <52867527$0$9504$9b4e6d93@newsspool1.arcor-online.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: Ws8cDh6KC0dYMbHlsA0RIw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Original-Bytes: 2346 Xref: number.nntp.dca.giganews.com comp.lang.ada:183892 Date: 2013-11-15T22:33:37+01:00 List-Id: 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