[vlc-devel] [PATCH] Mac: Add a detection for posix_memalign and a work-around
Jean-Baptiste Kempf
jb at videolan.org
Tue Sep 20 18:21:49 CEST 2011
This should fix compilation on MacOS X sdk-10.5
---
configure.ac | 2 +-
include/vlc_common.h | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index 854753d..90d957f 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 <time.h>])
-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_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_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 a127bfd..4607766 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -893,10 +893,14 @@ VLC_API bool vlc_ureduce( unsigned *, unsigned *, uint64_t, uint64_t, uint64_t )
#else
static inline void *vlc_memalign(size_t align, size_t size)
{
+#ifdef HAVE_POSIX_MEMALIGN
void *base;
if (unlikely(posix_memalign(&base, align, size)))
base = NULL;
return base;
+#else
+ return memalign(align, size);
+#endif
}
# define vlc_free(base) free(base)
#endif
--
1.7.7.rc1
More information about the vlc-devel
mailing list