Rhys Kidd 774dbf0a73 Increase test coverage on OS X, by re-enabling the memcheck/tests/amd64/xsave-avx regression tests with a handy memalign() shim.
n-i-bz

(Unfortunately I don’t have right here the hw support, but build environment works)

$ perl tests/vg_regtest memcheck/tests/amd64/xsave-avx
xsave-avx:       (skipping, prereq failed: test -x xsave-avx && ../../../tests/x86_amd64_features amd64-avx)

== 0 tests, 0 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==


On OS X 10.10

Before:

== 594 tests, 215 stderr failures, 9 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures ==

After:

== 594 tests, 215 stderr failures, 9 stdout failures, 0 stderrB failures, 0 stdoutB failures, 30 post failures ==


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15551
2015-08-15 11:16:35 +00:00

60 lines
1.2 KiB
C

// Replacement for malloc.h which factors out platform differences.
#include <stdlib.h>
#if defined(VGO_darwin)
# include <malloc/malloc.h>
#else
# include <malloc.h>
#endif
#include <assert.h>
// Allocates a 16-aligned block. Asserts if the allocation fails.
__attribute__((unused))
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;
}
// Allocates a 32-aligned block. Asserts if the allocation fails.
__attribute__((unused))
static void* memalign32(size_t szB)
{
void* x;
#if defined(VGO_darwin)
// Darwin lacks memalign
posix_memalign((void **)&x, 32, szB);
#else
x = memalign(32, szB);
#endif
assert(x);
assert(0 == ((32-1) & (unsigned long)x));
return x;
}
// Allocates a 64-aligned block. Asserts if the allocation fails.
__attribute__((unused))
static void* memalign64(size_t szB)
{
void* x;
#if defined(VGO_darwin)
// Darwin lacks memalign
posix_memalign((void **)&x, 64, szB);
#else
x = memalign(64, szB);
#endif
assert(x);
assert(0 == ((64-1) & (unsigned long)x));
return x;
}