comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Storage space question
Date: 1998/12/10
Date: 1998-12-10T00:00:00+00:00	[thread overview]
Message-ID: <F3rBC7.JAr.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 366FE278.FAF73497@pwfl.com

Marin David Condic (condicma@bogon.pwfl.com) wrote:
: Craig Allen wrote:
: > 
: > the short version of my question is this:  If I'm using enumerations
: > to
: > define names that will represent specific bit patterns that my program
: > may
: > wish to use, do *all* these bit patterns allocate space? e.g.  with
: > this:
: > 
: >    type DCD_Mode_Type is
: >       (CARRIER_DETECT, SYNC_DETECT, LOW, HIGH);
: >    for DCD_Mode_Type'Size use 2;
: >    for DCD_Mode_Type use
: >       (CARRIER_DETECT => 2#00#,
: >        SYNC_DETECT    => 2#01#,
: >        LOW            => 2#10#,
: >        HIGH           => 2#11#
: >        );
: > 
: > is space allocated for each of these definitions?  
: ...
: If you've got a good avionics-quality, embedded target, Ada compiler,
: I'd expect it to have switches/options to disable some of this storage
: allocation. 

In Ada 95, there is a language-defined pragma "Discard_Names"
designed to suppress the generation of the enumeration
"image" tables (and other similar run-time string names).
The pragma is described in RM95 C.5.  For the above example,

   pragma Discard_Names(On => DCD_Mode_Type);

would do the trick.

Note also that by specifying the representation of the
enumeration type, you run the danger of imposing additional
space and time overhead due to the internal conversions between 
enumeration position number and integer code.  In the above case,
all bit patterns are used consecutively, and hopefully 
your compiler is clever enough to recognize this special case.

However, there have been compilers which did not recognize
this special case, and in any case, if you have any "holes"
in the representation, the compiler will probably end up
creating a table (or tables) for converting between position
number and integer code.

The "Ravenscar" profile, which is supported by some Ada 95 compilers,
includes a restriction:

   pragma Restrictions(No_Enumeration_Maps);

which should suppress these tables, and flag any place
where a conversion between position number and integer code
would be required.

: Marin David Condic
: Real Time & Embedded Systems, Propulsion Systems Analysis
: United Technologies, Pratt & Whitney, Large Military Engines
: M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
: Ph: 561.796.8997         Fx: 561.796.4669

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA
An AverStar Company




  parent reply	other threads:[~1998-12-10  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-10  0:00 Storage space question Craig Allen
1998-12-10  0:00 ` dennison
1998-12-10  0:00 ` Marin David Condic
1998-12-10  0:00   ` Matthew Heaney
1998-12-10  0:00     ` dennison
1998-12-10  0:00   ` Pat Rogers
1998-12-10  0:00     ` dennison
1998-12-10  0:00       ` Pat Rogers
1998-12-10  0:00   ` Tucker Taft [this message]
1998-12-10  0:00     ` callen
1998-12-10  0:00       ` Marin David Condic
1998-12-10  0:00         ` Tucker Taft
1998-12-11  0:00           ` dennison
1998-12-11  0:00         ` Matthew Heaney
1998-12-11  0:00           ` Marin David Condic
1998-12-12  0:00             ` Matthew Heaney
1998-12-12  0:00               ` David C. Hoos, Sr.
1998-12-12  0:00                 ` Matthew Heaney
1998-12-14  0:00                 ` dennison
1998-12-10  0:00       ` dennison
1998-12-11  0:00       ` Matthew Heaney
replies disabled

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