Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / linux / aligned_alloc.c
bloba4bb995f7cac3c99b46c115c3f43d915f3d6ceda
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <errno.h>
4 #include "../../../config.h"
6 int main(void)
8 #if defined (HAVE_GNU_LIBC_C17_ALIGNED_ALLOC)
9 char* p = NULL;
11 // zero size
12 p = aligned_alloc(0, 8);
13 assert(p == NULL);
15 // non multiple of alignment
16 p = aligned_alloc(8, 25);
17 assert(p && ((size_t)p % 8U == 0U));
18 free(p);
20 // align not power of 2
21 p = aligned_alloc(40, 160);
22 assert(p == NULL);
23 errno = 0;
24 #endif
25 #if defined(MUSL_LIBC)
26 char* p = NULL;
28 // zero size
29 p = aligned_alloc(0, 8);
30 assert(p && ((size_t)p % 8U == 0U));
31 free(p);
32 // non multiple of alignment passes on FreeBSD
33 p = aligned_alloc(8, 25);
34 assert(p && ((size_t)p % 8U == 0U));
35 free(p);
36 //errno = 0;
37 // align not power of 2
38 p = aligned_alloc(40, 160);
39 assert(p == NULL);
40 errno = 0;
41 // the test below causes a segfault with musl 1.2.2
42 // apparently it has been fixed in 1.2.3
43 #if 0
44 // too big
45 if (sizeof(size_t) == 8)
47 p = aligned_alloc(16, 1UL<<48);
49 else
51 p = NULL;
52 errno = ENOMEM;
54 assert(p == NULL && errno == ENOMEM);
55 #endif
56 #endif