From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How do you bitwise operations in Ada '83 and '95
Date: Fri, 21 Jul 2006 17:09:30 -0500
Date: 2006-07-21T17:09:30-05:00 [thread overview]
Message-ID: <yOednRjjiOPEzVzZnZ2dnUVZ_tSdnZ2d@megapath.net> (raw)
In-Reply-To: mailman.43.1153460313.30988.comp.lang.ada@ada-france.org
"Marius Amado-Alves" <marius@amado-alves.info> wrote in message
news:mailman.43.1153460313.30988.comp.lang.ada@ada-france.org...
...
> > Which is much more likely to ruin the alignment of the bit-field
components
> > (an important part of maximum performance).
>
> For records. For a 64-bit unit it does not matter for the "<"
> functions where the fields are.
That is only true on a 64-bit machine. On more typical 32-bit machines, you
are doing double precision math to extract a few bits from the middle.
That's going to be more expensive.
> >> And the expressions are not
> >> complex. Once you get the masks and magnitudes right, it's simply
> >>
> >> Part := (Whole and Mask) / Magnitude.
> >
> > But that's for each component. Surely you do other operations (like
> > difference in seconds) where the expressions are far more complex?
>
> Actually, in this case, no. I leave it to Ada.Calendar. Convert,
> compute, convert. This limitation is documented.
Sounds nearly useless. Especially as Ada.Calendar.Time is a 64-bit type on
most compilers (but I realize you can't depend on that).
Even so, I'd expect that your equivelent of Time_Of would use a pretty
complex expression.
> > All-in-all, I prefer the record representation.
>
> For Calendar_64 I specifically wanted a 64-bit string, it was a
> requirement.
Yes, but that has nothing to do with whether it is represented as a record
or not. Just put a size clause on your record:
for My_Time'Size use 64;
If you need an untyped blob for some reason, its easy enough to use an
Unchecked_Conversion. But it's often easy to avoid the need to have it
untyped in the first place -- we did that in many places in the Win32 calls
that underlie Claw.
> If I was to implement Ada.Calendar I think I would use a record too,
> because it is a private type by definition, so I would have to write
> the "<" functions anyway.
>
> > Janus/Ada Calendar.Time implementation is a 64-bit record type
>
> Just curious: is it aligned properly i.e. if you uncheckedly convert
> to a 64-bit modular will the modular "<" functions work properly i.e.
> represent the relations between the dates properly?
I think so, but it is a moot point: Janus/Ada doesn't (currently) support
any 64 bit integer or modular types. So you'd have to convert to a
Storage_Array or Stream_Array or similar.
> Of course a Calendar_64 for a specific compiler/platform could take
> advantage of the respective Ada.Calendar representation.
Yes, of course.
Randy.
next prev parent reply other threads:[~2006-07-21 22:09 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CD6E3BB8-52D2-4EED-A790-0184FE56A99A@amado-alves.info>
2006-07-20 20:41 ` How do you bitwise operations in Ada '83 and '95 Marius Amado-Alves
2006-07-20 23:13 ` Randy Brukardt
2006-07-21 5:38 ` Marius Amado-Alves
2006-07-21 22:09 ` Randy Brukardt [this message]
[not found] <BFF12262-F906-4F9A-B867-D0373609F038@amado-alves.info>
2006-07-20 16:40 ` Marius Amado-Alves
2006-07-20 9:39 Fwd: " Marius Amado-Alves
2006-07-20 17:54 ` tmoran
2006-07-20 18:30 ` Marius Amado-Alves
2006-07-20 19:36 ` tmoran
2006-07-20 22:09 ` Simon Wright
2006-07-21 10:07 ` Stephen Leake
2006-07-21 19:09 ` Simon Wright
2006-07-21 19:45 ` tmoran
2006-07-23 15:59 ` Stephen Leake
2006-07-24 6:08 ` Simon Wright
[not found] <9315684D-C216-4EDA-8852-0A6BD4C275B0@amado-alves.info>
2006-07-19 22:30 ` Marius Amado-Alves
2006-07-20 7:40 ` Georg Bauhaus
2006-07-20 9:29 ` Colin Paul Gloster
2006-07-20 12:31 ` Georg Bauhaus
2006-07-20 13:08 ` Colin Paul Gloster
2006-07-20 13:29 ` Marius Amado-Alves
2006-07-20 13:49 ` Georg Bauhaus
2006-07-21 5:23 ` Colin Paul Gloster
2006-07-21 8:00 ` Georg Bauhaus
2006-07-20 9:03 ` Stephen Leake
2006-07-20 9:38 ` Marius Amado-Alves
2006-07-21 9:53 ` Stephen Leake
2006-07-20 11:31 ` Dmitry A. Kazakov
2006-07-20 13:18 ` Marius Amado-Alves
2006-07-21 9:58 ` Stephen Leake
2006-07-21 12:09 ` Dmitry A. Kazakov
2006-07-21 19:03 ` Simon Wright
2006-07-22 8:32 ` Dmitry A. Kazakov
2006-07-22 8:57 ` Simon Wright
2006-07-22 10:52 ` Georg Bauhaus
2006-07-22 13:31 ` Dmitry A. Kazakov
[not found] <1153244316.853254.291560@m79g2000cwm.googlegroups.com>
2006-07-18 18:45 ` Robert A Duff
2006-07-18 18:53 ` jimmaureenrogers
2006-07-18 19:22 ` Jeffrey R. Carter
2006-07-18 21:32 ` jimmaureenrogers
2006-07-19 0:40 ` Jeffrey R. Carter
2006-07-19 3:55 ` jimmaureenrogers
2006-07-19 4:37 ` Jeffrey R. Carter
2006-07-19 13:05 ` jimmaureenrogers
2006-07-19 19:43 ` Jeffrey R. Carter
[not found] ` <1153313832.389434.144930@s13g2000cwa.googlegroups.com>
2006-07-19 13:55 ` Georg Bauhaus
2006-07-19 14:20 ` Robert A Duff
2006-07-19 19:30 ` Jeffrey R. Carter
2006-07-19 14:41 ` Robert A Duff
2006-07-18 19:21 ` Jeffrey R. Carter
2006-07-19 3:01 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox