Skip to content

Commit 42b924e

Browse files
authored
[SYCL][COMPAT] Convert error names to lower case (#15373)
This is done to avoid conflict with upper-case macros redefining e.g. `SUCCESS`. I'm also bumping to `0.2.0`.
1 parent dff3d00 commit 42b924e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

sycl/doc/syclcompat/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,10 +1579,10 @@ SYCL spec supported by the current SYCL compiler.
15791579
15801580
The `SYCLCOMPAT_CHECK_ERROR` macro encapsulates an error-handling mechanism for
15811581
expressions that might throw `sycl::exception` and `std::runtime_error`. If no
1582-
exceptions are thrown, it returns `syclcompat::error_code::SUCCESS`. If a
1583-
`sycl::exception` is caught, it returns `syclcompat::error_code::BACKEND_ERROR`.
1582+
exceptions are thrown, it returns `syclcompat::error_code::success`. If a
1583+
`sycl::exception` is caught, it returns `syclcompat::error_code::backend_error`.
15841584
If a `std::runtime_error` exception is caught,
1585-
`syclcompat::error_code::DEFAULT_ERROR` is returned instead. For both cases, it
1585+
`syclcompat::error_code::default_error` is returned instead. For both cases, it
15861586
prints the error message to the standard error stream.
15871587
15881588
``` c++
@@ -1615,7 +1615,7 @@ template <int Arg> class syclcompat_kernel_scalar;
16151615
16161616
16171617
namespace syclcompat {
1618-
enum error_code { SUCCESS = 0, BACKEND_ERROR = 1, DEFAULT_ERROR = 999 };
1618+
enum error_code { success = 0, backend_error = 1, default_error = 999 };
16191619
}
16201620
16211621
#define SYCLCOMPAT_CHECK_ERROR(expr)

sycl/include/syclcompat/defs.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ template <int Arg> class syclcompat_kernel_scalar;
5656
#endif
5757

5858
#define SYCLCOMPAT_MAJOR_VERSION 0
59-
#define SYCLCOMPAT_MINOR_VERSION 1
59+
#define SYCLCOMPAT_MINOR_VERSION 2
6060
#define SYCLCOMPAT_PATCH_VERSION 0
6161

6262
#define SYCLCOMPAT_MAKE_VERSION(_major, _minor, _patch) \
@@ -67,19 +67,19 @@ template <int Arg> class syclcompat_kernel_scalar;
6767
SYCLCOMPAT_PATCH_VERSION)
6868

6969
namespace syclcompat {
70-
enum error_code { SUCCESS = 0, BACKEND_ERROR = 1, DEFAULT_ERROR = 999 };
70+
enum error_code { success = 0, backend_error = 1, default_error = 999 };
7171
}
7272

7373
#define SYCLCOMPAT_CHECK_ERROR(expr) \
7474
[&]() { \
7575
try { \
7676
expr; \
77-
return syclcompat::error_code::SUCCESS; \
77+
return syclcompat::error_code::success; \
7878
} catch (sycl::exception const &e) { \
7979
std::cerr << e.what() << std::endl; \
80-
return syclcompat::error_code::BACKEND_ERROR; \
80+
return syclcompat::error_code::backend_error; \
8181
} catch (std::runtime_error const &e) { \
8282
std::cerr << e.what() << std::endl; \
83-
return syclcompat::error_code::DEFAULT_ERROR; \
83+
return syclcompat::error_code::default_error; \
8484
} \
8585
}()

sycl/test-e2e/syclcompat/defs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ void test_check_error() {
5454
throw std::runtime_error("Expected invalid exception in test_check_error");
5555
};
5656

57-
assert(syclcompat::error_code::SUCCESS == SYCLCOMPAT_CHECK_ERROR());
58-
assert(syclcompat::error_code::BACKEND_ERROR ==
57+
assert(syclcompat::error_code::success == SYCLCOMPAT_CHECK_ERROR());
58+
assert(syclcompat::error_code::backend_error ==
5959
SYCLCOMPAT_CHECK_ERROR(sycl_error_throw()));
60-
assert(syclcompat::error_code::DEFAULT_ERROR ==
60+
assert(syclcompat::error_code::default_error ==
6161
SYCLCOMPAT_CHECK_ERROR(runtime_error_throw()));
6262
}
6363

0 commit comments

Comments
 (0)