From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,261bedf7aad81534,start X-Google-Attributes: gid103376,public From: billimad@vanuata.dcs.gla.ac.uk (billimad) Subject: Posix.4 memory mapping from Ada programs Date: 1997/05/06 Message-ID: <5kname$iv7@singer.cent.gla.ac.uk>#1/1 X-Deja-AN: 239741837 X-Posted-From: InterNews 1.0.4@soay.dcs.gla.ac.uk Organization: University of Glasgow X-Authenticated: billimad on POP host vanuata.dcs.gla.ac.uk Newsgroups: comp.lang.ada Date: 1997-05-06T00:00:00+00:00 List-Id: 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