From 8bb82b4e58cb4dedb276151c47a799c1e51af230 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 5 Apr 2011 16:33:55 -0400 Subject: [PATCH] add sysv ipc message queues (completely untested) --- src/ipc/msgctl.c | 12 ++++++++++++ src/ipc/msgget.c | 12 ++++++++++++ src/ipc/msgrcv.c | 17 +++++++++++++++++ src/ipc/msgsnd.c | 17 +++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 src/ipc/msgctl.c create mode 100644 src/ipc/msgget.c create mode 100644 src/ipc/msgrcv.c create mode 100644 src/ipc/msgsnd.c diff --git a/src/ipc/msgctl.c b/src/ipc/msgctl.c new file mode 100644 index 00000000..7c84291c --- /dev/null +++ b/src/ipc/msgctl.c @@ -0,0 +1,12 @@ +#include +#include "syscall.h" +#include "ipc.h" + +int msgctl(int q, int cmd, struct msqid_ds *buf) +{ +#ifdef __NR_msgctl + return syscall(SYS_msgctl, q, cmd, buf); +#else + return syscall(SYS_ipc, IPCOP_msgctl, q, cmd, buf); +#endif +} diff --git a/src/ipc/msgget.c b/src/ipc/msgget.c new file mode 100644 index 00000000..9d79fe76 --- /dev/null +++ b/src/ipc/msgget.c @@ -0,0 +1,12 @@ +#include +#include "syscall.h" +#include "ipc.h" + +int msgget(key_t k, int flag) +{ +#ifdef __NR_msgget + return syscall(SYS_msgget, k, flag); +#else + return syscall(SYS_ipc, IPCOP_msgget, k, flag); +#endif +} diff --git a/src/ipc/msgrcv.c b/src/ipc/msgrcv.c new file mode 100644 index 00000000..ee071766 --- /dev/null +++ b/src/ipc/msgrcv.c @@ -0,0 +1,17 @@ +#include +#include "syscall.h" +#include "ipc.h" +#include "libc.h" + +ssize_t msgrcv(int q, void *m, size_t len, long type, int flag) +{ + ssize_t r; + CANCELPT_BEGIN; +#ifdef __NR_msgrcv + r = syscall(SYS_msgrcv, q, m, len, type, flag); +#else + r = syscall(SYS_ipc, IPCOP_msgrcv, q, len, flag, ((long[]){ (long)m, type })); +#endif + CANCELPT_END; + return r; +} diff --git a/src/ipc/msgsnd.c b/src/ipc/msgsnd.c new file mode 100644 index 00000000..ed05d6b3 --- /dev/null +++ b/src/ipc/msgsnd.c @@ -0,0 +1,17 @@ +#include +#include "syscall.h" +#include "ipc.h" +#include "libc.h" + +ssize_t msgsnd(int q, const void *m, size_t len, int flag) +{ + ssize_t r; + CANCELPT_BEGIN; +#ifdef __NR_msgsnd + r = syscall(SYS_msgsnd, q, m, len, flag); +#else + r = syscall(SYS_ipc, IPCOP_msgsnd, q, len, flag, m); +#endif + CANCELPT_END; + return r; +} -- 2.25.1