Here is how I do it:
function shmget(key: integer; size: integer; shmflag: integer) return integer;
pragma interface(C, shmget);
function shmat(shmid: integer; shmaddr: address; shmflag: integer) return address;
pragma interface(C, shmat);
SHMID: INTEGER;
...
begin
SHMID := SHMGET(0, 100, 8#600#);
...
end;
The problem is that the returned SHMID is a valid number (i.e. not equal to -1), but
the shared memory segment is NOT being created. I use the ipcs command to check for
the shared memory and it's not there. I have used the shmget() call in a C program
with the same parameters and it works fine.
I am using Sun Ada (Verdix).
Any ideas?
Anthony
Are you actually linking in what you think you are? Why is there
no Verdix-defined pragma INTERFACE_NAME being used?
Does the size for the Ada type "integer" match the sizes of the Unix
types "key_t" and "int?" Try compiling a trivial C program that will
print out what is coming across in the "C world." The call this via
your pragmas INTERFACE and INTERFACE_NAME.
Are you compiling with the "-w" option set so that you are
missing out on warnings about incorrect parameter type sizes?
I think Verdix will only let you have 32 bits as the size. (Have a
look at the programmers guide, chapter 4 (I think?))
Bob Wells.
-- Chris
--
Christopher A. Warack, Capt, USAF
Computer Science Department, US Air Force Academy
1 - For some reason I could never get "shmget" to work with what I thought
was a reasonable flag value "16#1666#", but it did work with "10#932#. I
was never able to get Verdix to explain to me why this was so. 932 came
from a fax they sent me of FAQs about shared memory. You should be able
to request it from their software support department.
2 - Once you have allocated a block of memory and attached it to your
process, variables declared to be within the shared block of memory need
a user-defined AA_GLOBAL_ALLOC routine to overlaod the standard allocation
routine of the Verdix Ada environment. This is also covered in the
aforementioned FAQ.
Without comparing my code to yours in greater detail, I can offer
little else, but reassurance. Once I finally did get it working, it worked
really well, doing exactly what I wanted it to do.
************************************************
G_Ha...@qm.is.lmsc.lockheed.com
I found these opinions on my doorstep, would you please give them a good home?
************************************************
The flag values are coded with 3 bits for each of the 3 permission flags (at
least on the Sun), a total of 9 bits. The flags should therefore be coded in
octal, ie. 8#1666#. I guess you wanted to create the memory with a "rw-rw-rw-"
permission flag [ie. (IPC_CREAT | 0666) in C]. 10#932#=8#1644#, ie. create
with "rw-r--r--" permissions.
--
Oystein Torbjornsen Phone: +47 73 59 70 57 (office)
Division of Computer Systems and Telematics +47 73 52 92 91 (home)
Norwegian Institute of Technology Email: oy...@hobbes.er.sintef.no
N-7034 Trondheim, Norway or oys...@idt.unit.no
>The flag values are coded with 3 bits for each of the 3 permission flags (at
>least on the Sun), a total of 9 bits. The flags should therefore be coded in
>octal, ie. 8#1666#. I guess you wanted to create the memory with a "rw-rw-rw-"
>permission flag [ie. (IPC_CREAT | 0666) in C]. 10#932#=8#1644#, ie. create
>with "rw-r--r--" permissions.
Thanks. I looked at (what I thought were) the appropriate header files
to get the Ultrix bit map, but I missed that somehow.
**************************************
G_Ha...@qm.is.lmsc.lockheed.com
I found these opinions on my doorstep, could you please give them a good home?
**************************************