BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / blob / 2e2f919ac415da5f75aeb6b83981b659fa5072eb / sys / ipc.c

// Related

OrionLibC

Barry Importing existing Orion LibC 03048a9 (2 years, 2 months ago)
#include <stdint.h>
#include <sys/ipc.h>
#include <sys/syscall.h>

/* Send a message without blocking */
Message *
nb_send_msg(pid_t to, uint16_t type, MessageContent *msg)
{
	int ret;
	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_NB_SEND_MSG),
	             "c" (3), "S" (&to));
	return (Message *) ret;
}

/* Send a message and block until delivery */
Message *
send_msg(pid_t to, uint16_t type, MessageContent *msg)
{
	int ret;
	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_SEND_MSG),
	             "c" (3), "S" (&to));
	return (Message *) ret;
}

/* Receive a message if available */
pid_t
nb_recv_msg(Message *buf, pid_t from)
{
	int ret;
	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_NB_RECV_MSG),
	             "c" (2), "S" (&buf));
	return (pid_t) ret;
}

/* Block until a message is received */
pid_t
recv_msg(Message *buf, pid_t from)
{
	int ret;
	asm volatile("int $0x80" : "=a" (ret) : "0" (SYSCALL_RECV_MSG),
	             "c" (2), "S" (&buf));
	return (pid_t) ret;
}