Sysadmin > SolarIs > RtorrentSolaris10 > Libtorrent093SolarisPatch
--- rak/allocators.h.old        2012-01-19 11:18:01.000000000 +0100
+++ rak/allocators.h    2014-01-06 14:05:02.353536095 +0100
@@ -44,6 +44,40 @@
 #include <stdlib.h>
 #include <sys/types.h>

+#ifdef __sun__
+// #ifndef HAVE_POSIX_MEMALIGN
+// # ifdef HAVE_MEMALIGN
+
+// Solaris 10 has no posix_memalign so we have to emulate it
+// My know how is very limited, so this is a hack
+// most of the code got from https://www.redhat.com/archives/open-scap-list/2011-April/msg00035.html
+// Pitz 12. Jan 2014
+
+/* Implementing posix_memalign using memalign */
+inline int posix_memalign(void **memptr, size_t alignment, size_t size)
+{
+  if ((alignment % sizeof(void *)) != 0)
+  {
+//    return EINVAL;
+    return 1;
+  }
+
+  *memptr = memalign(alignment, size);
+
+  /* The spec for posix_memalign requires that alignment be a power
+     of 2.   Memalign checks for that case, and returns NULL on failure. */
+  if (*memptr == NULL)
+  {
+    /* posix_memalign must return an appropriate error code */
+//    return EINVAL;
+    return 1;
+  }
+  return 0;
+}
+// # endif /* HAVE_MEMALIGN */
+// #endif /* HAVE_POSIX_MEMALIGN */
+#endif
+
 namespace rak {

 template <class T = void*>