GNU bug report logs - #14599
An option to make vector allocation aligned

Previous Next

Package: guile;

Reported by: Jan Schukat <shookie <at> email.de>

Date: Wed, 12 Jun 2013 13:38:02 UTC

Severity: wishlist

Full log


Message #16 received at 14599 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: Jan Schukat <shookie <at> email.de>
Cc: 14599 <at> debbugs.gnu.org
Subject: Re: bug#14599: An option to make vector allocation aligned
Date: Wed, 12 Jun 2013 22:37:40 +0200
On Wed 12 Jun 2013 15:37, Jan Schukat <shookie <at> email.de> writes:

> If you want to access native uniform vectors from c, sometimes you
> really want guarantees about the alignment.

16 bytes I guess?  Guile's uniforms are 8-byte-aligned by default, as
you probably know.

Just wondering if there is a better default.

> +#ifdef SCM_VECTOR_ALIGN
> +      contents = scm_gc_malloc_pointerless (SCM_BYTEVECTOR_HEADER_BYTES
> + c_len + SCM_VECTOR_ALIGN,
> +                        SCM_GC_BYTEVECTOR);
> +      ret = PTR2SCM (contents);
> +      contents += SCM_BYTEVECTOR_HEADER_BYTES;
> +      contents += (addr + (SCM_VECTOR_ALIGN - 1)) & -SCM_VECTOR_ALIGN;
> +#else
>        contents = scm_gc_malloc_pointerless (SCM_BYTEVECTOR_HEADER_BYTES
> + c_len,
>                          SCM_GC_BYTEVECTOR);
>        ret = PTR2SCM (contents);
>        contents += SCM_BYTEVECTOR_HEADER_BYTES;
> +#endif

This is somewhat dangerous, as you could lose the pointer to the start,
and then the contents get collected.

I guess this can be fixed in master, if you set the "holder" field on a
bytevector to the actual memory that you allocate.

Andy
-- 
http://wingolog.org/




This bug report was last modified 12 years and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.