]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / Windows / aligned_mallocs.cc
1 // RUN: %clang_cl_asan -O0 %s -Fe%t
2 // RUN: %run %t
3
4 #include <windows.h>
5
6 #define CHECK_ALIGNED(ptr,alignment) \
7 do { \
8 if (((uintptr_t)(ptr) % (alignment)) != 0) \
9 return __LINE__; \
10 } \
11 while(0)
12
13 int main(void) {
14 int *p = (int*)_aligned_malloc(1024 * sizeof(int), 32);
15 CHECK_ALIGNED(p, 32);
16 p[512] = 0;
17 _aligned_free(p);
18
19 p = (int*)_aligned_malloc(128, 128);
20 CHECK_ALIGNED(p, 128);
21 p = (int*)_aligned_realloc(p, 2048 * sizeof(int), 128);
22 CHECK_ALIGNED(p, 128);
23 p[1024] = 0;
24 if (_aligned_msize(p, 128, 0) != 2048 * sizeof(int))
25 return __LINE__;
26 _aligned_free(p);
27
28 return 0;
29 }