Make weak posix_memalign() private to Solaris
authorJens Axboe <jens.axboe@oracle.com>
Wed, 16 Dec 2009 08:50:05 +0000 (09:50 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 16 Dec 2009 08:50:05 +0000 (09:50 +0100)
OSX has posix_memalign() but no memalign() and no malloc.h
standard include. So until we have a autoconf based build
system, move this weak helper to the private Solaris header.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
helpers.c
os/os-solaris.h

index 098195c8f0f2a61279e64baa6b5e55c58caea3dd..8ac58239fef434a5338fcce4f3f54f65586ed22d 100644 (file)
--- a/helpers.c
+++ b/helpers.c
@@ -1,20 +1,11 @@
-#include <malloc.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <netinet/in.h>
 
 #include "compiler/compiler.h"
 
-int __weak posix_memalign(void **ptr, size_t align, size_t size)
-{
-       *ptr = memalign(align, size);
-       if (*ptr)
-               return 0;
-
-       return ENOMEM;
-}
-
 int __weak posix_fallocate(int fd, off_t offset, off_t len)
 {
        return 0;
index ff8d6f25d6ca6a02497d7cab081873dad376a6c5..175654e84bf49864c7dab08e3ad8906b45b8ca73 100644 (file)
@@ -2,6 +2,7 @@
 #define FIO_OS_SOLARIS_H
 
 #include <errno.h>
+#include <malloc.h>
 #include <sys/types.h>
 #include <sys/fcntl.h>
 #include <sys/pset.h>
@@ -102,4 +103,17 @@ static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
 #define FIO_MADV_FREE  MADV_FREE
 #endif
 
+/*
+ * Some Solaris versions don't have posix_memalign(), provide a private
+ * weak alternative
+ */
+static inline int __weak posix_memalign(void **ptr, size_t align, size_t size)
+{
+       *ptr = memalign(align, size);
+       if (*ptr)
+               return 0;
+
+       return ENOMEM;
+}
+
 #endif