Blender  V3.3
util_aligned_malloc_test.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #include "testing/testing.h"
5 
6 #include "util/aligned_malloc.h"
7 
8 #define CHECK_ALIGNMENT(ptr, align) EXPECT_EQ((size_t)ptr % align, 0)
9 
11 
12 TEST(util_aligned_malloc, aligned_malloc_16)
13 {
14  int *mem = (int *)util_aligned_malloc(sizeof(int), 16);
15  CHECK_ALIGNMENT(mem, 16);
16  util_aligned_free(mem);
17 }
18 
19 /* On Apple we currently only support 16 bytes alignment. */
20 #ifndef __APPLE__
21 TEST(util_aligned_malloc, aligned_malloc_32)
22 {
23  int *mem = (int *)util_aligned_malloc(sizeof(int), 32);
24  CHECK_ALIGNMENT(mem, 32);
25  util_aligned_free(mem);
26 }
27 #endif /* __APPLE__ */
28 
void util_aligned_free(void *ptr)
CCL_NAMESPACE_BEGIN void * util_aligned_malloc(size_t size, int alignment)
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
#define CHECK_ALIGNMENT(ptr, align)
CCL_NAMESPACE_BEGIN TEST(util_aligned_malloc, aligned_malloc_16)