Skip to content

Commit fb445db

Browse files
committed
Fix comment and formatting.
1 parent 6a488c3 commit fb445db

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

sycl/include/sycl/stl_wrappers/corecrt.h

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// When std::array is used in device code, MSVC's STL uses a _invalid_parameter
10-
// function. This causes issue when _invalid_parameter is invoked from device
11-
// code:
9+
// MSVC's STL emits functions like _invalid_parameter and _invoke_watson
10+
// to validate parameters passed to STL containers, like std::array, when
11+
// compiled in debug mode.
12+
// STL containers when used in device code fails to compile on Windows
13+
// because these functions are not marked with SYCL_EXTERNAL attribute.
1214

13-
// 1. `_invalid_parameter` is provided via ucrtbased.dll at runtime: DLLs are
14-
// not loaded for device code, thus causing undefined symbol errors.
15-
16-
// 2. MSVC's STL never defined the function as SYCL_EXTERNAL, errors are thrown
17-
// when device code tries to invoke `_invalid_parameter`.
18-
19-
// As a workaround, this wrapper wraps around corecrt.h and defines a custom
20-
// _invalid_parameter for device code compilation.
21-
22-
// This new SYCL_EXTERNAL definition of _invalid_parameter has to be declared
23-
// before corecrt.h is included: Thus, we have this STL wrapper instead of
24-
// declaring _invalid_parameter function in SYCL headers.
15+
// As a workaround, this wrapper defines a custom, empty defination of
16+
// _invalid_parameter and _invoke_watson for device code.
17+
// MSVC picks up these definitions instead of the ones defined in MSVC's
18+
// corecrt header.
2519

2620
#pragma once
2721

@@ -36,14 +30,12 @@ extern "C" inline void __cdecl _invalid_parameter(wchar_t const *,
3630
// Do nothing when called in device code
3731
}
3832

39-
extern "C" __declspec(noreturn) void __cdecl
40-
_invoke_watson(wchar_t const *const expression,
41-
wchar_t const *const function_name,
42-
wchar_t const *const file_name, unsigned int const line_number,
43-
uintptr_t const reserved) {
33+
extern "C" __declspec(noreturn) void __cdecl _invoke_watson(
34+
wchar_t const *const expression, wchar_t const *const function_name,
35+
wchar_t const *const file_name, unsigned int const line_number,
36+
uintptr_t const reserved) {
4437
// Do nothing.
4538
}
46-
4739
#endif
4840

4941
#if defined(__has_include_next)

0 commit comments

Comments
 (0)