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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,31c63f07e48d5471,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-18 07:39:19 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: Pat.Donahue@msfc.nasa.gov (Patrick) Newsgroups: comp.lang.ada Subject: Ada to 'C' parameter passing problem Date: 18 Feb 2003 07:39:19 -0800 Organization: http://groups.google.com/ Message-ID: NNTP-Posting-Host: 198.119.224.151 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1045582759 31249 127.0.0.1 (18 Feb 2003 15:39:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 18 Feb 2003 15:39:19 GMT Xref: archiver1.google.com comp.lang.ada:34196 Date: 2003-02-18T15:39:19+00:00 List-Id: I am using GNAT Ada on Linux. I am trying to port from a Sun (Solaris) implementation. I didn't write the Ada or 'C' myself, but am trying to make it work on Linux. The Ada code passes five parameters to the 'C' code. It is trying to pass the address in each case so that the 'C' can pass back status in the variables (parameters). The below Ada code (in tls.ads) contains the definition of the function "to_c_pointer" to convert the Ada address to a "c_pointer": type us1 is range 0..SYSTEM.MAX_INT; subtype unsigned_long is us1; subtype c_pointer is unsigned_long; -- convert ada address into a value that can be assigned -- to a c pointer. The following is an example of a call to -- to_c_pointer: TLS.to_c_pointer(i'ADDRESS) function to_c_pointer is new unchecked_conversion(SYSTEM.address, c_pointer); pragma inline(to_c_pointer); Here is what the Ada call to 'C' looks like: DMC_Initialize_Database_Configuration_C( TLS.to_c_pointer(Configuration_Id_In'ADDRESS), TLS.to_c_pointer(Configuration_Id_Len'ADDRESS), TLS.to_c_pointer(Initialization_Status_Ind'ADDRESS), TLS.to_c_pointer(Init_Failure_Text_In'ADDRESS), TLS.to_c_pointer(Init_Failure_Text_Len'ADDRESS)); Here is what the 'C' funtion definition looks like: DMC_Initialize_Database_Configuration_C( char *Configuration_Id, int *Configuration_Id_Len, int *Initialization_Status, char *Init_Failure_Text, int *Init_Failure_Text_Len) { As I said, there are five parameters. This worked fine under Solaris (Spark compiler for Ada), but under Linux the address of the 2nd and 4th parameters ends up being zero on the 'C' side (we can tell this with a debugger). Using the debugger, it looks like the first parameter on the Ada side is being passed into the first parameter on the 'C' side. The second parameter on the Ada side shows up on the 'C' side as the third parameter. The third parameter on the Ada side shows up on the 'C' side as the fifth parameter. So, at least on the surface, it looks as if the size of the parameter on the Ada side is twice the size of the parameter on the 'C' and it is filling in with zero. Have you run into anything similar that would enable you to help me solve this problem? Thanks for any help you can give me,