[vlc-devel] [PATCH 2/2] Work around the lack of dirfd()

Brad Smith brad at comstyle.com
Tue Feb 28 11:37:06 CET 2012


On Tue, Feb 28, 2012 at 09:37:28AM +0000, Maciej (Matchek) Blizi??ski wrote:
> 2012/2/28 Brad Smith <brad at comstyle.com>:
> > Solaris does not have posix_memalign(). This will help..
> 
> I was thinking that a better approach would be to test for
> posix_memalign and define it when missing. What do you think?

VLC already uses macros and the header is already more or less
ready to deal with Solaris. It just needs a bit of tweaking.
Here is a better diff.. the OS's that use memalign() should
not be a hardcoded list and for OS's where both exist posix_memalign()
should be preferred..


diff --git a/configure.ac b/configure.ac
index 6d2562c..51cb16c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -490,7 +490,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 strptime uselocale])
+AC_CHECK_FUNCS([daemon fcntl fstatvfs fork getenv getpwuid_r if_nameindex if_nametoindex isatty lstat posix_memalign memalign mmap openat pread posix_fadvise posix_madvise setlocale stricmp strnicmp strptime uselocale])
 AC_REPLACE_FUNCS([atof atoll dirfd fdopendir flockfile fsync getdelim getpid gmtime_r inet_pton lldiv localtime_r nrand48 poll rewind setenv strcasecmp strcasestr strdup strlcpy strncasecmp strndup strnlen strsep strtof strtok_r strtoll swab tdestroy strverscmp])
 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 545b1cd..0a308c1 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -904,10 +904,7 @@ static void vlc_free(void *ptr)
     if (ptr)
         free((char*)ptr - ((char*)ptr)[-1]);
 }
-#elif defined(__ANDROID__)
-# define vlc_memalign(align, size) memalign(align, size)
-# define vlc_free(base) free(base)
-#else
+#elif defined(HAVE_POSIX_MEMALIGN)
 static inline void *vlc_memalign(size_t align, size_t size)
 {
     void *base;
@@ -916,6 +913,9 @@ static inline void *vlc_memalign(size_t align, size_t size)
     return base;
 }
 # define vlc_free(base) free(base)
+#elif defined(HAVE_MEMALIGN)
+# define vlc_memalign(align, size) memalign(align, size)
+# define vlc_free(base) free(base)
 #endif
 
 VLC_API void vlc_tdestroy( void *, void (*)(void *) );

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the vlc-devel mailing list