1 //===-- GPU Implementation of aligned_alloc -------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "src/stdlib/aligned_alloc.h"
11 #include "src/__support/GPU/allocator.h"
12 #include "src/__support/common.h"
13 #include "src/__support/macros/config.h"
15 namespace LIBC_NAMESPACE_DECL
{
17 LLVM_LIBC_FUNCTION(void *, aligned_alloc
, (size_t alignment
, size_t size
)) {
18 if ((alignment
& -alignment
) != alignment
)
21 void *ptr
= gpu::allocate(size
);
22 if ((reinterpret_cast<uintptr_t>(ptr
) & (alignment
- 1)) != 0) {
29 } // namespace LIBC_NAMESPACE_DECL