Skip to content

Commit ff9a212

Browse files
author
Andrew Savonichev
committed
Use #include_next
Signed-off-by: Andrew Savonichev <[email protected]>
1 parent 2122820 commit ff9a212

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

libdevice/cmake/modules/SYCLLibdevice.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ add_custom_command(
112112
${CMAKE_CURRENT_SOURCE_DIR}/include/devicelib.h
113113
${include_dir}/CL/sycl/devicelib
114114
COMMAND ${CMAKE_COMMAND} -E copy
115-
${CMAKE_CURRENT_SOURCE_DIR}/include/devicelib-assert.h
115+
${CMAKE_CURRENT_SOURCE_DIR}/include/assert.h
116116
${include_dir}/CL/sycl/devicelib
117117
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/include/devicelib.h
118-
${CMAKE_CURRENT_SOURCE_DIR}/include/devicelib-assert.h)
118+
${CMAKE_CURRENT_SOURCE_DIR}/include/assert.h)
119119

120120
add_custom_target(libsycldevice-obj DEPENDS
121121
${devicelib-obj-complex}
@@ -141,7 +141,7 @@ else()
141141
endif()
142142

143143
install(FILES ${include_dir}/CL/sycl/devicelib/devicelib.h
144-
${include_dir}/CL/sycl/devicelib/devicelib-assert.h
144+
${include_dir}/CL/sycl/devicelib/assert.h
145145
DESTINATION include/sycl/CL/sycl/devicelib
146146
COMPONENT libsycldevice)
147147

libdevice/include/devicelib-assert.h renamed to libdevice/include/assert.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __DEVICELIB_ASSERT_H__
10+
#define __DEVICELIB_ASSERT_H__
11+
12+
#include_next "assert.h"
913
#include "devicelib.h"
10-
#include <cstddef>
11-
#include <cstdint>
14+
15+
#ifdef __DEVICELIB_DEVICE_ONLY__
16+
17+
#include <stddef.h>
18+
#include <stdint.h>
1219

1320
DEVICE_EXTERNAL size_t __spirv_GlobalInvocationId_x();
1421
DEVICE_EXTERNAL size_t __spirv_GlobalInvocationId_y();
@@ -64,3 +71,6 @@ EXTERN_C inline void _wassert(const wchar_t *wexpr, const wchar_t *wfile,
6471
}
6572

6673
#endif
74+
75+
#endif // __DEVICELIB_DEVICE_ONLY__
76+
#endif // __DEVICELIB_ASSERT_H__

libdevice/include/devicelib.h

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#ifndef __DEVICELIB_H__
10+
#define __DEVICELIB_H__
11+
912
#ifndef _WIN32
1013
#include <features.h> // for GLIBC macro
1114
#endif
@@ -40,3 +43,9 @@
4043
#endif // CL_SYCL_LANGUAGE_VERSION
4144

4245
#define DEVICE_EXTERN_C DEVICE_EXTERNAL EXTERN_C
46+
47+
#ifdef __SYCL_DEVICE_ONLY__
48+
#define __DEVICELIB_DEVICE_ONLY__ 1
49+
#endif
50+
51+
#endif // __DEVICELIB_H__

sycl/include/CL/sycl/builtins.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,4 @@ detail::enable_if_t<detail::is_genfloatf<T>::value, T> tan(T x) __NOEXC {
15461546
} // namespace sycl
15471547
} // __SYCL_INLINE_NAMESPACE(cl)
15481548

1549-
#ifdef __SYCL_DEVICE_ONLY__
1550-
#include "devicelib/devicelib-assert.h"
1551-
#endif // __SYCL_DEVICE_ONLY__
1552-
15531549
#undef __NOEXC

sycl/test/devicelib/assert.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// REQUIRES: cpu,linux
2-
// RUN: %clangxx -fsycl %s -o %t.out
2+
// RUN: %clangxx -fsycl %s -o %t.out -I%sycl_include/CL/sycl/devicelib
33
// (see the other RUN lines below; it is a bit complicated)
44
//
55
// assert() call in device code guarantees nothing: on some devices it behaves

0 commit comments

Comments
 (0)