comp.lang.ada
 help / color / mirror / Atom feed
* Convert an address range into an array
@ 1999-06-06  0:00 Markus Kuhn
  1999-06-06  0:00 ` David C. Hoos, Sr.
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Markus Kuhn @ 1999-06-06  0:00 UTC (permalink / raw)


Problem: I have memory-mapped a file into my address space using
mmap(). I have parsed data structures in this file and I have located
a continuous string of characters in the address range A to B.
I now want to convert this address range into an Ada String type,
which I can then pass on to a procedure that expects a String
parameter. I do NOT want to copy the (potentially very large)
sequence of bytes for performance reasons.

Basically, I want to get somehow a value

  S : String;

such that

  S(S'First)'Access = A 
  S(S'Last)'Access = B
  S'First = 1

which I can then pass on to a prodecure without copying the bytes.
All I want to allocate is the (First,Last) meta-data of the array,
not the array data itself. In other words, I want to combine the
efficiency of C's pointer+length representation of memory chunks
with the comfort and safety of Ada's arrays, but none of the
textbooks explain how to do this.

What is the proper Ada way of turning a variable address range
into an array located there? Representation clauses? Or should the
efficient zero-copying handling of memory mapped files, packet
headers, etc. better be done via good old pointer arithmetic
like in C?

The compiler is GNAT on Linux, but the most portable solution
would be preferred.

Markus

-- 
Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at acm.org,  WWW: <http://www.cl.cam.ac.uk/~mgk25/>




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

end of thread, other threads:[~1999-06-06  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-06  0:00 Convert an address range into an array Markus Kuhn
1999-06-06  0:00 ` David C. Hoos, Sr.
1999-06-06  0:00 ` Matthew Heaney
1999-06-06  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