comp.lang.ada
 help / color / mirror / Atom feed
From: Warren <ve3wwg@gmail.com>
Subject: Re: Passing Ada Proc as a C Function Pointer
Date: Wed, 4 Aug 2010 17:55:44 -0700 (PDT)
Date: 2010-08-04T17:55:44-07:00	[thread overview]
Message-ID: <ac343777-eb81-4168-887f-c377a83e139e@d17g2000yqb.googlegroups.com> (raw)
In-Reply-To: cce56782-e45c-4917-819d-30e352659ee6@u26g2000yqu.googlegroups.com

On Aug 4, 8:42 pm, Warren <ve3...@gmail.com> 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.  It 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



  reply	other threads:[~2010-08-05  0:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04 16:40 Passing Ada Proc as a C Function Pointer Warren
2010-08-04 17:14 ` Dmitry A. Kazakov
2010-08-05  0:24   ` Warren
2010-08-04 18:46 ` Jeffrey Carter
2010-08-04 19:36   ` Dmitry A. Kazakov
2010-08-05  0:42   ` Warren
2010-08-05  0:55     ` Warren [this message]
2010-08-04 19:46 ` Simon Wright
2010-08-05  0:45   ` Warren
2010-08-05  7:33     ` Rolf
2010-08-05 20:50       ` Simon Wright
  -- strict thread matches above, loose matches on Subject: below --
2010-08-05 14:31 Warren
2010-08-05 15:37 ` Warren
2010-08-05 16:51   ` Warren
replies disabled

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