mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
Solaris 11.3 doesn't have aligned_alloc - add a configure time test memalign does not accept either a size or an alignment of zero
40 lines
695 B
C
40 lines
695 B
C
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
#include "../../config.h"
|
|
|
|
int main(void)
|
|
{
|
|
#if defined(HAVE_ALIGNED_ALLOC)
|
|
char* p = NULL;
|
|
|
|
// zero size
|
|
p = aligned_alloc(0, 8);
|
|
assert(p == NULL && errno == EINVAL);
|
|
errno = 0;
|
|
// non multiple of alignment passes on Solaris
|
|
p = aligned_alloc(8, 25);
|
|
assert(p && ((size_t)p % 8U == 0U));
|
|
free(p);
|
|
//errno = 0;
|
|
// align not power of 2
|
|
p = aligned_alloc(40, 160);
|
|
assert(p);
|
|
errno = 0;
|
|
|
|
// too big aligment
|
|
if (sizeof(size_t) == 8)
|
|
{
|
|
p = aligned_alloc(16, 1UL<<48);
|
|
}
|
|
else
|
|
{
|
|
p = NULL;
|
|
errno = ENOMEM;
|
|
}
|
|
|
|
assert(p == NULL && errno == ENOMEM);
|
|
#endif
|
|
}
|
|
|