• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <sys/shm.h>
2 #include <endian.h>
3 #include "syscall.h"
4 #include "ipc.h"
5 
6 #if __BYTE_ORDER != __BIG_ENDIAN
7 #undef SYSCALL_IPC_BROKEN_MODE
8 #endif
9 
shmctl(int id,int cmd,struct shmid_ds * buf)10 int shmctl(int id, int cmd, struct shmid_ds *buf)
11 {
12 #ifdef SYSCALL_IPC_BROKEN_MODE
13 	struct shmid_ds tmp;
14 	if (cmd == IPC_SET) {
15 		tmp = *buf;
16 		tmp.shm_perm.mode *= 0x10000U;
17 		buf = &tmp;
18 	}
19 #endif
20 #ifndef SYS_ipc
21 	int r = __syscall(SYS_shmctl, id, IPC_CMD(cmd), buf);
22 #else
23 	int r = __syscall(SYS_ipc, IPCOP_shmctl, id, IPC_CMD(cmd), 0, buf, 0);
24 #endif
25 #ifdef SYSCALL_IPC_BROKEN_MODE
26 	if (r >= 0) switch (cmd | IPC_TIME64) {
27 	case IPC_STAT:
28 	case SHM_STAT:
29 	case SHM_STAT_ANY:
30 		buf->shm_perm.mode >>= 16;
31 	}
32 #endif
33 #if IPC_TIME64
34 	if (r >= 0 && (cmd&IPC_TIME64)) {
35 		IPC_HILO(buf, shm_atime);
36 		IPC_HILO(buf, shm_dtime);
37 		IPC_HILO(buf, shm_ctime);
38 	}
39 #endif
40 	return __syscall_ret(r);
41 }
42