2 #if defined(__FreeBSD__)
14 res
= posix_memalign((void**)&p
, 0, 8);
15 assert(p
== NULL
&& res
== EINVAL
);
16 // align not multiple of sizeof(void*)
17 res
= posix_memalign((void**)&p
, 2, 32);
18 assert(p
== NULL
&& res
== EINVAL
);
19 // align not power of two
20 res
= posix_memalign((void**)&p
, 40, 160);
21 assert(p
== NULL
&& res
== EINVAL
);
23 // digging through the jemalloc code
24 // the max alignment allowed is
25 // 0x70000000 for i386 and
26 // 0x7000000000000000 for amd64
27 // but valgrind has a limit of only 16M
30 // the 64bit limit is around 1e18 bytes
31 // a million terabytes
33 // Valgrind handles that badly. it throws a core_panic :-(
35 //res = posix_memalign((void**)&p, (1UL<<63), 4096);
36 //assert(p == NULL && res == ENOMEM);
39 if (sizeof(size_t) == 8)
41 res
= posix_memalign((void**)&p
, 16, 1UL<<48);
45 // on x86 it's hard to actually get ENOMEM
46 // if we ask for more than 2Gbytes the fishy
47 // detector will kick in and not try to allocate
48 // less than 2Gbytes and it's likely to succeed
49 // (at least on a machine just running VG regtests)
54 assert(p
== NULL
&& res
== ENOMEM
);
58 // if ever we make this multi-platform, Solaris doesn't support this
60 p
= aligned_alloc(32, 0);
61 assert(p
&& ((size_t)p
% 32U == 0U));
64 p
= aligned_alloc(0, 8);
65 assert(p
== NULL
&& errno
== EINVAL
);
67 // non multiple of alignment passes on FreeBSD
68 p
= aligned_alloc(8, 25);
69 assert(p
&& ((size_t)p
% 8U == 0U));
72 // align not power of 2
73 p
= aligned_alloc(40, 160);
74 assert(p
== NULL
&& errno
== EINVAL
);
77 if (sizeof(size_t) == 8)
79 p
= aligned_alloc(16, 1UL<<48);
86 assert(p
== NULL
&& errno
== ENOMEM
);