comp.lang.ada
 help / color / mirror / Atom feed
* RE: Ada to 'C' parameter passing problem
@ 2003-02-21 16:52 Lionel.DRAGHI
  0 siblings, 0 replies; 14+ messages in thread
From: Lionel.DRAGHI @ 2003-02-21 16:52 UTC (permalink / raw)
  To: comp.lang.ada



| -----Message d'origine-----
| De: Stuart Palin [mailto:null@0.0]
...
| [RD does not usually make unconsidered statements, so I
| would be interested in reading his line of arguments.  Is it
| available somewhere convenient?]

Search for example the 4 Nov 2001 05:07:42 answer to Nick Roberts in the
"Re: Rosen Trick [List container strawman]" thread.

It begins with "Here are the facts:", it's a kind of signature, isn't it?
:-)

Lionel Draghi
 




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Ada to 'C' parameter passing problem
@ 2003-02-18 15:39 Patrick
  2003-02-18 16:47 ` Jeffrey Carter
  2003-02-18 19:50 ` Rod Chapman
  0 siblings, 2 replies; 14+ messages in thread
From: Patrick @ 2003-02-18 15:39 UTC (permalink / raw)


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,



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

end of thread, other threads:[~2003-02-25 17:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-21 16:52 Ada to 'C' parameter passing problem Lionel.DRAGHI
  -- strict thread matches above, loose matches on Subject: below --
2003-02-18 15:39 Patrick
2003-02-18 16:47 ` Jeffrey Carter
2003-02-18 19:50 ` Rod Chapman
2003-02-20  2:36   ` Matthew Heaney
2003-02-20  9:18     ` Rod Chapman
2003-02-20  9:43       ` Dmitry A. Kazakov
2003-02-20 22:05       ` Simon Wright
2003-02-21  9:53         ` Stuart Palin
2003-02-21 17:39           ` Jeffrey Carter
2003-02-21 18:12           ` Warren W. Gay VE3WWG
2003-02-21 20:25           ` Randy Brukardt
2003-02-24 23:53       ` Matthew Heaney
2003-02-25 17:21         ` Rod Chapman

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