OLD | NEW |
1 #include <sys/sem.h> | 1 #include <sys/sem.h> |
2 #include <stdarg.h> | 2 #include <stdarg.h> |
3 #include "syscall.h" | 3 #include "syscall.h" |
4 #include "ipc.h" | 4 #include "ipc.h" |
5 | 5 |
6 union semun { | 6 union semun { |
7 » int val; | 7 int val; |
8 » struct semid_ds *buf; | 8 struct semid_ds* buf; |
9 » unsigned short *array; | 9 unsigned short* array; |
10 }; | 10 }; |
11 | 11 |
12 int semctl(int id, int num, int cmd, ...) | 12 int semctl(int id, int num, int cmd, ...) { |
13 { | 13 union semun arg = {0}; |
14 » union semun arg = {0}; | 14 va_list ap; |
15 » va_list ap; | 15 switch (cmd) { |
16 » switch (cmd) { | 16 case SETVAL: |
17 » case SETVAL: case GETALL: case SETALL: case IPC_STAT: case IPC_SET: | 17 case GETALL: |
18 » case IPC_INFO: case SEM_INFO: case SEM_STAT: | 18 case SETALL: |
19 » » va_start(ap, cmd); | 19 case IPC_STAT: |
20 » » arg = va_arg(ap, union semun); | 20 case IPC_SET: |
21 » » va_end(ap); | 21 case IPC_INFO: |
22 » } | 22 case SEM_INFO: |
| 23 case SEM_STAT: |
| 24 va_start(ap, cmd); |
| 25 arg = va_arg(ap, union semun); |
| 26 va_end(ap); |
| 27 } |
23 #ifdef SYS_semctl | 28 #ifdef SYS_semctl |
24 » return syscall(SYS_semctl, id, num, cmd | IPC_64, arg.buf); | 29 return syscall(SYS_semctl, id, num, cmd | IPC_64, arg.buf); |
25 #else | 30 #else |
26 » return syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg.buf); | 31 return syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg.buf); |
27 #endif | 32 #endif |
28 } | 33 } |
OLD | NEW |