2 // These #defines attempt to ensure that posix_memalign() is declared, and
3 // so no spurious warning is given about using it.
5 // Advertise compliance of the code to the XSI (a POSIX superset that
6 // defines what a system must be like to be called "UNIX")
8 #define _XOPEN_SOURCE 600
10 // Advertise compliance to POSIX
11 #undef _POSIX_C_SOURCE
12 #define _POSIX_C_SOURCE 200112L
17 #include "tests/malloc.h"
19 #include "../../config.h"
23 # if !defined(VGO_darwin) || (DARWIN_VERS >= DARWIN_10_6)
24 // Nb: assuming VG_MIN_MALLOC_SZB is 8 or more...
27 assert(sizeof(long int) == sizeof(void*));
29 # define PM(a,b,c) posix_memalign((void**)a, b, c)
33 #if defined(VGO_solaris)
36 assert(0 == res
&& p
&& 0 == (long)p
% 64);
41 assert(EINVAL
== res
);
43 assert(EINVAL
== res
);
45 assert(EINVAL
== res
);
47 assert(EINVAL
== res
);
49 assert(EINVAL
== res
);
50 res
= PM(&p
, sizeof(void*), 100);
51 assert(0 == res
&& p
&& 0 == (long)p
% sizeof(void*));
53 res
= PM(&p
, 31, 100);
54 assert(EINVAL
== res
);
55 res
= PM(&p
, 32, 100);
56 assert(0 == res
&& p
&& 0 == (long)p
% 32);
58 res
= PM(&p
, 33, 100);
59 assert(EINVAL
== res
);
60 res
= PM(&p
, 4095, 100);
61 assert(EINVAL
== res
);
62 res
= PM(&p
, 4096, 100);
63 assert(0 == res
&& p
&& 0 == (long)p
% 4096);
65 res
= PM(&p
, 4097, 100);
66 assert(EINVAL
== res
);
67 res
= PM(&p
, 4 * 1024 * 1024, 100);
68 assert(0 == res
&& p
&& 0 == (long)p
% (4 * 1024 * 1024));
70 res
= PM(&p
, 16 * 1024 * 1024, 100);
71 assert(0 == res
&& p
&& 0 == (long)p
% (16 * 1024 * 1024));