* [Caml-list] accessing a bigarray from c stubs
@ 2011-01-19 19:47 Joel Reymont
2011-01-19 19:58 ` [Caml-list] " Joel Reymont
0 siblings, 1 reply; 2+ messages in thread
From: Joel Reymont @ 2011-01-19 19:47 UTC (permalink / raw)
To: caml-list
Folks,
How do I get hold of the array pointer in the C stub below, assuming that the Caml value is of type (char, Bigarray.int8_unsigned_elt) Bigarray.kind?
Should I be using Bigarray for memory buffers?
Thanks in advance, Joel
---
/*
int bg_usb480_read (
Beagle beagle,
u32 * status,
u32 * events,
u64 * time_sop,
u64 * time_duration,
u32 * time_dataoffset,
int max_bytes,
u08 * packet
);
*/
type buffer = (char, Bigarray.int8_unsigned_elt) Bigarray.kind
CAMLprim value ml_bg_usb480_read(value beagle, value bytes, value buffer)
{
CAMLparam3(beagle, bytes, buffer);
CAMLlocal1(tuple);
u32 status, events, time_dataoffset;
u64 time_sop, time_duration;
int max_bytes = Int_val(bytes);
u08 *packet = ???
int err = bg_usb480_read(Int_val(beagle), &status, &events,
&time_sop, &time_duration, &time_dataoffset,
Int_val(max_bytes), packet);
tuple = caml_alloc_tuple(6);
Store_field(tuple, 0, Val_int(err));
Store_field(tuple, 1, Val_int32(status));
Store_field(tuple, 2, Val_int32(events));
Store_field(tuple, 3, Val_int64(time_sop));
Store_field(tuple, 4, Val_int64(time_duration));
Store_field(tuple, 5, Val_int32(time_dataoffset));
CAMLreturn(tuple);
}
---
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-19 19:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 19:47 [Caml-list] accessing a bigarray from c stubs Joel Reymont
2011-01-19 19:58 ` [Caml-list] " Joel Reymont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox