[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] How do I plug into (lolevel) move-memory! ?

From: felix
Subject: Re: [Chicken-users] How do I plug into (lolevel) move-memory! ?
Date: Wed, 24 Sep 2003 23:44:22 +0200
User-agent: Opera7.11/Linux M2 build 406

On Wed, 24 Sep 2003 11:56:50 -0700, Dale Jordan <address@hidden> wrote:

I'm trying to write a procedure with the following signature:

(copy-bytes! s-bv s-offs d-bv d-offs n)

that copies n bytes from a source byte-vector to a destination byte- vector
with given offsets, using the move-memory! procedure in lolevel.  I can't
figure out the right combination of parameter juggling to get pointers to
the two blocks;  I assume one has to dereference the pointer to the
byte-vector body, but various things I've tried turn up with bad argument
types.  It would be nice if the code worked for both 64 and 32 bit archs.

Do I have to resort to C and FFI?

Well, the canonical weay should be:

(define (copy-bytes! s-bv s-offs d-bv d-offs n)
   (make-locative s-bv s-offs)
   (make-locative d-bv d-offs)
   n) )

But, alas, MOVE-MEMORY! doesn't handle locatives, yet
(I simply forgot and will fix this right away).

In the meantime you can use the less elegant but more

(define (copy-bytes! s-bv s-offs d-bv d-offs n)
 (##sys#copy-bytes s-bv d-bv s-offs d-offs n) )

(This does not work for SRFI-4 byte-vectors, BTW)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]