Skip to content

Commit

Permalink
[Clang][libc] Add wrapper headers for assert.h for the GPU libc
Browse files Browse the repository at this point in the history
Summary:
This patch adds the `assert.h` wrapper header. I forgot to include this
in the last patch.
  • Loading branch information
jhuber6 committed Sep 1, 2023
1 parent 63b2911 commit e082973
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,13 @@ set(openmp_wrapper_files
)

set(llvm_libc_wrapper_files
llvm_libc_wrappers/assert.h
llvm_libc_wrappers/stdio.h
llvm_libc_wrappers/stdlib.h
llvm_libc_wrappers/string.h
llvm_libc_wrappers/ctype.h
llvm_libc_wrappers/inttypes.h
llvm_libc_wrappers/time.h
)

include(GetClangResourceDir)
Expand Down
34 changes: 34 additions & 0 deletions clang/lib/Headers/llvm_libc_wrappers/assert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//===-- Wrapper for C standard assert.h declarations on the GPU ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__
#define __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__

#if !defined(_OPENMP) && !defined(__HIP__) && !defined(__CUDA__)
#error "This file is for GPU offloading compilation only"
#endif

#include_next <assert.h>

#if __has_include(<llvm-libc-decls/assert.h>)

#if defined(__HIP__) || defined(__CUDA__)
#define __LIBC_ATTRS __attribute__((device))
#endif

#pragma omp begin declare target

#include <llvm-libc-decls/assert.h>

#pragma omp end declare target

#undef __LIBC_ATTRS

#endif

#endif // __CLANG_LLVM_LIBC_WRAPPERS_ASSERT_H__

0 comments on commit e082973

Please sign in to comment.