From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p0JJlGJT005579 for ; Wed, 19 Jan 2011 20:47:16 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuwAAM7NNk3RVaE2kGdsb2JhbACWLo4SCBUBAQEBCQkMBxEEIKVaiXqCGIUDLoglAQEDBYVLBIsegyRs X-IronPort-AV: E=Sophos;i="4.60,345,1291590000"; d="scan'208";a="95956545" Received: from mail-fx0-f54.google.com ([209.85.161.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 19 Jan 2011 20:47:11 +0100 Received: by fxm16 with SMTP id 16so1241694fxm.27 for ; Wed, 19 Jan 2011 11:47:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:content-type:content-transfer-encoding :subject:date:message-id:to:mime-version:x-mailer; bh=UsDye2EOdZovmFO5jkUXxlOdGA47QxpO1hBjZxhMKa8=; b=cPiZ1/EqYLzDQxVRUray2QeEz8cUYVboBn3K3OEr11VvEHzPXnZheUJm5wZ+L+8/CQ 85NkIHhKYmXfUgST/NDJF5Ndxpnq+LUMt8OCjcPsPBfh+uuuvy4u8pEgRQYyCaFQ1Dry 76HPMbhB0Sstl5wiCx7qrfQX77aSMuBrOqzxE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=W9gaynZrVbwjC4fFrIx1MZ7yMn0gvv77Z08H2eYBrcb73YOyWEbWhzw07aTBHXUxNZ mjy8BXAj2nD14V5CFr2++KDvX5ZYI85P6yoWljk6TwP3ASUZTeSwE4ThrPPaOvQdzfKs ixFA1xXUAzs2W1rT3kdrmUS9/a70DW5dZr/KY= Received: by 10.223.74.11 with SMTP id s11mr1112459faj.2.1295466428840; Wed, 19 Jan 2011 11:47:08 -0800 (PST) Received: from [192.168.0.193] ([95.60.213.7]) by mx.google.com with ESMTPS id n7sm2780930fam.11.2011.01.19.11.47.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Jan 2011 11:47:08 -0800 (PST) From: Joel Reymont Content-Type: text/plain; charset=us-ascii Date: Wed, 19 Jan 2011 19:47:03 +0000 Message-Id: <6A91562E-4FF8-4E71-8DDD-F0FA7B838063@gmail.com> To: caml-list@inria.fr Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p0JJlGJT005579 Subject: [Caml-list] accessing a bigarray from c stubs 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