[RFC] sysvipc: Fix handling of direct syscalls
Commit Message
Working on the OpenRISC port I get an error that __NR_ipc is not
defined using the default kernel-features.h with kernel 5.7.
It seems this would also impact riscv and csky that also do not
do any special SYSVIPC defines or use __NR_ipc.
Compiler output:
In file included from ../sysdeps/unix/sysv/linux/msgctl.c:21:
../sysdeps/unix/sysv/linux/msgctl.c: In function '__old_msgctl':
../sysdeps/unix/sysv/linux/or1k/sysdep.h:23:34: error: '__NR_ipc' undeclared (first use in this function)
23 | #define SYS_ify(syscall_name) (__NR_##syscall_name)
| ^~~~~
../sysdeps/unix/sysv/linux/or1k/sysdep.h:103:35: note: in definition of macro 'INTERNAL_SYSCALL_NCS'
103 | long _sc_ret = (long) number; \
| ^~~~~~
../sysdeps/unix/sysv/linux/or1k/sysdep.h:96:24: note: in expansion of macro 'SYS_ify'
96 | INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
| ^~~~~~~
../sysdeps/unix/sysv/linux/sysdep.h:43:23: note: in expansion of macro 'INTERNAL_SYSCALL'
43 | long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:71:3: note: in expansion of macro 'INLINE_SYSCALL'
71 | INLINE_SYSCALL (name, 5, a1, a2, a3, a4, a5)
| ^~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:27:37: note: in expansion of macro '__INLINE_SYSCALL5'
27 | #define __SYSCALL_CONCAT_X(a,b) a##b
| ^
../sysdeps/unix/sysdep.h:28:37: note: in expansion of macro '__SYSCALL_CONCAT_X'
28 | #define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b)
| ^~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:81:3: note: in expansion of macro '__SYSCALL_CONCAT'
81 | __SYSCALL_CONCAT (b,__INLINE_SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
| ^~~~~~~~~~~~~~~~
../sysdeps/unix/sysdep.h:89:3: note: in expansion of macro '__INLINE_SYSCALL_DISP'
89 | __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/msgctl.c:127:10: note: in expansion of macro 'INLINE_SYSCALL_CALL'
127 | return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
---
sysdeps/unix/sysv/linux/msgctl.c | 8 ++------
sysdeps/unix/sysv/linux/semctl.c | 9 +++------
sysdeps/unix/sysv/linux/shmctl.c | 8 ++------
3 files changed, 7 insertions(+), 18 deletions(-)
Comments
On Mai 02 2020, Stafford Horne via Libc-alpha wrote:
> ../sysdeps/unix/sysv/linux/msgctl.c:127:10: note: in expansion of macro 'INLINE_SYSCALL_CALL'
> 127 | return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
This is pre-2.2 compat code. Why does the compiler even get that far?
Andreas.
On Sat, May 02, 2020 at 08:55:35AM +0200, Andreas Schwab wrote:
> On Mai 02 2020, Stafford Horne via Libc-alpha wrote:
>
> > ../sysdeps/unix/sysv/linux/msgctl.c:127:10: note: in expansion of macro 'INLINE_SYSCALL_CALL'
> > 127 | return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
>
> This is pre-2.2 compat code. Why does the compiler even get that far?
Thanks for your comment,
For some reason I didn't notice this was all wrapped by SHLIB_COMPAT, your
comment helped me to double check.
I'll figure out why it's still trying to compile the compat API's, this patch
should not be needed.
-Stafford
@@ -117,12 +117,8 @@ int
attribute_compat_text_section
__old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
{
-#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS \
- && !defined __ASSUME_SYSVIPC_DEFAULT_IPC_64
- /* For architecture that have wire-up msgctl but also have __IPC_64 to a
- value different than default (0x0) it means the compat symbol used the
- __NR_ipc syscall. */
- return INLINE_SYSCALL_CALL (msgctl, msqid, cmd, buf);
+#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+ return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf);
#else
return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
#endif
@@ -174,12 +174,9 @@ __old_semctl (int semid, int semnum, int cmd, ...)
break;
}
-#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS \
- && !defined __ASSUME_SYSVIPC_DEFAULT_IPC_64
- /* For architectures that have wire-up semctl but also have __IPC_64 to a
- value different than default (0x0) it means the compat symbol used the
- __NR_ipc syscall. */
- return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd, arg.array);
+#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+ return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64,
+ arg.array);
# else
return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd,
SEMCTL_ARG_ADDRESS (arg));
@@ -117,12 +117,8 @@ int
attribute_compat_text_section
__old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
{
-#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS \
- && !defined __ASSUME_SYSVIPC_DEFAULT_IPC_64
- /* For architecture that have wire-up shmctl but also have __IPC_64 to a
- value different than default (0x0), it means the compat symbol used the
- __NR_ipc syscall. */
- return INLINE_SYSCALL_CALL (shmctl, shmid, cmd, buf);
+#if defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+ return INLINE_SYSCALL_CALL (shmctl, shmid, cmd | __IPC_64, buf);
#else
return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd, 0, buf);
#endif