lib: add libxpc to implement functionality needed by xpc interfaces

This commit is contained in:
2026-03-10 19:14:37 +00:00
parent b0fda122e0
commit aef0163017
10 changed files with 516 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
#ifndef XPC_MSG_H_
#define XPC_MSG_H_
#include <mango/types.h>
#include <stdbool.h>
#include <stdint.h>
#include <xpc/endpoint.h>
#define XPC_MSG_MAGIC 0x5850434D
typedef struct xpc_msg_header {
uint32_t hdr_magic;
uint32_t hdr_interface;
uint16_t hdr_func;
uint16_t hdr_status;
} xpc_msg_header_t;
typedef struct xpc_msg {
xpc_endpoint_t msg_sender;
xpc_msg_header_t msg_header;
size_t msg_handles_count;
kern_msg_handle_t msg_handles[KERN_MSG_MAX_HANDLES];
} xpc_msg_t;
extern void xpc_msg_header_init(
xpc_msg_header_t *msg,
unsigned long interface,
unsigned short func);
extern bool xpc_msg_header_validate(const xpc_msg_header_t *msg);
extern kern_status_t xpc_msg_recv(kern_handle_t channel, xpc_msg_t *out);
extern kern_status_t xpc_msg_read(
const xpc_msg_t *msg,
size_t offset,
void *p,
size_t count);
extern kern_status_t xpc_msg_write(
const xpc_msg_t *msg,
size_t offset,
const void *p,
size_t count);
extern kern_status_t xpc_msg_reply(
const xpc_msg_t *msg,
kern_iovec_t *iov,
size_t iov_count,
kern_msg_handle_t *handles,
size_t handle_count);
extern kern_status_t xpc_msg_reply_error(
const xpc_msg_t *msg,
unsigned short code);
#endif