The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Use U_LOG_CHK_ helpers instead of our own

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2483>

+17 -136
+5 -102
src/xrt/ipc/client/ipc_client.h
··· 36 36 #define IPC_WARN(IPC_C, ...) U_LOG_IFL_W((IPC_C)->imc.log_level, __VA_ARGS__) 37 37 #define IPC_ERROR(IPC_C, ...) U_LOG_IFL_E((IPC_C)->imc.log_level, __VA_ARGS__) 38 38 39 - /*! 40 - * This define will error if `XRET` is not `XRT_SUCCESS`, printing out that the 41 - * @p FUNC_STR string has failed, then returns @p XRET. The argument @p IPC_C 42 - * will be used to look up the @p cond_level for the @ref ipc_print_result call. 43 - * 44 - * @param IPC_C Client connection, used to look up @p cond_level. 45 - * @param XRET The @p xrt_result_t to check. 46 - * @param FUNC_STR String literal with the function name, used for logging. 47 - * 48 - * @ingroup ipc_client 49 - */ 50 - #define IPC_CHK_AND_RET(IPC_C, XRET, FUNC_STR) \ 51 - do { \ 52 - xrt_result_t _ret = XRET; \ 53 - if (_ret != XRT_SUCCESS) { \ 54 - ipc_print_result((IPC_C)->imc.log_level, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \ 55 - return _ret; \ 56 - } \ 57 - } while (false) 58 - 59 - /*! 60 - * This define will error if `XRET` is not `XRT_SUCCESS`, printing out that the 61 - * @p FUNC_STR string has failed, then gotos @p GOTO. The argument @p IPC_C 62 - * will be used to look up the @p cond_level for the @ref ipc_print_result call. 63 - * 64 - * @param IPC_C Client connection, used to look up @p cond_level. 65 - * @param XRET The @p xrt_result_t to check. 66 - * @param FUNC_STR String literal with the function name, used for logging. 67 - * @param GOTO Goto label to jump to on error. 68 - * 69 - * @ingroup ipc_client 70 - */ 71 - #define IPC_CHK_WITH_GOTO(IPC_C, XRET, FUNC_STR, GOTO) \ 72 - do { \ 73 - xrt_result_t _ret = XRET; \ 74 - if (_ret != XRT_SUCCESS) { \ 75 - ipc_print_result((IPC_C)->imc.log_level, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \ 76 - goto GOTO; \ 77 - } \ 78 - } while (false) 79 - 80 - /*! 81 - * This define will error if `XRET` is not `XRT_SUCCESS`, printing out that the 82 - * @p FUNC_STR string has failed, then returns @p RET. The argument @p IPC_C 83 - * will be used to look up the @p cond_level for the @ref ipc_print_result call. 84 - * 85 - * @param IPC_C Client connection, used to look up @p cond_level. 86 - * @param XRET The @p xrt_result_t to check. 87 - * @param FUNC_STR String literal with the function name, used for logging. 88 - * @param RET The value that is returned on error. 89 - * 90 - * @ingroup ipc_client 91 - */ 92 - #define IPC_CHK_WITH_RET(IPC_C, XRET, FUNC_STR, RET) \ 93 - do { \ 94 - xrt_result_t _ret = XRET; \ 95 - if (_ret != XRT_SUCCESS) { \ 96 - ipc_print_result((IPC_C)->imc.log_level, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \ 97 - return RET; \ 98 - } \ 99 - } while (false) 100 - 101 - /*! 102 - * This define will error if `XRET` is not `XRT_SUCCESS`, printing out that the 103 - * @p FUNC_STR string has failed, it only prints and does nothing else. The 104 - * argument @p IPC_C will be used to look up the @p cond_level for the 105 - * @ref ipc_print_result call. 106 - * 107 - * @param IPC_C Client connection, used to look up @p cond_level. 108 - * @param XRET The @p xrt_result_t to check. 109 - * @param FUNC_STR String literal with the function name, used for logging. 110 - * 111 - * @ingroup ipc_client 112 - */ 113 - #define IPC_CHK_ONLY_PRINT(IPC_C, XRET, FUNC_STR) \ 114 - do { \ 115 - xrt_result_t _ret = XRET; \ 116 - if (_ret != XRT_SUCCESS) { \ 117 - ipc_print_result((IPC_C)->imc.log_level, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \ 118 - } \ 119 - } while (false) 120 - 121 - /*! 122 - * This define will error if `XRET` is not `XRT_SUCCESS`, printing out that the 123 - * @p FUNC_STR string has failed, then it will always return the value. The 124 - * argument @p IPC_C will be used to look up the @p cond_level for the 125 - * @ref ipc_print_result call. 126 - * 127 - * @param IPC_C Client connection, used to look up @p cond_level. 128 - * @param XRET The @p xrt_result_t to check and always return. 129 - * @param FUNC_STR String literal with the function name, used for logging. 130 - * 131 - * @ingroup ipc_client 132 - */ 133 - #define IPC_CHK_ALWAYS_RET(IPC_C, XRET, FUNC_STR) \ 134 - do { \ 135 - xrt_result_t _ret = XRET; \ 136 - if (_ret != XRT_SUCCESS) { \ 137 - ipc_print_result((IPC_C)->imc.log_level, __FILE__, __LINE__, __func__, _ret, FUNC_STR); \ 138 - } \ 139 - return _ret; \ 140 - } while (false) 39 + #define IPC_CHK_AND_RET(IPC_C, ...) U_LOG_CHK_AND_RET((IPC_C)->imc.log_level, __VA_ARGS__) 40 + #define IPC_CHK_WITH_GOTO(IPC_C, ...) U_LOG_CHK_WITH_GOTO((IPC_C)->imc.log_level, __VA_ARGS__) 41 + #define IPC_CHK_WITH_RET(IPC_C, ...) U_LOG_CHK_WITH_RET((IPC_C)->imc.log_level, __VA_ARGS__) 42 + #define IPC_CHK_ONLY_PRINT(IPC_C, ...) U_LOG_CHK_ONLY_PRINT((IPC_C)->imc.log_level, __VA_ARGS__) 43 + #define IPC_CHK_ALWAYS_RET(IPC_C, ...) U_LOG_CHK_ALWAYS_RET((IPC_C)->imc.log_level, __VA_ARGS__) 141 44 142 45 143 46 /*
+6
src/xrt/ipc/server/ipc_server.h
··· 42 42 #define IPC_WARN(d, ...) U_LOG_IFL_W(d->log_level, __VA_ARGS__) 43 43 #define IPC_ERROR(d, ...) U_LOG_IFL_E(d->log_level, __VA_ARGS__) 44 44 45 + #define IPC_CHK_AND_RET(S, ...) U_LOG_CHK_AND_RET((S)->log_level, __VA_ARGS__) 46 + #define IPC_CHK_WITH_GOTO(S, ...) U_LOG_CHK_WITH_GOTO((S)->log_level, __VA_ARGS__) 47 + #define IPC_CHK_WITH_RET(S, ...) U_LOG_CHK_WITH_RET((S)->log_level, __VA_ARGS__) 48 + #define IPC_CHK_ONLY_PRINT(S, ...) U_LOG_CHK_ONLY_PRINT((S)->log_level, __VA_ARGS__) 49 + #define IPC_CHK_ALWAYS_RET(S, ...) U_LOG_CHK_ALWAYS_RET((S)->log_level, __VA_ARGS__) 50 + 45 51 46 52 /* 47 53 *
+6 -34
src/xrt/ipc/shared/ipc_utils.c
··· 11 11 12 12 #include "ipc_utils.h" 13 13 14 - #include "util/u_logging.h" 15 - #include "util/u_pretty_print.h" 16 - 17 14 #ifdef XRT_OS_WINDOWS 18 15 #include "util/u_windows.h" 19 16 #endif ··· 25 22 * 26 23 */ 27 24 28 - void 29 - ipc_print_result(enum u_logging_level cond_level, 30 - const char *file, 31 - int line, 32 - const char *calling_fn, 33 - xrt_result_t xret, 34 - const char *called_fn) 35 - { 36 - bool success = xret == XRT_SUCCESS; 37 - enum u_logging_level level = success ? U_LOGGING_INFO : U_LOGGING_ERROR; 38 - 39 - // Should we be logging? 40 - if (level < cond_level) { 41 - return; 42 - } 43 - 44 - struct u_pp_sink_stack_only sink; 45 - u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); 46 - 47 - if (success) { 48 - u_pp(dg, "%s: ", called_fn); 49 - } else { 50 - u_pp(dg, "%s failed: ", called_fn); 51 - } 52 - 53 - u_pp_xrt_result(dg, xret); 54 - u_pp(dg, " [%s:%i]", file, line); 55 - 56 - u_log(file, line, calling_fn, level, "%s", sink.buffer); 57 - } 58 - 59 25 #ifdef XRT_OS_WINDOWS 60 26 const char * 61 27 ipc_winerror(DWORD err) 62 28 { 63 29 static char s_buf[4096]; // N.B. Not thread-safe. If needed, use a thread var 64 30 return u_winerror(s_buf, sizeof(s_buf), err, false); 31 + } 32 + #else 33 + void 34 + _a_function_to_not_create_an_empty_compile_unit(void) 35 + { 36 + // To avoid warnings. 65 37 } 66 38 #endif