]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Use posix_memalign() if available.
authorramiro <ramiro@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 7 Jan 2009 23:36:34 +0000 (23:36 +0000)
committerramiro <ramiro@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 7 Jan 2009 23:36:34 +0000 (23:36 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@16488 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

configure
libavutil/mem.c

index 2c42b47c7046af496ab9c43c02d27a2ea2eb92f2..fe20844a519cfb15128a1e2a2cbbc88dd0bdd907 100755 (executable)
--- a/configure
+++ b/configure
@@ -866,6 +866,7 @@ HAVE_LIST="
     memalign
     mkstemp
     pld
+    posix_memalign
     ppc64
     round
     roundf
@@ -1819,6 +1820,7 @@ check_func  getrusage
 check_func  inet_aton $network_extralibs
 check_func  memalign
 check_func  mkstemp
+check_func  posix_memalign
 check_func_headers windows.h GetProcessTimes
 
 check_header conio.h
@@ -1833,8 +1835,8 @@ check_header vdpau/vdpau.h
 check_header vdpau/vdpau_x11.h
 check_header X11/extensions/XvMClib.h
 
-if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
-    die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
+if ! enabled_any memalign memalign_hack posix_memalign && enabled need_memalign ; then
+    die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
 fi
 
 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
index 960074c70f48dae3b26de8672b096254cd8dca07..328bef787c148e4704c0276f19cd9fd7dca7509b 100644 (file)
@@ -31,6 +31,7 @@
 #undef free
 #undef realloc
 
+#include <stdlib.h>
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
 #endif
@@ -41,7 +42,7 @@
 
 void *av_malloc(unsigned int size)
 {
-    void *ptr;
+    void *ptr = NULL;
 #ifdef CONFIG_MEMALIGN_HACK
     long diff;
 #endif
@@ -57,6 +58,8 @@ void *av_malloc(unsigned int size)
     diff= ((-(long)ptr - 1)&15) + 1;
     ptr = (char*)ptr + diff;
     ((char*)ptr)[-1]= diff;
+#elif defined (HAVE_POSIX_MEMALIGN)
+    posix_memalign(&ptr,16,size);
 #elif defined (HAVE_MEMALIGN)
     ptr = memalign(16,size);
     /* Why 64?