comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Calling Ada from C (linux/gnat 4.3.2)
Date: Tue, 01 Nov 2011 23:38:04 +0000
Date: 2011-11-01T23:38:04+00:00	[thread overview]
Message-ID: <m2aa8fpg6b.fsf@pushface.org> (raw)
In-Reply-To: 8ba649f0-7ca1-4f05-a158-74b074e401ee@o19g2000vbk.googlegroups.com

awdorrin <awdorrin@gmail.com> writes:

> I have been trying to search to find what the proper way would be to
> call an Ada procedure from a C pthread, but have had zero luck. I also
> have been unable to determine what the equivalent of the
> 'rts_init_task' would be with Gnat.

The info on-line is sparse; if you google 'gnat foreign threads' you'll
find [1], which tells you to look at the documentation of GNAT.Threads
(g-thread.ads). What it wants you to do is to read the comments in that
file.

In the past I've had success calling Register_Thread from the called Ada
procedure before it does anything at all, but that's not what the
comments seem to be saying. For example, I might have said

procedure P;
pragma export (C, P, "my_ada_proc");
procedure P is
   Id : constant System.Address := GNAT.Threads.Register_Thread;
   ...
begin
   ...

Jeffrey is correct that you need to call adainit() (and you should call
adafinal() before program exit or unloading a shared library).

[1] http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gnat_rm/GNAT_002eThreads-_0028g_002dthread_002eads_0029.html  



  parent reply	other threads:[~2011-11-01 23:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-01 18:46 Calling Ada from C (linux/gnat 4.3.2) awdorrin
2011-11-01 20:44 ` Jeffrey Carter
2011-11-01 23:38 ` Simon Wright [this message]
2011-11-02  4:17 ` anon
2011-11-02 16:05 ` Stephen Leake
2011-11-03 16:17   ` awdorrin
2011-11-08 23:22     ` awdorrin
2011-11-09 10:46       ` Pascal Obry
2011-11-09 21:10         ` Ludovic Brenta
2012-02-28 16:28 ` Matt Grochowalski
replies disabled

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