4 #include "tests/malloc.h"
6 #include "../../../config.h"
13 assert(sizeof(long int) == sizeof(void*));
15 p
= memalign(1024 * 1024, 4 * 1024 * 1024 + 1);
16 assert(0 == (long)p
% (1024 * 1024));
17 piece
= malloc(1024 * 1000); assert (piece
);
21 p
= memalign(1024 * 1024, 4 * 1024 * 1024 + 1);
22 assert(0 == (long)p
% (1024 * 1024));
23 piece
= malloc(1024 * 100); assert (piece
);
27 // Illumos doesn't allow a size of 0
31 assert(errno
== EINVAL
);
33 // Doesn't allow an alignment of 0 either
36 assert(errno
== EINVAL
);
38 // and most peculiar compared to other memaligns
39 // the alignment must be a multiple of 4
40 // but not necessarily a power of 2
45 assert(errno
== EINVAL
);
48 assert(errno
== EINVAL
);
51 assert(errno
== EINVAL
);
53 assert(p
&& 0 == (long)p
% 8);
56 assert(errno
== EINVAL
);
60 assert(errno
== EINVAL
);
62 assert(p
&& 0 == (long)p
% 8);
66 assert(errno
== EINVAL
);
67 p
= memalign(12, 100);
68 assert(p
&& 0 == (long)p
% 16);
70 p
= memalign(31, 100);
72 assert(errno
== EINVAL
);
73 p
= memalign(32, 100);
74 assert(p
&& 0 == (long)p
% 32);
76 p
= memalign(33, 100);
78 assert(errno
== EINVAL
);
80 p
= memalign(4095, 100);
82 assert(errno
== EINVAL
);
83 p
= memalign(4096, 100);
84 assert(p
&& 0 == (long)p
% 4096);
86 p
= memalign(4097, 100);
88 assert(errno
== EINVAL
);
90 p
= memalign(4 * 1024 * 1024, 100);
91 assert(p
&& 0 == (long)p
% (4 * 1024 * 1024));
92 p
= memalign(16 * 1024 * 1024, 100);
93 assert(p
&& 0 == (long)p
% (16 * 1024 * 1024));