diff options
author | Bastiaan Olij <mux213@gmail.com> | 2021-12-08 18:31:06 +1100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-02-23 11:50:45 +0100 |
commit | 65bae5a3411a6fd2dbfc9f8e364040024fa81b04 (patch) | |
tree | 0724a9c660a37bbb6305a11d893345dda71f6630 /thirdparty/openxr/src/loader/exception_handling.hpp | |
parent | fcf8c2006d39d4e1d97f68e2463514cfa60b5f21 (diff) | |
download | redot-engine-65bae5a3411a6fd2dbfc9f8e364040024fa81b04.tar.gz |
Add OpenXR 1.0.22 to thirdparty libraries
Will be compiled and used in the next commit.
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'thirdparty/openxr/src/loader/exception_handling.hpp')
-rw-r--r-- | thirdparty/openxr/src/loader/exception_handling.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/thirdparty/openxr/src/loader/exception_handling.hpp b/thirdparty/openxr/src/loader/exception_handling.hpp new file mode 100644 index 0000000000..428dd00279 --- /dev/null +++ b/thirdparty/openxr/src/loader/exception_handling.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2019-2022, The Khronos Group Inc. +// +// SPDX-License-Identifier: Apache-2.0 OR MIT +// +// Initial Author: Ryan Pavlik <ryan.pavlik@collabora.com> +// +// Provides protection for C ABI functions if standard library functions may throw. + +#pragma once + +#ifdef OPENXR_HAVE_COMMON_CONFIG +#include "common_config.h" +#endif // OPENXR_HAVE_COMMON_CONFIG + +#ifdef XRLOADER_DISABLE_EXCEPTION_HANDLING + +#define XRLOADER_ABI_TRY +#define XRLOADER_ABI_CATCH_BAD_ALLOC_OOM +#define XRLOADER_ABI_CATCH_FALLBACK + +#else + +#include <stdexcept> +#define XRLOADER_ABI_TRY try +#define XRLOADER_ABI_CATCH_BAD_ALLOC_OOM \ + catch (const std::bad_alloc&) { \ + LoaderLogger::LogErrorMessage("", "failed allocating memory"); \ + return XR_ERROR_OUT_OF_MEMORY; \ + } +#define XRLOADER_ABI_CATCH_FALLBACK \ + catch (const std::exception& e) { \ + LoaderLogger::LogErrorMessage("", "Unknown failure: " + std::string(e.what())); \ + return XR_ERROR_RUNTIME_FAILURE; \ + } \ + catch (...) { \ + LoaderLogger::LogErrorMessage("", "Unknown failure"); \ + return XR_ERROR_RUNTIME_FAILURE; \ + } + +#endif |