create ipc.c
This commit is contained in:
51
src/ipc.c
Normal file
51
src/ipc.c
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# include <sys/ksys.h>
|
||||||
|
|
||||||
|
enum SendIPCErrors
|
||||||
|
{
|
||||||
|
Ok = 0,
|
||||||
|
BufferNotDefined = 1,
|
||||||
|
BufferLocked = 2,
|
||||||
|
BufferOverflow = 3,
|
||||||
|
PidNotExist = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void define_ipc(ksys_ipc_buffer *buffer, size_t bufLen)
|
||||||
|
{
|
||||||
|
asm_inline(
|
||||||
|
"int $0x40"
|
||||||
|
::"a"(60), "b"(1), "c"(buffer), "d"(bufLen)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static enum SendIPCErrors send_ipc(int pid, ksys_ipc_msg *msg, size_t msgLen)
|
||||||
|
{
|
||||||
|
enum SendIPCErrors ret;
|
||||||
|
|
||||||
|
asm_inline(
|
||||||
|
"int $0x40"
|
||||||
|
: "=a"(ret),
|
||||||
|
: "a"(60), "b"(1), "c"(pid), "d"(msg), "S"(msgLen)
|
||||||
|
)
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int syscalls_DefineIPCBuffer(lua_State *L)
|
||||||
|
{
|
||||||
|
define_ipc();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int syscalls_SendIPCMessage(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_pushinteger(
|
||||||
|
L,
|
||||||
|
send_ipc(
|
||||||
|
lua_checkinteger(L, 1);,
|
||||||
|
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
Reference in New Issue
Block a user