| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 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 |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
/// |
| 9 |
/// \file |
| 10 |
/// This file contains the definition of error handling macros for reporting |
| 11 |
/// fatal error conditions and validating Offload API calls. |
| 12 |
/// |
| 13 |
//===----------------------------------------------------------------------===// |
| 14 |
|
| 15 |
#ifndef MATHTEST_ERRORHANDLING_HPP |
| 16 |
#define MATHTEST_ERRORHANDLING_HPP |
| 17 |
|
| 18 |
#include "mathtest/OffloadForward.hpp" |
| 19 |
|
| 20 |
#include "llvm/ADT/Twine.h" |
| 21 |
|
| 22 |
#define FATAL_ERROR(Message) \ |
| 23 |
mathtest::detail::reportFatalError(Message, __FILE__, __LINE__, __func__) |
| 24 |
|
| 25 |
#define OL_CHECK(ResultExpr) \ |
| 26 |
do { \ |
| 27 |
ol_result_t Result = (ResultExpr); \ |
| 28 |
if (Result != OL_SUCCESS) \ |
| 29 |
mathtest::detail::reportOffloadError(#ResultExpr, Result, __FILE__, \ |
| 30 |
__LINE__, __func__); \ |
| 31 |
\ |
| 32 |
} while (false) |
| 33 |
|
| 34 |
namespace mathtest { |
| 35 |
namespace detail { |
| 36 |
|
| 37 |
[[noreturn]] void reportFatalError(const llvm::Twine &Message, const char *File, |
| 38 |
int Line, const char *FuncName); |
| 39 |
|
| 40 |
[[noreturn]] void reportOffloadError(const char *ResultExpr, ol_result_t Result, |
| 41 |
const char *File, int Line, |
| 42 |
const char *FuncName); |
| 43 |
} // namespace detail |
| 44 |
} // namespace mathtest |
| 45 |
|
| 46 |
#endif // MATHTEST_ERRORHANDLING_HPP |