From: Markos Chandras <[email protected]> New architectures don't define ARCH_WANT_IPC_PARSE_VERSION in their kernel. This means that every cmd passed to semctl,msgctl and shmctl is IPC_64 by default. We need to prevent uClibc from XOR'ing this flag to the cmd otherwise it will break the syscalls in the kernel.
Signed-off-by: Markos Chandras <[email protected]> --- extra/Configs/Config.in.arch | 9 +++++++++ libc/misc/sysvipc/ipc.h | 8 ++++++++ libc/misc/sysvipc/msgq.c | 3 ++- libc/misc/sysvipc/sem.c | 4 +++- libc/misc/sysvipc/shm.c | 4 +++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch index ec541f4..f985472 100644 --- a/extra/Configs/Config.in.arch +++ b/extra/Configs/Config.in.arch @@ -42,6 +42,15 @@ if ARCH_USE_MMU comment "Using ELF file format" endif +config ARCH_HAS_NO_OLD_IPC + bool "Disable support for the old IPC interface" + default n + help + New architectures do not define the ARCH_WANT_IPC_PARSE_VERSION + in their kernel, which means they have no support for the old IPC + interface. For these architectures, these symbol must be defined + in order to have functional semctl, shmctl and msgctl system calls + config UCLIBC_SHARED_FLAT_ID int "Shared library ID" default 1 diff --git a/libc/misc/sysvipc/ipc.h b/libc/misc/sysvipc/ipc.h index 339d136..9f664f4 100644 --- a/libc/misc/sysvipc/ipc.h +++ b/libc/misc/sysvipc/ipc.h @@ -9,6 +9,14 @@ # define __IPC_64 0x0 #endif +/* New architectures don't have the OLD_IPC interface */ +#ifdef __ARCH_HAS_NO_OLD_IPC__ +#define PROCESS_IPC_CMD(cmd) +#else +#define PROCESS_IPC_CMD(cmd) \ + { int *p = &cmd; *p = (*p) | __IPC_64; } +#endif + #ifdef __NR_ipc /* The actual system call: all functions are multiplexed by this. */ diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c index 185cd26..0523a10 100644 --- a/libc/misc/sysvipc/msgq.c +++ b/libc/misc/sysvipc/msgq.c @@ -18,7 +18,8 @@ static __inline__ _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msq int msgctl(int msqid, int cmd, struct msqid_ds *buf) { #ifdef __NR_msgctl - return __libc_msgctl(msqid, cmd | __IPC_64, buf); + PROCESS_IPC_CMD(cmd) + return __libc_msgctl(msqid, cmd, buf); #else return __syscall_ipc(IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf, 0); #endif diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c index cca4cdf..3efdd75 100644 --- a/libc/misc/sysvipc/sem.c +++ b/libc/misc/sysvipc/sem.c @@ -53,8 +53,10 @@ int semctl(int semid, int semnum, int cmd, ...) va_start (ap, cmd); arg = va_arg (ap, union semun); va_end (ap); + #ifdef __NR_semctl - return __semctl(semid, semnum, cmd | __IPC_64, arg.__pad); + PROCESS_IPC_CMD(cmd) + return __semctl(semid, semnum, cmd, arg.__pad); #else return __syscall_ipc(IPCOP_semctl, semid, semnum, cmd|__IPC_64, &arg, NULL); #endif diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c index 27e871f..05d68f4 100644 --- a/libc/misc/sysvipc/shm.c +++ b/libc/misc/sysvipc/shm.c @@ -59,8 +59,10 @@ static __inline__ _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shm #endif int shmctl(int shmid, int cmd, struct shmid_ds *buf) { + #ifdef __NR_shmctl - return __libc_shmctl(shmid, cmd | __IPC_64, buf); + PROCESS_IPC_CMD(cmd) + return __libc_shmctl(shmid, cmd, buf); #else return __syscall_ipc(IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf, 0); #endif -- 1.7.1 _______________________________________________ uClibc mailing list [email protected] http://lists.busybox.net/mailman/listinfo/uclibc
