fix and overhaul dlsym depedency order, always record direct deps
[musl.git] / src / ipc / msgctl.c
blobea9b23377e47dad684ae1e7cc72df2cab81faf4c
1 #include <sys/msg.h>
2 #include <endian.h>
3 #include "syscall.h"
4 #include "ipc.h"
6 #if __BYTE_ORDER != __BIG_ENDIAN
7 #undef SYSCALL_IPC_BROKEN_MODE
8 #endif
10 int msgctl(int q, int cmd, struct msqid_ds *buf)
12 #ifdef SYSCALL_IPC_BROKEN_MODE
13 struct msqid_ds tmp;
14 if (cmd == IPC_SET) {
15 tmp = *buf;
16 tmp.msg_perm.mode *= 0x10000U;
17 buf = &tmp;
19 #endif
20 #ifdef SYS_msgctl
21 int r = __syscall(SYS_msgctl, q, cmd | IPC_64, buf);
22 #else
23 int r = __syscall(SYS_ipc, IPCOP_msgctl, q, cmd | IPC_64, 0, buf, 0);
24 #endif
25 #ifdef SYSCALL_IPC_BROKEN_MODE
26 if (r >= 0) switch (cmd) {
27 case IPC_STAT:
28 case MSG_STAT:
29 case MSG_STAT_ANY:
30 buf->msg_perm.mode >>= 16;
32 #endif
33 return __syscall_ret(r);