Make weak posix_memalign() private to Solaris
[fio.git] / os / os-solaris.h
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