Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Joel Reymont <joelr1@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] accessing a bigarray from c stubs
Date: Wed, 19 Jan 2011 19:47:03 +0000	[thread overview]
Message-ID: <6A91562E-4FF8-4E71-8DDD-F0FA7B838063@gmail.com> (raw)

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







             reply	other threads:[~2011-01-19 19:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-19 19:47 Joel Reymont [this message]
2011-01-19 19:58 ` [Caml-list] " Joel Reymont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6A91562E-4FF8-4E71-8DDD-F0FA7B838063@gmail.com \
    --to=joelr1@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox