diff options
Diffstat (limited to 'libc/src/stdlib/gpu/aligned_alloc.cpp')
| -rw-r--r-- | libc/src/stdlib/gpu/aligned_alloc.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libc/src/stdlib/gpu/aligned_alloc.cpp b/libc/src/stdlib/gpu/aligned_alloc.cpp index cd2c7e55128f..34a7eae618fe 100644 --- a/libc/src/stdlib/gpu/aligned_alloc.cpp +++ b/libc/src/stdlib/gpu/aligned_alloc.cpp @@ -15,15 +15,15 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(void *, aligned_alloc, (size_t alignment, size_t size)) { - if ((alignment & -alignment) != alignment) - return nullptr; - - void *ptr = gpu::allocate(size); - if ((reinterpret_cast<uintptr_t>(ptr) & (alignment - 1)) != 0) { - gpu::deallocate(ptr); - return nullptr; - } - return ptr; + // FIXME: NVIDIA targets currently use the built-in 'malloc' which we cannot + // reason with. But we still need to provide this function for compatibility. +#ifndef LIBC_TARGET_ARCH_IS_NVPTX + return gpu::aligned_allocate(static_cast<uint32_t>(alignment), size); +#else + (void)alignment; + (void)size; + return nullptr; +#endif } } // namespace LIBC_NAMESPACE_DECL |
