[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#14599: An option to make vector allocation aligned
From: |
Andy Wingo |
Subject: |
bug#14599: An option to make vector allocation aligned |
Date: |
Wed, 12 Jun 2013 22:37:40 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
On Wed 12 Jun 2013 15:37, Jan Schukat <address@hidden> 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/
- bug#14599: An option to make vector allocation aligned, Jan Schukat, 2013/06/12
- bug#14599: An option to make vector allocation aligned, Ludovic Courtès, 2013/06/12
- bug#14599: An option to make vector allocation aligned, Jan Schukat, 2013/06/12
- bug#14599: An option to make vector allocation aligned, Jan Schukat, 2013/06/12
- bug#14599: An option to make vector allocation aligned, Ludovic Courtès, 2013/06/13
- bug#14599: An option to make vector allocation aligned, Daniel Hartwig, 2013/06/13
- bug#14599: An option to make vector allocation aligned, Jan Schukat, 2013/06/14
- bug#14599: An option to make vector allocation aligned, Ludovic Courtès, 2013/06/14
- bug#14599: An option to make vector allocation aligned, Jan Schukat, 2013/06/17
bug#14599: An option to make vector allocation aligned,
Andy Wingo <=