comp.lang.ada
 help / color / mirror / Atom feed
From: "Vladimir Olensky" <vladimir_olensky@yahoo.com>
Subject: Re: 'Size (novice question)
Date: 2000/02/22
Date: 2000-02-22T00:00:00+00:00	[thread overview]
Message-ID: <sb58e0h1r2a31@corp.supernews.com> (raw)
In-Reply-To: slrn8aqgfn.15u.lutz@taranis.iks-jena.de

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2554 bytes --]


Lutz Donnerhacke wrote in message ...
>* Robert A Duff wrote:
>>The important thing to remember is that if you say:
>>
>>    X: Byte;
>>
>>then (surprise!) X'Size might be 8, or might be 32, whether or not the
>>above Size clause is there.  The language rules just say X'Size >=
>>Byte'Size.
>>The compiler should choose whatever is most efficient.  If

>>you really want X to be 8 bits, say "for X'Size use 8;".  Likewise, if
>
>Funny.

Though what is said above is generally true I see no reason to worry
about that much.

According  to LRM 13.3 (50) compiler should use the same size for
object as the size of it's type provided that this size provides
independent addressability :

=====================================================
Implementation Advice:

50  If the Size of a subtype is specified, and allows for efficient
independent addressability (see 9.10) on the target architecture,
then the Size of the following objects of the subtype should equal
the Size of the subtype:

51 � Aliased objects (including components).
52 � Unaliased components, unless the Size of the component is
     determined by a component_clause or Component_Size clause.
....
54 The recommended level of support for the Size attribute of
      subtypes is:

55 � The Size (if not specified) of a static discrete or fixed point
subtype should be the number of bits needed to represent each
value belonging to the subtype using an unbiased representation,
leaving space for a sign bit only if the subtype contains negative
values. If such a subtype is a first subtype, then an implementation
should support a specified Size for it that reflects this representation.


============================================

As I understand efficient  independent addressability  means
that the X'Size should be multiple of storage_units.
It would be strange to hear that separate storage unit could
not be addressed efficiently.

So if  X_Type'Size is multiple of storage_unit than
X'Size should be the same.

At least on IA32 platform storage_unit is equal one byte.

So if you  have :

  type  Byte_type is mod 2**8;
  type  Bits5_type is mod 2**5;
  type  Bits10_type is mod 2**10;

   A : byte_type;
   B : Bits5_type;
   C:  Bits10_type;

then according to 13.3 (55):

   Byte_Type'Size = 8;
   Bits5_type'Size = 5;
   Bits10_type'Size =10;

if  ( storage_unit = 8)  then

    A'Size = 8;
    B'Size = 8;
    C'Size =16;

end if;

 if  ( storage_unit = 32)  then

    A'Size = 32;
    B'Size = 32;
    C'Size = 32;

 end if;


Regards,
Vladimir Olensky










  parent reply	other threads:[~2000-02-22  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <38ACA68D.CEA7E03F@interact.net.au>
2000-02-18  0:00 ` 'Size (novice question) Jeff Carter
     [not found] ` <wccsnyqof2a.fsf@world.std.com>
     [not found]   ` <slrn8aqgfn.15u.lutz@taranis.iks-jena.de>
     [not found]     ` <87aekxlz33.fsf@deneb.cygnus.argh.org>
2000-02-22  0:00       ` Lutz Donnerhacke
2000-02-22  0:00         ` Florian Weimer
2000-02-23  0:00           ` Lutz Donnerhacke
2000-02-22  0:00     ` Vladimir Olensky [this message]
2000-02-22  0:00       ` Robert Dewar
replies disabled

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