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-Thread: 103376,2a5f6199c3cc0e8b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.0.170 with SMTP id 10mr1972810pbf.2.1320190769048; Tue, 01 Nov 2011 16:39:29 -0700 (PDT) Path: p6ni58748pbn.0!nntp.google.com!news2.google.com!news.glorb.com!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Calling Ada from C (linux/gnat 4.3.2) Date: Tue, 01 Nov 2011 23:38:04 +0000 Organization: A noiseless patient Spider Message-ID: References: <8ba649f0-7ca1-4f05-a158-74b074e401ee@o19g2000vbk.googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="25563"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YclBZ+BMCbjBxKEeG6H0jR9Co4IDi/38=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:EXXedLvnGghOyLNvChAK+RNuDo0= sha1:lOUD4jib013zKJnkqGm5hZX5LMc= Xref: news2.google.com comp.lang.ada:14271 Content-Type: text/plain; charset=us-ascii Date: 2011-11-01T23:38:04+00:00 List-Id: awdorrin 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