From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 30F14BC37 for ; Wed, 28 Oct 2009 16:37:39 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhIKAPsB6ErRVdrki2dsb2JhbACReYkHPwEBAQoLCgcRBa57hlCIaAEDAwWEOgSJWw X-IronPort-AV: E=Sophos;i="4.44,640,1249250400"; d="scan'208";a="37148589" Received: from mail-bw0-f228.google.com ([209.85.218.228]) by mail3-smtp-sop.national.inria.fr with ESMTP; 28 Oct 2009 16:37:38 +0100 Received: by bwz28 with SMTP id 28so1232261bwz.17 for ; Wed, 28 Oct 2009 08:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=evOqaJQoljQSriAIubVI5lBH+XGIRndh24SJF9Zne8E=; b=XWq6QgK6adc5tk2JV3heogaihUtO05JRDO0fN8oKjFhAfjIbw/ds8Nt31rKQ9krOdl vfkm6lagxZ4TuaRm6kos4dxhZmYBnvOKvGWafgPFzcx3k9LHVo7ijsfR+/a3r4oGeT05 ikz/ppFi7PnI+mywjT4aLLCkzISwV0vF3gzkw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=HmlJnI6essiH628euqTl5hdaG4wGBTfxTNxNxVbX/bAdEPTjBrhX6lKcDGWjhnuYYC ZQBdXAoqfwmQcqgHgzUqZBxGeS/j5WooysGi4k9hcqO/va8Yp6vy8lcgrYs4AbAYqB74 OqAJ0tVZlAHQuSPLxtP0Djd/kVw0Dselm0f2M= MIME-Version: 1.0 Sender: oandrieu@gmail.com Received: by 10.204.32.204 with SMTP id e12mr5347900bkd.51.1256744258109; Wed, 28 Oct 2009 08:37:38 -0700 (PDT) In-Reply-To: <87eiond3of.fsf@frosties.localdomain> References: <87eiond3of.fsf@frosties.localdomain> Date: Wed, 28 Oct 2009 16:37:38 +0100 X-Google-Sender-Auth: a5900d04e49a7ac4 Message-ID: <95513600910280837p2e8c3126s540f4a5d4b7f1824@mail.gmail.com> Subject: Re: [Caml-list] How to read different ints from a Bigarray? From: Olivier Andrieu To: Goswin von Brederlow Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; bigarray:01 andrieu:01 oandrieu:01 buffer:01 malloc:01 ocaml:01 runtime:01 le-gall:01 constructors:01 compiler:01 bigarray:01 compiler:01 28,:98 2009:98 polymorphic:01 On Wed, Oct 28, 2009 at 14:54, Goswin von Brederlow wrote: > Hi, > > I'm working on binding s for linux libaio library (asynchron IO) with > a sharp eye on efficiency. That means no copying must be done on the > data, which in turn means I can not use string as buffer type. hmm I think you could try with strings. You need to allocate the storage yourself (with malloc) but then, as long as you properly set up the header and last field of the block as OCaml does for its native strings, the runtime will use it without problems. The GC will see that the block is outside the Caml heap and won't try to manage it. And on the Caml side you can use it as a regular string. The only caveat I know is that this disrupts the polymorphic comparison function a bit. That's worth a try IMO. Sylvain Le Gall wrote: > > PS: Is a.{i} <- x a C call? > Yes. really ? Given the number of Pbigarray* constructors in the compiler code, I'd be surprised :) No I think that for some cases like "accessing a 64bits bigarray on a 32bits arch" result in a C call, but otherwise it's handled by the compiler. -- Olivier