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!d17g2000yqb.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:55:44 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: 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 1280969744 5537 127.0.0.1 (5 Aug 2010 00:55:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 5 Aug 2010 00:55:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d17g2000yqb.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:12869 Date: 2010-08-04T17:55:44-07:00 List-Id: On Aug 4, 8:42=A0pm, Warren wrote: .. > OTOH, I could create a Thread_Context that is larger than what > the C routines expect. The Ada side will always be the one > setting aside the Context and Stack space. So I suppose I could > stuff an Ada procedure access (ptr) in it, and have a > C convention proc (in Ada) invoke that, acting as the > trampoline. =A0It just wastes a little more space but is > simple to do. Crap! That won't work either because the thread starting up doesn't know its own context object location. At least with the current avr_threads API ;-) I was trying to avoid modifying the avr_thread code. What it really needs is a user_data parameter. Hmmmm... It seems it boils down to 3 choices: 1) Have the starting thread signal the called thread, when it has "launched". 2) Add a "avr_get_current_thread" routine to return the current context object. 3) Add a "avr_start_ada_thread" function, which provides the context object as one of the local_proc arguments. The it can thunk with a call to context.ada_access_ptr.all; Only #1 works without changing the avr_threads C library. Maybe I'll try that approach first. Warren