[gambit-list] allocating still u8vectors

Dimitris Vyzovitis vyzo at hackzen.org
Fri Nov 15 06:27:15 EST 2019


thanks Marc!

-- vyzo

On Fri, Nov 15, 2019 at 1:16 PM Marc Feeley <feeley at iro.umontreal.ca> wrote:

> You can use the C interface to call ___alloc_scmobj with the first
> argument equal to the processor state, or call ##still-copy to make a still
> copy of an existing u8vector:
>
>
> ;; this code is specific to the C backend
>
> (define (make-u8vector-still len)
>   (let ((result
>          ((c-lambda
>               (unsigned-int)
>               scheme-object
>             "___SCMOBJ result = ___EXT(___alloc_scmobj) (___ps,
> ___sU8VECTOR, ___arg1);
>              if (!___FIXNUMP(result))
>                ___still_obj_refcount_dec (result);
>              ___return(result);
>             ")
>           len)))
>     (if (##fixnum? result)
>         (begin
>           (##raise-heap-overflow-exception)
>           (make-u8vector-still len))
>         result)))
>
> (define still?
>   (c-lambda
>       (scheme-object)
>       bool
>     "___return(___HD_TYP(___HEADER(___arg1)) == ___STILL);"))
>
>
> (pp (still? (make-u8vector 1000))) ;; #f (small objects are movable)
>
> (pp (still? (make-u8vector 3000))) ;; #t (large objects are still)
>
> (pp (still? (##still-copy (make-u8vector 10)))) ;; #t (make a still copy)
>
> (pp (still? (make-u8vector-still 10))) ;; #t (allocated as still even if
> small)
>
>
> Marc
>
>
>
> > On Nov 15, 2019, at 3:39 AM, Dimitris Vyzovitis <vyzo at hackzen.org>
> wrote:
> >
> > What's the magic incantation to allocate a still u8vector?
> > I can't seem to find any primitive procedure (in scheme or in C) for
> this.
> >
> > -- vyzo
> > _______________________________________________
> > Gambit-list mailing list
> > Gambit-list at iro.umontreal.ca
> > https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20191115/3e55b4f9/attachment.htm>


More information about the Gambit-list mailing list