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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,86f62fb0f98ad93e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!o19g2000yqb.googlegroups.com!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: Passing Ada Proc as a C Function Pointer Date: Wed, 4 Aug 2010 17:24:09 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <18lgtff9nqvia.bxr7lzz8gk36.dlg@40tude.net> NNTP-Posting-Host: 216.121.235.102 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1280967849 21714 127.0.0.1 (5 Aug 2010 00:24:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 5 Aug 2010 00:24:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o19g2000yqb.googlegroups.com; posting-host=216.121.235.102; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12866 Date: 2010-08-04T17:24:09-07:00 List-Id: On Aug 4, 1:14=A0pm, "Dmitry A. Kazakov" wrote: > On Wed, 4 Aug 2010 09:40:29 -0700 (PDT), Warren wrote: > > I some types defined as: > > > =A0 type Thread_Context is private; > > pragma Convention (C, Thread_Context); Let's not worry about the arguments. The WinAVR or even AVR-GCC is very gnat specific. System.Address is all I need where argument pointers are required. > > Because this part of the Ada code is not working, I'm suspicious that > > the passed function pointer is incorrect (I have an all-C thread > > example working). > > You have to pass a pointer to a procedure of C convention. You also must > ensure that other parameters aren't passed by copy. The only problem to be solved is the function pointer for the C code (ignoring portability of course). The C side is going to set up its stack and registers and then invoke the Ada side. I have this working in pure C, but when I try to launch an Ada thread, things seem to fall apart. Warren