1 // Replacement for malloc.h which factors out platform differences.
4 #if defined(VGO_darwin)
5 # include <malloc/malloc.h>
12 // Allocates a 16-aligned block. Asserts if the allocation fails.
13 __attribute__((unused
))
14 static void* memalign16(size_t szB
)
17 #if defined(VGO_darwin)
18 // Darwin lacks memalign, but its malloc is always 16-aligned anyway.
19 posix_memalign((void **)&x
, 16, szB
);
21 x
= memalign(16, szB
);
24 assert(0 == ((16-1) & (unsigned long)x
));
28 // Allocates a 32-aligned block. Asserts if the allocation fails.
29 __attribute__((unused
))
30 static void* memalign32(size_t szB
)
33 #if defined(VGO_darwin)
34 // Darwin lacks memalign
35 posix_memalign((void **)&x
, 32, szB
);
37 x
= memalign(32, szB
);
40 assert(0 == ((32-1) & (unsigned long)x
));
44 // Allocates a 64-aligned block. Asserts if the allocation fails.
45 __attribute__((unused
))
46 static void* memalign64(size_t szB
)
49 #if defined(VGO_darwin)
50 // Darwin lacks memalign
51 posix_memalign((void **)&x
, 64, szB
);
53 x
= memalign(64, szB
);
56 assert(0 == ((64-1) & (unsigned long)x
));