Monado OpenXR Runtime
ipc_utils.h
Go to the documentation of this file.
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
u_logging_level
Logging level enum.
Definition: u_logging.h:40
const char * ipc_winerror(DWORD err)
Helper to convert windows error codes to human readable strings for logging.
void ipc_print_result(enum u_logging_level cond_level, const char *file, int line, const char *calling_func, xrt_result_t xret, const char *called_func)
Helper to print the results of called functions that return xret results, if the result is XRT_SUCCES...
Definition: ipc_utils.c:29
enum xrt_result xrt_result_t
Result type used across Monado.
Basic logging functionality.
Various helpers for doing Windows specific things.
Auto detect OS and certain features.
Internal result type for XRT.