The open source OpenXR runtime
at main 74 lines 1.7 kB view raw
1// Copyright 2020-2023, Collabora, Ltd. 2// Copyright 2022, Magic Leap, Inc. 3// SPDX-License-Identifier: BSL-1.0 4/*! 5 * @file 6 * @brief IPC util helpers, for internal use only 7 * @author Julian Petrov <jpetrov@magicleap.com> 8 * @author Jakob Bornecrantz <jakob@collabora.com> 9 * @ingroup ipc_shared 10 */ 11 12#pragma once 13 14#include "xrt/xrt_config_os.h" 15#include "xrt/xrt_results.h" 16 17#include "util/u_logging.h" 18 19#ifdef XRT_OS_WINDOWS 20#include "util/u_windows.h" 21#endif 22 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28 29/* 30 * 31 * Misc utils. 32 * 33 */ 34 35/*! 36 * Helper to print the results of called functions that return xret results, if 37 * the result is @p XRT_SUCCESS will log with info, otherwise error. Will also 38 * check if logging should be done with @p cond_level. 39 * 40 * @param cond_level What the current logging level is. 41 * @param file Callee site (__FILE__). 42 * @param line Callee site (__LINE__). 43 * @param calling_fn Callee site (__func__). 44 * @param xret Result from the called function. 45 * @param called_fn Which function that this return is from. 46 * 47 * @ingroup ipc_shared 48 */ 49void 50ipc_print_result(enum u_logging_level cond_level, 51 const char *file, 52 int line, 53 const char *calling_func, 54 xrt_result_t xret, 55 const char *called_func); 56 57#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN) 58/*! 59 * Helper to convert windows error codes to human readable strings for logging. 60 * N.B. This routine is not thread safe. 61 * 62 * @param err windows error code 63 * @return human readable string corresponding to the error code. 64 * 65 * @ingroup ipc_shared 66 */ 67const char * 68ipc_winerror(DWORD err); 69#endif 70 71 72#ifdef __cplusplus 73} 74#endif