comp.lang.ada
 help / color / mirror / Atom feed
From: kevq@banana.demon.co.uk (Kevin F. Quinn)
Subject: Re: Why no exception hierarchy ?
Date: 1995/03/29
Date: 1995-03-29T00:00:00+00:00	[thread overview]
Message-ID: <19950329.215548.46@banana.demon.co.uk> (raw)
In-Reply-To: 1995Mar28.115614.9511@eisner

In article <1995Mar28.115614.9511@eisner>,
          kilgallen@eisner.decus.org (Larry Kilgallen, LJK Software) wrote:

> In article <D645uH.Dqr@nntpa.cb.att.com>, ka@socrates.hr.att.com (Kenneth Almquist) writes:
> > kilgallen@eisner.decus.org (Larry Kilgallen, LJK Software) writes:
> >> For an address representation clause, which might be used to access hardware,
> >> optimizing out dead assignments seems quite inappropriate.  Is there no
> >> Ada83 method of avoiding such an optimization for such objects?
> > 
> > Pragma Atomic will suppress these optimizations.
> 
> I find no reference to Pragma Atomic in the manual for DEC Ada, which
> is supposedly validated against the Ada83 standard.

Pragma Atomic is not required by Ada83.  And there is no equivalent
that is.  Try looking under Pragma Volatile instead - XDAda certainly
has it so DEC Ada might, given that they have the same front-end.
Couldn't tell you for sure off-hand though - I have this nagging feeling
that it's an XD enhancement.  Note that GNAT has both Atomic and
Volatile, and that they achieve different goals; Atomic forces reads
and writes to an object to be indivisible, and Volatile forces all
access to be direct to/from memory.  Volatile is the one that stops
the optimisations you're worrying about.

I think some Ada83 compilers implement a pragma Atomic that does the
job of pragma Volatile; but I'm not sure.

I would have thought that anything with an address clause would not be
optimised in such a way, and that the compiler would make no assumptions
as to its stability.  The '95 LRM says this explicitly:

  13.3.19 If the Address if an object is specified, or it is imported
          or exported, then the implementation should not perform
          optimizations based on assumptions of no aliases.

Note that this means that you could use pragma Export, for example,
to achieve the desired effect.  Just because you export something
doesn't mean you actually have to use it outside the Ada environment :)

You should check this with the '83 LRM et. al. though.


Try writing something like:

  with System;
  procedure ResetKevsASIC is
    Kevs_Command_Register : Integer;
    for Kevs_Command_Register use at System.To_Address(16#101010#);
  begin
    Kevs_Command_Register := 16#0000#;
    Kevs_Command_Register := 16#0123#;
  end Test;

and compile with assembly listing switched on (ADA/LIS/MAC <file>) and
take a peek at the output.  If you see two writes to the relevant
location, you should be alright.  If you just see one (where the value
is 16#1234#) then you know that you need something else.  I'd be
surprised though... (horrified might be a better adjective :) )

pragma Volatile of course allows you to stop those optimisations from
occurring on data that isn't located specifically with an address
clause.  That's the important difference.


P.S. Forgive me if the System.To_Address bit is wrong; I don't
have DEC Ada to hand here.  You might need to use
UnChecked_Conversion from Integer to System.Address.
-- 
Kevin F. Quinn           * "No-one ever made any money out of good
kevq@banana.demon.co.uk  *  looks and charm."
kevq@cix.compulink.co.uk * "You obviously haven't met Lady Hamilton..."
Compu$erve: 100025,1525  *                               Blackadder III




  reply	other threads:[~1995-03-29  0:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-23 23:10 Why no exception hierarchy ? Mogens Jensen
1995-03-24 11:19 ` Michel Gauthier
1995-03-24 21:52   ` Tucker Taft
1995-03-25  1:50   ` Kenneth Almquist
1995-03-25 12:40     ` David Weller
1995-03-27  5:47       ` Kenneth Almquist
1995-03-25 16:03     ` Larry Kilgallen, LJK Software
1995-03-27 19:23   ` Kenneth Almquist
1995-03-28 16:56     ` Larry Kilgallen, LJK Software
1995-03-29  0:00       ` Kevin F. Quinn [this message]
1995-03-30  0:00         ` Kevin F. Quinn
1995-03-31  0:00       ` Kenneth Almquist
1995-04-04  0:00       ` Robert Dewar
     [not found]         ` <1995Apr4.210804.9579@eisner.decus.org>
1995-04-05  0:00           ` Ada means what version by default ? Michael Feldman
1995-04-06  0:00             ` Larry Kilgallen
1995-04-07  0:00               ` Jean D. Ichbiah
1995-04-07  0:00               ` Robert Dewar
1995-04-05  0:00           ` Kevin F. Quinn
1995-04-07  0:00             ` Robert Dewar
1995-04-05  0:00         ` Why no exception hierarchy ? Jean D. Ichbiah
1995-04-05  0:00           ` Garlington KE
1995-04-06  0:00             ` Versions of Ada (was Why no exception hierarchy ?) Larry Kilgallen
1995-04-07  0:00               ` Robert Dewar
1995-04-07  0:00               ` Garlington KE
1995-04-05  0:00           ` Why no exception hierarchy ? Robert A Duff
1995-04-05  0:00             ` Jean D. Ichbiah
1995-04-07  0:00               ` Robert Dewar
1995-04-06  0:00           ` Robert Dewar
1995-04-07  0:00             ` Norman H. Cohen
1995-04-07  0:00             ` Jean D. Ichbiah
1995-04-07  0:00               ` Robert Dewar
1995-04-07  0:00             ` Garlington KE
1995-04-06  0:00           ` Robert Dewar
1995-04-07  0:00             ` Jean D. Ichbiah
1995-04-07  0:00               ` Robert Dewar
1995-04-06  0:00           ` Robert Dewar
1995-04-07  0:00             ` Jean D. Ichbiah
1995-04-05  0:00         ` Michael Feldman
1995-04-05  0:00         ` Is "Ada" 95 or 83? (was: Re: Why no exception hierarchy ?) Theodore Dennison
1995-04-07  0:00           ` Robert Dewar
1995-04-07  0:00       ` Ada means what version by default ? Robert I. Eachus
1995-03-25 18:13 ` Why no exception hierarchy ? Robert Dewar
1995-03-28 18:15   ` Jean D. Ichbiah
1995-03-31  0:00   ` Mats Weber
1995-04-04  0:00     ` Robert Dewar
1995-04-06  0:00       ` Mats Weber
1995-04-07  0:00         ` Kenneth Almquist
replies disabled

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