fix broken semctl on systems that don't use IPC_64 flag
[musl] / src / ipc / semctl.c
index 392a4aa..9de5b1d 100644 (file)
@@ -3,6 +3,10 @@
 #include "syscall.h"
 #include "ipc.h"
 
+#ifndef IPC_64
+#define IPC_64 0
+#endif
+
 int semctl(int id, int num, int cmd, ...)
 {
        long arg;
@@ -10,9 +14,9 @@ int semctl(int id, int num, int cmd, ...)
        va_start(ap, cmd);
        arg = va_arg(ap, long);
        va_end(ap);
-#ifdef __NR_semctl
-       return syscall(SYS_semctl, id, num, cmd, arg);
+#ifdef SYS_semctl
+       return syscall(SYS_semctl, id, num, cmd | IPC_64, arg);
 #else
-       return syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | 0x100, &arg);
+       return syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg);
 #endif
 }