From 3388e6b03a23104fac73edd15fe429e63e574779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sat, 24 Sep 2011 20:27:47 -0400 Subject: [PATCH] Revert "vlc_memalign: use memalign() if posix_memalign() isn't here" This reverts commit 0ad141d394dd86e930d1f27be2ea6ea7e698fddf. --- configure.ac | 2 +- include/vlc_common.h | 14 +++++++++++--- modules/codec/avcodec/copy.c | 2 +- src/extras/libc.c | 22 ---------------------- src/libvlccore.sym | 1 - src/misc/picture.c | 2 +- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index 490f3ca67f..ef04fd38bb 100644 --- a/configure.ac +++ b/configure.ac @@ -562,7 +562,7 @@ need_libc=false dnl Check for usual libc functions AC_CHECK_DECLS([nanosleep],,,[#include ]) -AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise posix_memalign setlocale stricmp strnicmp uselocale]) +AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp uselocale]) AC_REPLACE_FUNCS([asprintf atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r lldiv localtime_r nrand48 rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy vasprintf]) AC_CHECK_FUNCS(fdatasync,, [AC_DEFINE(fdatasync, fsync, [Alias fdatasync() to fsync() if missing.]) diff --git a/include/vlc_common.h b/include/vlc_common.h index c7e06d9081..a127bfd88b 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -886,11 +886,19 @@ static inline void SetQWLE (void *p, uint64_t qw) VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t ); /* Aligned memory allocator */ -VLC_API void *vlc_memalign(size_t align, size_t size); #ifdef WIN32 -# define vlc_aligned_free(base) (__mingw_aligned_free(base)) +# include +# define vlc_memalign(align, size) (__mingw_aligned_malloc(size, align)) +# define vlc_free(base) (__mingw_aligned_free(base)) #else -# define vlc_aligned_free(base) free(base) +static inline void *vlc_memalign(size_t align, size_t size) +{ + void *base; + if (unlikely(posix_memalign(&base, align, size))) + base = NULL; + return base; +} +# define vlc_free(base) free(base) #endif VLC_API void vlc_tdestroy( void *, void (*)(void *) ); diff --git a/modules/codec/avcodec/copy.c b/modules/codec/avcodec/copy.c index 2a1955a42f..3c2706926e 100644 --- a/modules/codec/avcodec/copy.c +++ b/modules/codec/avcodec/copy.c @@ -300,7 +300,7 @@ int CopyInitCache(copy_cache_t *cache, unsigned width) } void CopyCleanCache(copy_cache_t *cache) { - vlc_aligned_free(cache->buffer); + vlc_free(cache->buffer); cache->buffer = NULL; cache->size = 0; } diff --git a/src/extras/libc.c b/src/extras/libc.c index db08691188..5004480a0b 100644 --- a/src/extras/libc.c +++ b/src/extras/libc.c @@ -32,12 +32,6 @@ #include #include -#if defined(HAVE_POSIX_MEMALIGN) -# include -#elif defined(HAVE_MEMALIGN) || defined(HAVE_WIN32) -# include -#endif - #include #undef iconv_t @@ -425,19 +419,3 @@ bool vlc_ureduce( unsigned *pi_dst_nom, unsigned *pi_dst_den, return b_exact; } - -void *vlc_memalign(size_t align, size_t size) -{ - void *base; -#if defined(HAVE_POSIX_MEMALIGN) - if (unlikely(posix_memalign(&base, align, size))) - base = NULL; -#elif defined(HAVE_MEMALIGN) - base = memalign(align, size); -#elif defined(HAVE_WIN32) - base = __mingw_aligned_malloc(size, align); -#else -# error Unimplemented! -#endif - return base; -} diff --git a/src/libvlccore.sym b/src/libvlccore.sym index dc066db8d0..672bb53f2a 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -675,5 +675,4 @@ xml_ReaderCreate xml_ReaderDelete xml_ReaderReset vlc_keycode2str -vlc_memalign vlc_str2keycode diff --git a/src/misc/picture.c b/src/misc/picture.c index 3a09685ada..2c47255bd5 100644 --- a/src/misc/picture.c +++ b/src/misc/picture.c @@ -268,7 +268,7 @@ void picture_Delete( picture_t *p_picture ) assert( p_picture->p_release_sys == NULL ); free( p_picture->p_q ); - vlc_aligned_free( p_picture->p_data_orig ); + vlc_free( p_picture->p_data_orig ); free( p_picture->p_sys ); free( p_picture ); }