mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-25 08:19:02 +00:00
Fix align_malloc on Linux (#645)
posix_memalign requires alignment to be a power of two and a multiple of sizeof(void*). All powers of two greater than sizeof(void*) are multiples of sizeof(void*) so we only need to make sure sizeof(void*) is the minimum value passed to posix_memalign. Fixes #644 Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
@@ -40,6 +40,9 @@ static void * align_malloc(size_t size, size_t alignment)
|
|||||||
if ( ptr )
|
if ( ptr )
|
||||||
return ptr;
|
return ptr;
|
||||||
#else
|
#else
|
||||||
|
if (alignment < sizeof(void*)) {
|
||||||
|
alignment = sizeof(void*);
|
||||||
|
}
|
||||||
if (0 == posix_memalign(&ptr, alignment, size))
|
if (0 == posix_memalign(&ptr, alignment, size))
|
||||||
return ptr;
|
return ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user