On Wed, May 25, 2011 at 3:33 PM, Diego Biurrun <[email protected]> wrote:
> Patches welcome, maybe you can implement and test that?
>
I check the function in gcc headers (it declared in xmmintrin.h ->
mm_malloc.h).
On Linux it redirect to posix_memalign(). But on Windows it has body similar
to libavutil:
static __inline__ void* _mm_malloc (size_t size, size_t align) {
void * malloc_ptr;
void * aligned_ptr;
/* Error if align is not a power of two. */
if (align & (align - 1)) {
errno = EINVAL;
return ((void*) 0);
}
if (size == 0)
return ((void *) 0);
/* Assume malloc'd pointer is aligned at least to sizeof (void*).
If necessary, add another sizeof (void*) to store the value
returned by malloc. Effectively this enforces a minimum alignment
of sizeof double. */
if (align < 2 * sizeof (void *))
align = 2 * sizeof (void *);
malloc_ptr = malloc (size + align);
if (!malloc_ptr)
return ((void *) 0);
/* Align We have at least sizeof (void *) space below malloc'd ptr. */
aligned_ptr = (void *) (((size_t) malloc_ptr + align)
& ~((size_t) (align) - 1));
/* Store the original pointer just before p. */
((void **) aligned_ptr) [-1] = malloc_ptr;
return aligned_ptr;
}
static __inline__ void _mm_free (void * aligned_ptr) {
if (aligned_ptr)
free (((void **) aligned_ptr) [-1]);
}
M$ Visual Compiler redirect these functions to own
_aligned_malloc()._aligned_free() (
and has _aligned_realloc()).
However there no any _mm_realloc() function so implementation
av_realloc()will be somewhat
even more tricky than 'memalign hack' (which currently doesn't care about
alignment at all).
-----------------------------------------------
Kirill Gavrilov,
Software designer.
<[email protected]>
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel