From: Warren <ve3wwg@gmail.com>
Subject: Passing Ada Proc as a C Function Pointer
Date: Wed, 4 Aug 2010 09:40:29 -0700 (PDT)
Date: 2010-08-04T09:40:29-07:00 [thread overview]
Message-ID: <bc887840-ef75-405a-8019-8e44552a92d3@i28g2000yqa.googlegroups.com> (raw)
I some types defined as:
type Thread_Context is private;
type Stack_Area is new String;
type Thread_Proc is access procedure;
and an Ada API function:
procedure Thread_Start(Context : out Thread_Context; Proc :
Thread_Proc; Stack : out Stack_Area) is
type C_Func_Ptr is access procedure;
pragma Convention(Convention => C, Entity => C_Func_Ptr);
procedure avr_thread_start(Context : System.Address;
Proc : C_Func_Ptr;
Stack : System.Address;
Size : Unsigned_16);
pragma import(C,avr_thread_start,"avr_thread_start");
Func : C_Func_Ptr := Proc.all'Access;
begin
avr_thread_start(Context'Address,Func,Stack(Stack'First)'Address,Stack'Length);
end Thread_Start;
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).
Is it vital that the Thread_Proc procedure also be declared as
pragma import(C,Proc) ?
I'd prefer not to, if possible.
There are no arguments passed-- I only need to launch the passed
Ada procedure from the C side (in a thread).
The avr_thread_start C routine is declared as:
void avr_thread_start(
avr_thread_context* context,
void (*fn)(void),
uint8_t* stack,
uint16_t stack_size
);
Warren
next reply other threads:[~2010-08-04 16:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-04 16:40 Warren [this message]
2010-08-04 17:14 ` Passing Ada Proc as a C Function Pointer 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
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