changeset 2060:d07784fbdad1 libavcodec

optional and disabled by default memalign hack for SSE/SSE2 on that alternative OS
author michael
date Sun, 06 Jun 2004 03:45:53 +0000
parents ad972ab280bc
children c28b03fea50f
files mem.c
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mem.c	Sat Jun 05 22:36:43 2004 +0000
+++ b/mem.c	Sun Jun 06 03:45:53 2004 +0000
@@ -46,7 +46,13 @@
 {
     void *ptr;
     
-#if defined (HAVE_MEMALIGN)
+#ifdef MEMALIGN_HACK
+    int diff;
+    ptr = malloc(size+16+1);
+    diff= ((-(int)ptr - 1)&15) + 1;
+    ptr += diff;
+    ((char*)ptr)[-1]= diff;
+#elif defined (HAVE_MEMALIGN) 
     ptr = memalign(16,size);
     /* Why 64? 
        Indeed, we should align it:
@@ -87,7 +93,13 @@
  */
 void *av_realloc(void *ptr, unsigned int size)
 {
+#ifdef MEMALIGN_HACK
+    //FIXME this isnt aligned correctly though it probably isnt needed
+    int diff= ptr ? ((char*)ptr)[-1] : 0;
+    return realloc(ptr - diff, size + diff) + diff;
+#else
     return realloc(ptr, size);
+#endif
 }
 
 /* NOTE: ptr = NULL is explicetly allowed */
@@ -95,6 +107,10 @@
 {
     /* XXX: this test should not be needed on most libcs */
     if (ptr)
+#ifdef MEMALIGN_HACK
+        free(ptr - ((char*)ptr)[-1]);
+#else
         free(ptr);
+#endif
 }