mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
ipc: Move non-channel functions to utils [NFC]
This commit is contained in:
parent
5dfdab9e80
commit
850e57a002
|
@ -31,6 +31,7 @@ set(IPC_COMMON_SOURCES
|
|||
${CMAKE_CURRENT_BINARY_DIR}/ipc_protocol_generated.h
|
||||
shared/ipc_shmem.c
|
||||
shared/ipc_shmem.h
|
||||
shared/ipc_utils.c
|
||||
shared/ipc_utils.h
|
||||
)
|
||||
|
||||
|
|
32
src/xrt/ipc/shared/ipc_utils.c
Normal file
32
src/xrt/ipc/shared/ipc_utils.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2022, Magic Leap, Inc.
|
||||
// Copyright 2020-2023, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief IPC util helpers.
|
||||
* @author Julian Petrov <jpetrov@magicleap.com>
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup ipc_shared
|
||||
*/
|
||||
|
||||
#include "ipc_utils.h"
|
||||
|
||||
#ifdef XRT_OS_WINDOWS
|
||||
#include "util/u_windows.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Misc utils 'exported' functions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef XRT_OS_WINDOWS
|
||||
const char *
|
||||
ipc_winerror(DWORD err)
|
||||
{
|
||||
static char s_buf[4096]; // N.B. Not thread-safe. If needed, use a thread var
|
||||
return u_winerror(s_buf, sizeof(s_buf), err, false);
|
||||
}
|
||||
#endif
|
|
@ -22,6 +22,34 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Misc utils.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(XRT_OS_WINDOWS) || defined(XRT_DOXYGEN)
|
||||
/*!
|
||||
* Helper to convert windows error codes to human readable strings for logging.
|
||||
* N.B. This routine is not thread safe.
|
||||
*
|
||||
* @param err windows error code
|
||||
* @return human readable string corresponding to the error code.
|
||||
*
|
||||
* @ingroup ipc_shared
|
||||
*/
|
||||
const char *
|
||||
ipc_winerror(DWORD err);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Channel functions.
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Wrapper for a socket and flags.
|
||||
*/
|
||||
|
@ -155,18 +183,6 @@ xrt_result_t
|
|||
ipc_send_handles(
|
||||
struct ipc_message_channel *imc, const void *data, size_t size, const HANDLE *handles, uint32_t handle_count);
|
||||
|
||||
/*!
|
||||
* Helper to convert windows error codes to human readable strings for logging
|
||||
* N.B. This routine is not thread safe
|
||||
*
|
||||
* @param err windows error code
|
||||
* @return human readable string corresponding to the error code
|
||||
*
|
||||
* @public @memberof ipc_message_channel
|
||||
*/
|
||||
const char *
|
||||
ipc_winerror(DWORD err);
|
||||
|
||||
#endif // XRT_OS_UNIX
|
||||
/*!
|
||||
* @}
|
||||
|
|
|
@ -93,13 +93,6 @@ open_target_process_dup_handle(struct ipc_message_channel *imc)
|
|||
*
|
||||
*/
|
||||
|
||||
const char *
|
||||
ipc_winerror(DWORD err)
|
||||
{
|
||||
static char s_buf[4096]; // N.B. Not thread-safe. If needed, use a thread var
|
||||
return u_winerror(s_buf, sizeof(s_buf), err, false);
|
||||
}
|
||||
|
||||
void
|
||||
ipc_message_channel_close(struct ipc_message_channel *imc)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue