Merge the DARWIN branch onto the trunk.

I tried using 'svn merge' to do the merge but it did a terrible job and
there were bazillions of conflicts.  So instead I just took the diff between
the branch and trunk  at r10155, applied the diff to the trunk, 'svn add'ed
the added files (no files needed to be 'svn remove'd) and committed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10156 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/tests/malloc.h b/tests/malloc.h
index 454d2cf..0179b38 100644
--- a/tests/malloc.h
+++ b/tests/malloc.h
@@ -1,7 +1,11 @@
 // Replacement for malloc.h which factors out platform differences.
 
 #include <stdlib.h>
-#include <malloc.h>
+#if defined(VGO_darwin)
+#  include <malloc/malloc.h>
+#else
+#  include <malloc.h>
+#endif
 
 #include <assert.h>
 
@@ -10,7 +14,12 @@
 static void* memalign16(size_t szB)
 {
    void* x;
+#if defined(VGO_darwin)
+   // Darwin lacks memalign, but its malloc is always 16-aligned anyway.
+   x = malloc(szB);
+#else
    x = memalign(16, szB);
+#endif
    assert(x);
    assert(0 == ((16-1) & (unsigned long)x));
    return x;