base: don't define posix_memalign, if it cannot be emulated
authorMarko Kreen <markokr@gmail.com>
Mon, 6 Sep 2010 05:19:57 +0000 (08:19 +0300)
committerMarko Kreen <markokr@gmail.com>
Mon, 6 Sep 2010 05:19:57 +0000 (08:19 +0300)
usual/base.c

index ed4515696f7ffa59b27a7e8d2bdf88355362951a..9489d9ff333d8fc71ce3a9b49a77ca07bb75d42c 100644 (file)
 #include <malloc.h>
 #endif
 
-#ifndef HAVE_POSIX_MEMALIGN
+/* define posix_memalign() only when possible to emulate */
+#if !defined(HAVE_POSIX_MEMALIGN) \
+    && (defined(HAVE_MEMALIGN) || defined(HAVE_VALLOC))
+
 int posix_memalign(void **ptr_p, size_t align, size_t len)
 {
        void *p;
@@ -34,9 +37,6 @@ int posix_memalign(void **ptr_p, size_t align, size_t len)
 #ifdef HAVE_VALLOC
        /* assuming less than pagesize alignment */
        p = valloc(len);
-#else /* !VALLOC */
-       #warning "cannot emulate posix_memalign sanely"
-       p = malloc(len);
 #endif /* !VALLOC */
 #endif /* !MEMALIGN */