comp.lang.ada
 help / color / mirror / Atom feed
From: billimad@vanuata.dcs.gla.ac.uk (billimad)
Subject: Posix.4 memory mapping from Ada programs
Date: 1997/05/06
Date: 1997-05-06T00:00:00+00:00	[thread overview]
Message-ID: <5kname$iv7@singer.cent.gla.ac.uk> (raw)


I have been trying to use the Posix.4 memory mapping functions from an
Ada program, but without total success. I have managed to successfully
map static arrays but have been having more problems trying to map
access to array types.

For example, for types defined as such -

	type Integer_Array is array(1..10) of Integer;
	type integer_Array_Ptr is access all Integer_Array;

using (via a pragma IMPORT),

	Integer_Array_ptr := mmap(NULL, size, PROT_READ, MAP_SHARED,     
file_descriptor, 0ffset);

produces the desired result (i.e. the array can be read using
Integer_Array_Ptr(I)).

But, using -

	type Integer_Array is array(Integer range <>) of Integer;
	type Integer_Array_ptr is access all Integer_Array;

and using the same mmap function call produces an "Illegal Instruction"
run-time report when the program returns from the mmap function call.
The mmap function itself works fine (it is called from a small C
routine and code placed in there confirms that the mapping works). I
see the problem being in the asignment of Integer_Array_Ptr to the
return address from the mmap function.

We thought this may be due to the extra dope information present in Ada
arrays. So we then tried declaring the access type and allocating
memory to it (to fill in the extra dope information) -

	Array_Ptr := new Integer_Array(1..Size);

and then using the address of Array_ptr (Array_Ptr.all(1)'Address) as
the desired address to the mmap function (in place of NULL above). The
mmap function also requires MAP_SHARED to be changed to MAP_FIXED and
that the desired address is aligned on a page boundary.  We attempted
to satisfy this constraint by allocating an integer, determining its
address, and padding out to the next page boundary. We were still
unsuccessful with the mmap function.

I wonder whther anyone else tried to use memory mapping from Ada
programs (with or without success)?

Also, I have heard of the Posix.5 Ada language bindings to Posix.1 and
Posix.20 bindings to Posix.4. Is this still a work is progress, and
does anyone have any pointers (on-line, or off-line) to material of
this nature?

Any help would be gratefully appreciated. For your information, I am
using SunOS 5.5.1, gcc (v2.7), and gnatbl.

Thanks Andy




             reply	other threads:[~1997-05-06  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-06  0:00 billimad [this message]
1997-05-06  0:00 ` Posix.4 memory mapping from Ada programs David C. Hoos, Sr.
replies disabled

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