comp.lang.ada
 help / color / mirror / Atom feed
* aliased & packed?
@ 1997-05-09  0:00 Tom Moran
  1997-05-09  0:00 ` Stephen Leake
  1997-05-10  0:00 ` Robert Dewar
  0 siblings, 2 replies; 13+ messages in thread
From: Tom Moran @ 1997-05-09  0:00 UTC (permalink / raw)



Clearly you can't do it.  I'd like to use pragma Pack for bits in a
black/white bitmap array.  That's easy to manipulate.  But to actually
display it I need to do a system call and pass the address.  If it
wasn't packed, Image'unchecked_access would be appropriate.  But
that won't work because Image would have to be aliased, and it can't
be because it's packed. Must I drop 'Pack' and make it an array of
bytes and do my own masking, shifting, etc?  What's the cleanest/most
portable/best way to accomplish the task?




^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: aliased & packed?
@ 1997-05-11  0:00 tmoran
  1997-05-11  0:00 ` Robert Dewar
  0 siblings, 1 reply; 13+ messages in thread
From: tmoran @ 1997-05-11  0:00 UTC (permalink / raw)



>take the access of a packed array, but then the *array* needs to be
>aliased, not its components. The components only need to be aliased
>if you need the access of individual array elements, but clearly that
>makes no sense if the elements are on arbitrary bit boundaries.
  Given
type Image_type is array(0 .. last_row, 0 .. last_col) of aliased BW_Bit_type;
pragma Pack(Image_Type);
  If you want to pass, say, the right half of the fifth scan line,
The_Image(4, 320 .. 639), which is done in Windows by passing
the address of The_Image(4,320).  (320 being divisible by 8)

  Or look at ARM B.3(23), where char_array is defined as a packed array
of aliased 'char'.  Is this different except in the empirical sense
that on most machines a char is addressable and a bit is not?

  Having been bitten in the past by passing an array to an external
function, and finding the external function looking at a descriptor
when it thought it was looking at the first data element, my coding
style has evolved to pass the address of the first data element
instead.  Is this no longer necessary with any correct Ada 95 compiler?

  It was suggested that 'address be used instead of 'access.  Do the
rules of Ada say that should always work, on any compiler, for an
Imported function?  Clearly 'address and 'access are not normally
assumed identical (or there would be no point to
System.Address_To_Access_Conversions).




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~1997-05-14  0:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-09  0:00 aliased & packed? Tom Moran
1997-05-09  0:00 ` Stephen Leake
1997-05-09  0:00   ` Tom Moran
1997-05-10  0:00 ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-05-11  0:00 tmoran
1997-05-11  0:00 ` Robert Dewar
1997-05-11  0:00   ` Tom Moran
1997-05-12  0:00     ` Robert Dewar
1997-05-12  0:00       ` Robert A Duff
     [not found]         ` <1997May13.065907.1@eisner>
1997-05-13  0:00           ` Robert A Duff
1997-05-13  0:00             ` Larry Kilgallen
1997-05-14  0:00             ` Richard Kenner
1997-05-13  0:00           ` Robert Dewar

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