* [PATCH 0/6] linux: Some syscall refactors
@ 2021-11-22 18:54 Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 1/6] linux: Add fanotify_mark C implementation Adhemerval Zanella via Libc-alpha
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
The autogeneration syscall list has some limitations:
* 64-bit arguments might require to override with the specific
kernel ABI (for instance if the ABI required even-off register
number).
* LFS might also incur arch-specific override.
* Variadic call is also another source of potential issues,
since some architectures might use a different call mechanism
(for instance passing argument on the stack instead of registers)
and the argument might impose some non obvious issues (for
instance if 64-bit argument are used).
Besides this issue, this patchset also refactors pipe (to remove the
usage of arch-specific kernel ABIS), and provide C generic
implementations for syscall and ioctl.
Adhemerval Zanella (6):
linux: Add fanotify_mark C implementation
linux: Add prlimit64 C implementation
linux: Implement mremap in C
linux: Implement pipe in terms of __NR_pipe2
linux: Add generic syscall implementation
linux: Add generic ioctl implementation
sysdeps/unix/sysdep.h | 20 ++++++
sysdeps/unix/sysv/linux/Makefile | 6 +-
sysdeps/unix/sysv/linux/alpha/pipe.S | 1 -
sysdeps/unix/sysv/linux/arm/syscalls.list | 4 --
.../{sparc/sparc32/pipe.S => fanotify_mark.c} | 38 +++++------
.../linux/generic/wordsize-32/syscalls.list | 5 --
sysdeps/unix/sysv/linux/hppa/fanotify_mark.c | 2 +
sysdeps/unix/sysv/linux/hppa/prlimit64.c | 2 +
sysdeps/unix/sysv/linux/hppa/syscall.c | 65 ------------------
sysdeps/unix/sysv/linux/hppa/syscalls.list | 2 -
sysdeps/unix/sysv/linux/i386/syscalls.list | 4 --
sysdeps/unix/sysv/linux/ia64/pipe.S | 36 ----------
.../pipe.S => sysv/linux/internal-ioctl.h} | 23 +++----
sysdeps/unix/sysv/linux/ioctl.c | 49 +++++++++++++
sysdeps/unix/sysv/linux/m68k/syscalls.list | 2 -
.../unix/sysv/linux/microblaze/syscalls.list | 2 -
.../unix/sysv/linux/mips/mips32/syscalls.list | 5 --
.../sysv/linux/mips/mips64/n32/syscalls.list | 4 --
.../sysv/linux/mips/mips64/n64/syscalls.list | 4 --
sysdeps/unix/sysv/linux/mips/pipe.S | 1 -
.../linux/{sparc/sparc64/pipe.S => mremap.c} | 40 +++++------
sysdeps/unix/sysv/linux/{generic => }/pipe.c | 5 +-
.../linux/powerpc/internal-ioctl.h} | 39 +++++++----
sysdeps/unix/sysv/linux/powerpc/ioctl.c | 68 -------------------
.../linux/powerpc/powerpc32/syscalls.list | 3 -
sysdeps/unix/sysv/linux/prlimit.c | 2 +
.../sysv/linux/{sh/pipe.S => prlimit64.c} | 45 ++++++------
sysdeps/unix/sysv/linux/riscv/syscall.c | 4 +-
.../sysv/linux/s390/s390-32/syscalls.list | 2 -
sysdeps/unix/sysv/linux/sh/fanotify_mark.c | 2 +
sysdeps/unix/sysv/linux/sh/syscalls.list | 4 --
.../sysv/linux/sparc/sparc32/syscalls.list | 3 -
sysdeps/unix/sysv/linux/syscall.c | 43 ++++++++++++
sysdeps/unix/sysv/linux/syscalls.list | 2 -
.../unix/sysv/linux/wordsize-64/syscalls.list | 3 -
35 files changed, 225 insertions(+), 315 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/alpha/pipe.S
rename sysdeps/unix/sysv/linux/{sparc/sparc32/pipe.S => fanotify_mark.c} (56%)
delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
create mode 100644 sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
create mode 100644 sysdeps/unix/sysv/linux/hppa/prlimit64.c
delete mode 100644 sysdeps/unix/sysv/linux/hppa/syscall.c
delete mode 100644 sysdeps/unix/sysv/linux/ia64/pipe.S
rename sysdeps/unix/{alpha/pipe.S => sysv/linux/internal-ioctl.h} (69%)
create mode 100644 sysdeps/unix/sysv/linux/ioctl.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
delete mode 100644 sysdeps/unix/sysv/linux/mips/pipe.S
rename sysdeps/unix/sysv/linux/{sparc/sparc64/pipe.S => mremap.c} (56%)
rename sysdeps/unix/sysv/linux/{generic => }/pipe.c (87%)
rename sysdeps/unix/{mips/pipe.S => sysv/linux/powerpc/internal-ioctl.h} (53%)
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/ioctl.c
rename sysdeps/unix/sysv/linux/{sh/pipe.S => prlimit64.c} (53%)
create mode 100644 sysdeps/unix/sysv/linux/sh/fanotify_mark.c
create mode 100644 sysdeps/unix/sysv/linux/syscall.c
--
2.32.0
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/6] linux: Add fanotify_mark C implementation
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
@ 2021-11-22 18:54 ` Adhemerval Zanella via Libc-alpha
2021-11-24 21:45 ` Stafford Horne via Libc-alpha
2021-11-22 18:54 ` [PATCH 2/6] linux: Add prlimit64 " Adhemerval Zanella via Libc-alpha
` (4 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
Passing 64-bit arguments on syscalls.list is tricky: it requires
to reimplement the expected kernel abi in each architecture. This
is way to better to represent in C code where we already have
macros for this (SYSCALL_LL64).
Checked on x86_64-linux-gnu.
---
sysdeps/unix/sysv/linux/Makefile | 3 +-
sysdeps/unix/sysv/linux/arm/syscalls.list | 2 --
sysdeps/unix/sysv/linux/fanotify_mark.c | 36 +++++++++++++++++++
.../linux/generic/wordsize-32/syscalls.list | 1 -
sysdeps/unix/sysv/linux/hppa/fanotify_mark.c | 2 ++
sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 -
sysdeps/unix/sysv/linux/i386/syscalls.list | 2 --
sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 -
.../unix/sysv/linux/microblaze/syscalls.list | 1 -
.../unix/sysv/linux/mips/mips32/syscalls.list | 2 --
.../sysv/linux/mips/mips64/n32/syscalls.list | 2 --
.../sysv/linux/mips/mips64/n64/syscalls.list | 2 --
.../linux/powerpc/powerpc32/syscalls.list | 1 -
.../sysv/linux/s390/s390-32/syscalls.list | 1 -
sysdeps/unix/sysv/linux/sh/fanotify_mark.c | 2 ++
sysdeps/unix/sysv/linux/sh/syscalls.list | 2 --
.../sysv/linux/sparc/sparc32/syscalls.list | 1 -
.../unix/sysv/linux/wordsize-64/syscalls.list | 2 --
18 files changed, 42 insertions(+), 22 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/fanotify_mark.c
create mode 100644 sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
create mode 100644 sysdeps/unix/sysv/linux/sh/fanotify_mark.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 76ad06361c..c5b4f249cc 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -66,7 +66,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
fxstatat fxstatat64 \
xmknod xmknodat convert_scm_timestamps \
closefrom_fallback \
- clone3 clone-internal
+ clone3 clone-internal \
+ fanotify_mark \
CFLAGS-gethostid.c = -fexceptions
CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index 10c3ae9dae..fa26876f90 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -17,8 +17,6 @@ setfsuid - setfsuid32 Ei:i setfsuid
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
-
personality EXTRA personality Ei:i __personality personality
# proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/fanotify_mark.c b/sysdeps/unix/sysv/linux/fanotify_mark.c
new file mode 100644
index 0000000000..6f8fd2e9cf
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/fanotify_mark.c
@@ -0,0 +1,36 @@
+/* Add, remove, or modify an fanotify mark on a filesystem object.
+ Linux specific syscall.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sys/fanotify.h>
+#include <sysdep.h>
+
+int
+__fanotify_mark (int fd, unsigned int flags, uint64_t mask, int dirfd,
+ const char *pathname)
+{
+ return INLINE_SYSCALL_CALL (fanotify_mark, fd, flags, SYSCALL_LL64 (mask),
+ dirfd, pathname);
+}
+#ifdef VERSION_fanotify_mark
+# include <shlib-compat.h>
+versioned_symbol (libc, __fanotify_mark, fanotify_mark,
+ VERSION_fanotify_mark);
+#else
+weak_alias (__fanotify_mark, fanotify_mark)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
index b775008a37..736edbe654 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
@@ -2,4 +2,3 @@
# rlimit APIs
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
new file mode 100644
index 0000000000..ce347a4261
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
@@ -0,0 +1,2 @@
+#define VERSION_fanotify_mark GLIBC_2_19
+#include <sysdeps/unix/sysv/linux/fanotify_mark.c>
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index 043d884bf9..cc5305a585 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -10,5 +10,4 @@ socket - socket i:iii __socket socket
socketpair - socketpair i:iiif __socketpair socketpair
prlimit64 EXTRA prlimit64 i:iipp __prlimit64 prlimit64@@GLIBC_2.17
-fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.19
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
index 58020dfae5..d3eaabe61b 100644
--- a/sysdeps/unix/sysv/linux/i386/syscalls.list
+++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
@@ -21,6 +21,4 @@ vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
-
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list
index 55a377b841..44c84bf626 100644
--- a/sysdeps/unix/sysv/linux/m68k/syscalls.list
+++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list
@@ -17,5 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid
cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index 932c9cccc8..0abdc38bf3 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -3,5 +3,4 @@
cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
index f357b5c918..dbeb184d73 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
@@ -1,5 +1,3 @@
# File name Caller Syscall name # args Strong name Weak names
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
index 9e6a584685..848028f125 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
@@ -6,6 +6,4 @@ lseek64 - lseek i:iii __lseek64 __libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
-
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index e4e16dfa49..84f348c8e5 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -2,6 +2,4 @@
prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
-
sendfile - sendfile i:iipi sendfile sendfile64
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
index 966856e64a..d31303250d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
@@ -4,4 +4,3 @@ chown - chown i:sii __chown chown@@GLIBC_2.1
lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
index 300b13dd01..8e9b7c4b71 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
@@ -16,5 +16,4 @@ setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/sh/fanotify_mark.c b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c
new file mode 100644
index 0000000000..3662f21b60
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c
@@ -0,0 +1,2 @@
+#define VERSION_fanotify_mark GLIBC_2_16
+#include <sysdeps/unix/sysv/linux/fanotify_mark.c>
diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
index 32badd1ee0..6ff3e8eb8a 100644
--- a/sysdeps/unix/sysv/linux/sh/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sh/syscalls.list
@@ -17,6 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.16
-
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
index 0b6095ffab..4fcae65451 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
@@ -16,4 +16,3 @@ setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
prlimit64 EXTRA prlimit64 i:iipp prlimit64
-fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 68e3c60536..8d97a32344 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -2,6 +2,4 @@
sendfile - sendfile i:iipi sendfile sendfile64
prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
-
-fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
personality EXTRA personality i:i __personality personality
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/6] linux: Add prlimit64 C implementation
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 1/6] linux: Add fanotify_mark C implementation Adhemerval Zanella via Libc-alpha
@ 2021-11-22 18:54 ` Adhemerval Zanella via Libc-alpha
2021-11-25 23:39 ` Stafford Horne via Libc-alpha
2021-11-22 18:54 ` [PATCH 3/6] linux: Implement mremap in C Adhemerval Zanella via Libc-alpha
` (3 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
The LFS prlimit64 requires a arch-specific implementation in
syscalls.list. Instead add a generic one that handles the
required symbol alias for __RLIM_T_MATCHES_RLIM64_T.
HPPA is the only outlier which requires a different default
symbol.
Checked on x86_64-linux-gnu and with build for the affected ABIs.
---
sysdeps/unix/sysv/linux/Makefile | 2 +-
sysdeps/unix/sysv/linux/arm/syscalls.list | 2 -
.../linux/generic/wordsize-32/syscalls.list | 4 --
sysdeps/unix/sysv/linux/hppa/prlimit64.c | 2 +
sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 -
sysdeps/unix/sysv/linux/i386/syscalls.list | 2 -
sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 -
.../unix/sysv/linux/microblaze/syscalls.list | 1 -
.../unix/sysv/linux/mips/mips32/syscalls.list | 3 --
.../sysv/linux/mips/mips64/n32/syscalls.list | 2 -
.../sysv/linux/mips/mips64/n64/syscalls.list | 2 -
.../linux/powerpc/powerpc32/syscalls.list | 2 -
sysdeps/unix/sysv/linux/prlimit.c | 2 +
sysdeps/unix/sysv/linux/prlimit64.c | 39 +++++++++++++++++++
.../sysv/linux/s390/s390-32/syscalls.list | 1 -
sysdeps/unix/sysv/linux/sh/syscalls.list | 2 -
.../sysv/linux/sparc/sparc32/syscalls.list | 2 -
.../unix/sysv/linux/wordsize-64/syscalls.list | 1 -
18 files changed, 44 insertions(+), 27 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
create mode 100644 sysdeps/unix/sysv/linux/hppa/prlimit64.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
create mode 100644 sysdeps/unix/sysv/linux/prlimit64.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index c5b4f249cc..aa10754b98 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -56,7 +56,7 @@ endif
ifeq ($(subdir),misc)
sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
setfsuid setfsgid epoll_pwait signalfd \
- eventfd eventfd_read eventfd_write prlimit \
+ eventfd eventfd_read eventfd_write prlimit prlimit64 \
personality epoll_wait tee vmsplice splice \
open_by_handle_at mlock2 pkey_mprotect pkey_set pkey_get \
timerfd_gettime timerfd_settime prctl \
diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
index fa26876f90..55fb065893 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
@@ -15,8 +15,6 @@ getgroups - getgroups32 i:ip __getgroups getgroups
setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
-
personality EXTRA personality Ei:i __personality personality
# proper socket implementations:
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
deleted file mode 100644
index 736edbe654..0000000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
+++ /dev/null
@@ -1,4 +0,0 @@
-# File name Caller Syscall name # args Strong name Weak names
-
-# rlimit APIs
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
diff --git a/sysdeps/unix/sysv/linux/hppa/prlimit64.c b/sysdeps/unix/sysv/linux/hppa/prlimit64.c
new file mode 100644
index 0000000000..4554c81dd9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/hppa/prlimit64.c
@@ -0,0 +1,2 @@
+#define VERSION_prlimit64 GLIBC_2_17
+#include <sysdeps/unix/sysv/linux/prlimit64.c>
diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
index cc5305a585..12e4adeccc 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
@@ -9,5 +9,4 @@ shutdown - shutdown i:ii __shutdown shutdown
socket - socket i:iii __socket socket
socketpair - socketpair i:iiif __socketpair socketpair
-prlimit64 EXTRA prlimit64 i:iipp __prlimit64 prlimit64@@GLIBC_2.17
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
index d3eaabe61b..c0ec1af8f3 100644
--- a/sysdeps/unix/sysv/linux/i386/syscalls.list
+++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
@@ -19,6 +19,4 @@ modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt
vm86old EXTRA vm86old i:p __vm86old vm86@GLIBC_2.0
vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
-
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list
index 44c84bf626..0fc117886c 100644
--- a/sysdeps/unix/sysv/linux/m68k/syscalls.list
+++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list
@@ -16,5 +16,4 @@ setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index 0abdc38bf3..878ce7e6a2 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -2,5 +2,4 @@
cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
deleted file mode 100644
index dbeb184d73..0000000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
+++ /dev/null
@@ -1,3 +0,0 @@
-# File name Caller Syscall name # args Strong name Weak names
-
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
index 848028f125..c737eeadc5 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
@@ -4,6 +4,4 @@
# return value.
lseek64 - lseek i:iii __lseek64 __libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC_2.0:GLIBC_2.28
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
-
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index 84f348c8e5..0924f245d4 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -1,5 +1,3 @@
# File name Caller Syscall name # args Strong name Weak names
-prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
-
sendfile - sendfile i:iipi sendfile sendfile64
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
index d31303250d..5231da94b2 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
@@ -2,5 +2,3 @@
chown - chown i:sii __chown chown@@GLIBC_2.1
lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0
-
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c
index c12de52693..f9d9911a04 100644
--- a/sysdeps/unix/sysv/linux/prlimit.c
+++ b/sysdeps/unix/sysv/linux/prlimit.c
@@ -18,6 +18,7 @@
#include <sys/resource.h>
#include <sysdep.h>
+#if !__RLIM_T_MATCHES_RLIM64_T
int
prlimit (__pid_t pid, enum __rlimit_resource resource,
const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
@@ -73,3 +74,4 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
return res;
}
+#endif /* __RLIM_T_MATCHES_RLIM64_T */
diff --git a/sysdeps/unix/sysv/linux/prlimit64.c b/sysdeps/unix/sysv/linux/prlimit64.c
new file mode 100644
index 0000000000..e3a8718b98
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/prlimit64.c
@@ -0,0 +1,39 @@
+/* Get/set resource limits. Linux specific syscall.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#define prlimit __redirect_prlimit
+#include <sys/resource.h>
+#undef prlimit
+#include <sysdep.h>
+
+int
+__prlimit64 (pid_t pid, enum __rlimit_resource resource,
+ const struct rlimit64 *new_rlimit, struct rlimit64 *old_rlimit)
+{
+ return INLINE_SYSCALL_CALL (prlimit64, pid, resource, new_rlimit,
+ old_rlimit);
+}
+#ifdef VERSION_prlimit64
+# include <shlib-compat.h>
+versioned_symbol (libc, __prlimit64, prlimit64, VERSION_prlimit64);
+#else
+strong_alias (__prlimit64, prlimit64)
+# if __RLIM_T_MATCHES_RLIM64_T
+strong_alias (prlimit64, prlimit)
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
index 8e9b7c4b71..91d78d91ef 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
@@ -15,5 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups
setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
index 6ff3e8eb8a..78b2348c05 100644
--- a/sysdeps/unix/sysv/linux/sh/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sh/syscalls.list
@@ -15,6 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups
setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
-
personality EXTRA personality Ei:i __personality personality
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
index 4fcae65451..9e4eb0a165 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
@@ -14,5 +14,3 @@ getgroups - getgroups32 i:ip __getgroups getgroups
setfsgid - setfsgid32 Ei:i setfsgid
setfsuid - setfsuid32 Ei:i setfsuid
-
-prlimit64 EXTRA prlimit64 i:iipp prlimit64
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 8d97a32344..3232f11f51 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -1,5 +1,4 @@
# File name Caller Syscall name # args Strong name Weak names
sendfile - sendfile i:iipi sendfile sendfile64
-prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
personality EXTRA personality i:i __personality personality
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/6] linux: Implement mremap in C
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 1/6] linux: Add fanotify_mark C implementation Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 2/6] linux: Add prlimit64 " Adhemerval Zanella via Libc-alpha
@ 2021-11-22 18:54 ` Adhemerval Zanella via Libc-alpha
2021-11-26 0:26 ` Stafford Horne via Libc-alpha
2021-11-22 18:54 ` [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2 Adhemerval Zanella via Libc-alpha
` (2 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
Variadic function calls in syscalls.list does not work for all ABIs
(for instance where the argument are passed on the stack instead of
registers) and might have underlying issues depending of the variadic
type (for instance if a 64-bit argument is used).
Checked on x86_64-linux-gnu.
---
sysdeps/unix/sysv/linux/Makefile | 1 +
sysdeps/unix/sysv/linux/mremap.c | 41 +++++++++++++++++++++++++++
sysdeps/unix/sysv/linux/syscalls.list | 1 -
3 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 sysdeps/unix/sysv/linux/mremap.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index aa10754b98..1dd6ec9ef9 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -68,6 +68,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
closefrom_fallback \
clone3 clone-internal \
fanotify_mark \
+ mremap \
CFLAGS-gethostid.c = -fexceptions
CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c
new file mode 100644
index 0000000000..83b4e95338
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mremap.c
@@ -0,0 +1,41 @@
+/* Remap a virtual memory address. Linux specific syscall.
+ Copyright (C) 2020 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sys/mman.h>
+#include <sysdep.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+void *
+__mremap (void *addr, size_t old_len, size_t new_len, int flags, ...)
+{
+ va_list va;
+ void *new_addr = NULL;
+
+ if (flags & MREMAP_FIXED)
+ {
+ va_start (va, flags);
+ new_addr = va_arg (va, void *);
+ va_end (va);
+ }
+
+ return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags,
+ new_addr);
+}
+libc_hidden_def (__mremap)
+weak_alias (__mremap, mremap)
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 29899eb264..2acd7551d3 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -35,7 +35,6 @@ mincore - mincore i:aUV mincore
mlock - mlock i:bU mlock
mlockall - mlockall i:i mlockall
mount EXTRA mount i:sssUp __mount mount
-mremap EXTRA mremap b:aUUip __mremap mremap
munlock - munlock i:aU munlock
munlockall - munlockall i: munlockall
nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
` (2 preceding siblings ...)
2021-11-22 18:54 ` [PATCH 3/6] linux: Implement mremap in C Adhemerval Zanella via Libc-alpha
@ 2021-11-22 18:54 ` Adhemerval Zanella via Libc-alpha
2021-11-26 23:03 ` Stafford Horne via Libc-alpha
2021-11-22 18:54 ` [PATCH 5/6] linux: Add generic syscall implementation Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 6/6] linux: Add generic ioctl implementation Adhemerval Zanella via Libc-alpha
5 siblings, 1 reply; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
It removes the arch-specific implementation for alpha, ia64,
mips, sh, and sparc which requires a different kernel ABI
than the usual one.
Checked on x86_64-linux-gnu and with a build for the affected ABIs.
---
sysdeps/unix/alpha/pipe.S | 30 --------------
sysdeps/unix/mips/pipe.S | 31 ---------------
sysdeps/unix/sysv/linux/alpha/pipe.S | 1 -
sysdeps/unix/sysv/linux/ia64/pipe.S | 36 -----------------
sysdeps/unix/sysv/linux/mips/pipe.S | 1 -
sysdeps/unix/sysv/linux/{generic => }/pipe.c | 5 ++-
sysdeps/unix/sysv/linux/sh/pipe.S | 42 --------------------
sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 38 ------------------
sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 39 ------------------
sysdeps/unix/sysv/linux/syscalls.list | 1 -
10 files changed, 3 insertions(+), 221 deletions(-)
delete mode 100644 sysdeps/unix/alpha/pipe.S
delete mode 100644 sysdeps/unix/mips/pipe.S
delete mode 100644 sysdeps/unix/sysv/linux/alpha/pipe.S
delete mode 100644 sysdeps/unix/sysv/linux/ia64/pipe.S
delete mode 100644 sysdeps/unix/sysv/linux/mips/pipe.S
rename sysdeps/unix/sysv/linux/{generic => }/pipe.c (87%)
delete mode 100644 sysdeps/unix/sysv/linux/sh/pipe.S
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
diff --git a/sysdeps/unix/alpha/pipe.S b/sysdeps/unix/alpha/pipe.S
deleted file mode 100644
index 45944535cd..0000000000
--- a/sysdeps/unix/alpha/pipe.S
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <https://www.gnu.org/licenses/>. */
-
-/* __pipe is a special syscall since it returns two values. */
-
-#include <sysdep.h>
-
-PSEUDO (__pipe, pipe, 0)
- stl r0, 0(a0)
- stl r1, 4(a0)
- mov zero, v0
- ret
-PSEUDO_END(__pipe)
-
-libc_hidden_def (__pipe)
-weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/mips/pipe.S b/sysdeps/unix/mips/pipe.S
deleted file mode 100644
index 6fbea01d44..0000000000
--- a/sysdeps/unix/mips/pipe.S
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-SYSCALL__ (pipe, 1)
- /* Plop in the two descriptors. */
- sw v0, 0(a0)
- sw v1, 4(a0)
-
- /* Go out with a clean status. */
- move v0, zero
- j ra
-PSEUDO_END(__pipe)
-
-libc_hidden_def (__pipe)
-weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/sysv/linux/alpha/pipe.S b/sysdeps/unix/sysv/linux/alpha/pipe.S
deleted file mode 100644
index 1e7ec1c199..0000000000
--- a/sysdeps/unix/sysv/linux/alpha/pipe.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/alpha/pipe.S>
diff --git a/sysdeps/unix/sysv/linux/ia64/pipe.S b/sysdeps/unix/sysv/linux/ia64/pipe.S
deleted file mode 100644
index ffda712920..0000000000
--- a/sysdeps/unix/sysv/linux/ia64/pipe.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-/* __pipe is a special syscall since it returns two values. */
-
-#include <sysdep.h>
-
-ENTRY(__pipe)
- .regstk 1,0,0,0
- DO_CALL (SYS_ify (pipe))
- cmp.ne p6,p0=-1,r10
- ;;
-(p6) st4 [in0]=r8,4
-(p6) mov ret0=0
- ;;
-(p6) st4 [in0]=r9
-(p6) ret
- br.cond.spnt.few __syscall_error
-PSEUDO_END(__pipe)
-
-libc_hidden_def (__pipe)
-weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/sysv/linux/mips/pipe.S b/sysdeps/unix/sysv/linux/mips/pipe.S
deleted file mode 100644
index 1708888da4..0000000000
--- a/sysdeps/unix/sysv/linux/mips/pipe.S
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/mips/pipe.S>
diff --git a/sysdeps/unix/sysv/linux/generic/pipe.c b/sysdeps/unix/sysv/linux/pipe.c
similarity index 87%
rename from sysdeps/unix/sysv/linux/generic/pipe.c
rename to sysdeps/unix/sysv/linux/pipe.c
index a73a4e89fc..c873bed11a 100644
--- a/sysdeps/unix/sysv/linux/generic/pipe.c
+++ b/sysdeps/unix/sysv/linux/pipe.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
+/* Create create pipe. Linux generic version.
+ Copyright (C) 2021 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,7 +26,7 @@
int
__pipe (int __pipedes[2])
{
- return INLINE_SYSCALL (pipe2, 2, __pipedes, 0);
+ return INLINE_SYSCALL_CALL (pipe2, (int *) __pipedes, 0);
}
libc_hidden_def (__pipe)
weak_alias (__pipe, pipe)
diff --git a/sysdeps/unix/sysv/linux/sh/pipe.S b/sysdeps/unix/sysv/linux/sh/pipe.S
deleted file mode 100644
index 0f3eb16588..0000000000
--- a/sysdeps/unix/sysv/linux/sh/pipe.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
-ENTRY (__libc_pipe)
- mov #+__NR_pipe, r3
- trapa #0x10
- mov r0, r3
- mov #-12, r2
- shad r2, r3
- not r3, r3 // r1=0 means r0 = -1 to -4095
- tst r3, r3 // i.e. error in linux
- bt 1f
- mov.l r0, @r4
- mov.l r1, @(4, r4)
- rts
- mov #0, r0
-1:
- SYSCALL_ERROR_HANDLER
-.Lpseudo_end:
- rts
- nop
-PSEUDO_END (__libc_pipe)
-
-weak_alias (__libc_pipe, __pipe)
-libc_hidden_def (__pipe)
-weak_alias (__libc_pipe, pipe)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
deleted file mode 100644
index 0fa155fa61..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
- .text
- .globl __syscall_error
-ENTRY(__libc_pipe)
- mov %o0, %o2 /* Save PIPEDES. */
- mov SYS_ify(pipe),%g1
- ta 0x10
- bcc 1f
- mov %o7, %g1
- call __syscall_error
- mov %g1, %o7
-1: st %o0, [%o2] /* PIPEDES[0] = %o0; */
- st %o1, [%o2 + 4] /* PIPEDES[1] = %o1; */
- retl
- clr %o0
-END(__libc_pipe)
-
-weak_alias (__libc_pipe, __pipe)
-libc_hidden_def (__pipe)
-weak_alias (__libc_pipe, pipe)
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
deleted file mode 100644
index da6ea71729..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-
- .text
-
- .globl __syscall_error
-ENTRY(__libc_pipe)
- mov %o0, %o2 /* Save PIPEDES. */
- LOADSYSCALL(pipe)
- ta 0x6d
- bcc,pt %xcc, 1f
- mov %o7, %g1
- call __syscall_error
- mov %g1, %o7
-1: st %o0, [%o2] /* PIPEDES[0] = %o0; */
- st %o1, [%o2 + 4] /* PIPEDES[1] = %o1; */
- retl
- clr %o0
-END(__libc_pipe)
-
-weak_alias (__libc_pipe, __pipe)
-libc_hidden_def (__pipe)
-weak_alias (__libc_pipe, pipe)
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 2acd7551d3..8a32b354a9 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -38,7 +38,6 @@ mount EXTRA mount i:sssUp __mount mount
munlock - munlock i:aU munlock
munlockall - munlockall i: munlockall
nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28
-pipe - pipe i:f __pipe pipe
pipe2 - pipe2 i:fi __pipe2 pipe2
pivot_root EXTRA pivot_root i:ss pivot_root
query_module EXTRA query_module i:sipip __compat_query_module query_module@GLIBC_2.0:GLIBC_2.23
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/6] linux: Add generic syscall implementation
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
` (3 preceding siblings ...)
2021-11-22 18:54 ` [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2 Adhemerval Zanella via Libc-alpha
@ 2021-11-22 18:54 ` Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 6/6] linux: Add generic ioctl implementation Adhemerval Zanella via Libc-alpha
5 siblings, 0 replies; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
It allows also to remove hppa specific implementation and simplify
riscv implementation a bit.
---
sysdeps/unix/sysdep.h | 20 ++++++++
sysdeps/unix/sysv/linux/hppa/syscall.c | 65 -------------------------
sysdeps/unix/sysv/linux/riscv/syscall.c | 4 +-
sysdeps/unix/sysv/linux/syscall.c | 43 ++++++++++++++++
4 files changed, 65 insertions(+), 67 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/hppa/syscall.c
create mode 100644 sysdeps/unix/sysv/linux/syscall.c
diff --git a/sysdeps/unix/sysdep.h b/sysdeps/unix/sysdep.h
index 664d093c05..0ecc653838 100644
--- a/sysdeps/unix/sysdep.h
+++ b/sysdeps/unix/sysdep.h
@@ -57,6 +57,26 @@
#define INTERNAL_SYSCALL_CALL(...) \
__INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL, __VA_ARGS__)
+#define __INTERNAL_SYSCALL_NCS0(name) \
+ INTERNAL_SYSCALL_NCS (name, 0)
+#define __INTERNAL_SYSCALL_NCS1(name, a1) \
+ INTERNAL_SYSCALL_NCS (name, 1, a1)
+#define __INTERNAL_SYSCALL_NCS2(name, a1, a2) \
+ INTERNAL_SYSCALL_NCS (name, 2, a1, a2)
+#define __INTERNAL_SYSCALL_NCS3(name, a1, a2, a3) \
+ INTERNAL_SYSCALL_NCS (name, 3, a1, a2, a3)
+#define __INTERNAL_SYSCALL_NCS4(name, a1, a2, a3, a4) \
+ INTERNAL_SYSCALL_NCS (name, 4, a1, a2, a3, a4)
+#define __INTERNAL_SYSCALL_NCS5(name, a1, a2, a3, a4, a5) \
+ INTERNAL_SYSCALL_NCS (name, 5, a1, a2, a3, a4, a5)
+#define __INTERNAL_SYSCALL_NCS6(name, a1, a2, a3, a4, a5, a6) \
+ INTERNAL_SYSCALL_NCS (name, 6, a1, a2, a3, a4, a5, a6)
+#define __INTERNAL_SYSCALL_NCS7(name, a1, a2, a3, a4, a5, a6, a7) \
+ INTERNAL_SYSCALL_NCS (name, 7, a1, a2, a3, a4, a5, a6, a7)
+
+#define INTERNAL_SYSCALL_NCS_CALL(...) \
+ __INTERNAL_SYSCALL_DISP (__INTERNAL_SYSCALL_NCS, __VA_ARGS__)
+
#define __INLINE_SYSCALL0(name) \
INLINE_SYSCALL (name, 0)
#define __INLINE_SYSCALL1(name, a1) \
diff --git a/sysdeps/unix/sysv/linux/hppa/syscall.c b/sysdeps/unix/sysv/linux/hppa/syscall.c
deleted file mode 100644
index bce8c5fa1d..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/syscall.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <stdarg.h>
-#include <sysdep.h>
-#include <errno.h>
-
-/* HPPA implements syscall() in 'C'; the assembler version would
- typically be in syscall.S. Also note that we have INLINE_SYSCALL,
- INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
- How often the function is used is unknown. */
-
-long int
-syscall (long int __sysno, ...)
-{
- /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
- va_list args;
- long int arg0, arg1, arg2, arg3, arg4, arg5;
- long int __sys_res;
-
- /* Load varargs */
- va_start (args, __sysno);
- arg0 = va_arg (args, long int);
- arg1 = va_arg (args, long int);
- arg2 = va_arg (args, long int);
- arg3 = va_arg (args, long int);
- arg4 = va_arg (args, long int);
- arg5 = va_arg (args, long int);
- va_end (args);
-
- {
- LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
- register unsigned long int __res asm("r28");
- PIC_REG_DEF
- LOAD_REGS_6
- asm volatile (SAVE_ASM_PIC
- " ble 0x100(%%sr2, %%r0) \n"
- " copy %1, %%r20 \n"
- LOAD_ASM_PIC
- : "=r" (__res)
- : "r" (__sysno) PIC_REG_USE ASM_ARGS_6
- : "memory", CALL_CLOB_REGS CLOB_ARGS_6);
- __sys_res = __res;
- }
- if ((unsigned long int) __sys_res >= (unsigned long int) -4095)
- {
- __set_errno (-__sys_res);
- __sys_res = -1;
- }
- return __sys_res;
-}
diff --git a/sysdeps/unix/sysv/linux/riscv/syscall.c b/sysdeps/unix/sysv/linux/riscv/syscall.c
index 2748afcd90..f46aa77b00 100644
--- a/sysdeps/unix/sysv/linux/riscv/syscall.c
+++ b/sysdeps/unix/sysv/linux/riscv/syscall.c
@@ -24,8 +24,8 @@ syscall (long int syscall_number, long int arg1, long int arg2, long int arg3,
{
long int ret;
- ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4,
- arg5, arg6, arg7);
+ ret = INTERNAL_SYSCALL_NCS_CALL (syscall_number, arg1, arg2, arg3, arg4,
+ arg5, arg6, arg7);
if (INTERNAL_SYSCALL_ERROR_P (ret))
return __syscall_error (ret);
diff --git a/sysdeps/unix/sysv/linux/syscall.c b/sysdeps/unix/sysv/linux/syscall.c
new file mode 100644
index 0000000000..5d87428756
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/syscall.c
@@ -0,0 +1,43 @@
+/* Indirect system call. Linux generic implementation.
+ Copyright (C) 1997-2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <sysdep.h>
+
+long int
+syscall (long int number, ...)
+{
+ va_list args;
+
+ va_start (args, number);
+ long int a0 = va_arg (args, long int);
+ long int a1 = va_arg (args, long int);
+ long int a2 = va_arg (args, long int);
+ long int a3 = va_arg (args, long int);
+ long int a4 = va_arg (args, long int);
+ long int a5 = va_arg (args, long int);
+ va_end (args);
+
+ int r = INTERNAL_SYSCALL_NCS_CALL (number, a0, a1, a2, a3, a4, a5);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r)))
+ {
+ __set_errno (-r);
+ return -1;
+ }
+ return r;
+}
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 6/6] linux: Add generic ioctl implementation
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
` (4 preceding siblings ...)
2021-11-22 18:54 ` [PATCH 5/6] linux: Add generic syscall implementation Adhemerval Zanella via Libc-alpha
@ 2021-11-22 18:54 ` Adhemerval Zanella via Libc-alpha
2021-12-04 7:50 ` Stafford Horne via Libc-alpha
5 siblings, 1 reply; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-22 18:54 UTC (permalink / raw)
To: libc-alpha, Stafford Horne
The powerpc is refactor to use the default implementation.
---
sysdeps/unix/sysv/linux/internal-ioctl.h | 25 +++++++
sysdeps/unix/sysv/linux/ioctl.c | 49 +++++++++++++
.../unix/sysv/linux/powerpc/internal-ioctl.h | 46 +++++++++++++
sysdeps/unix/sysv/linux/powerpc/ioctl.c | 68 -------------------
4 files changed, 120 insertions(+), 68 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/internal-ioctl.h
create mode 100644 sysdeps/unix/sysv/linux/ioctl.c
create mode 100644 sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/ioctl.c
diff --git a/sysdeps/unix/sysv/linux/internal-ioctl.h b/sysdeps/unix/sysv/linux/internal-ioctl.h
new file mode 100644
index 0000000000..ecd48d5d6e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/internal-ioctl.h
@@ -0,0 +1,25 @@
+/* Linux internal definitions for ioctl.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+/* Architecture ports may choose to override this default implementation
+ to provide architecture specific ioctl support. */
+static inline bool
+__ioctl_arch (int *r, int fd, unsigned long request, void *arg)
+{
+ return false;
+}
diff --git a/sysdeps/unix/sysv/linux/ioctl.c b/sysdeps/unix/sysv/linux/ioctl.c
new file mode 100644
index 0000000000..c4855d6302
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ioctl.c
@@ -0,0 +1,49 @@
+/* Control device. Linux generic implementation.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <sys/ioctl.h>
+#include <sysdep.h>
+#include <internal-ioctl.h>
+
+int
+__ioctl (int fd, unsigned long int request, ...)
+{
+ va_list args;
+ va_start (args, request);
+ void *arg = va_arg (args, void *);
+ va_end (args);
+
+ int r;
+ if (!__ioctl_arch (&r, fd, request, arg))
+ {
+ r = INTERNAL_SYSCALL_CALL (ioctl, fd, request, arg);
+ if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (r)))
+ {
+ __set_errno (-r);
+ return -1;
+ }
+ }
+ return r;
+}
+libc_hidden_def (__ioctl)
+weak_alias (__ioctl, ioctl)
+
+#if __TIMESIZE != 64
+strong_alias (__ioctl, __ioctl_time64)
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h b/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h
new file mode 100644
index 0000000000..3a2adce7c3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h
@@ -0,0 +1,46 @@
+/* Linux internal definitions for ioctl.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <termios.h>
+
+static inline bool
+__ioctl_arch (int *r, int fd, unsigned long request, void *arg)
+{
+ switch (request)
+ {
+ case TCGETS:
+ *r = __tcgetattr (fd, (struct termios *) arg);
+ break;
+
+ case TCSETS:
+ *r = __tcsetattr (fd, TCSANOW, (struct termios *) arg);
+ break;
+
+ case TCSETSW:
+ *r = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg);
+ break;
+
+ case TCSETSF:
+ *r = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg);
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+}
diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl.c b/sysdeps/unix/sysv/linux/powerpc/ioctl.c
deleted file mode 100644
index a81c7ba54c..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/ioctl.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Copyright (C) 1998-2021 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <stdarg.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sysdep.h>
-
-/* The user-visible size of struct termios has changed. Catch ioctl calls
- using the new-style struct termios, and translate them to old-style. */
-
-int
-__ioctl (int fd, unsigned long int request, ...)
-{
- void *arg;
- va_list ap;
- int result;
-
- va_start (ap, request);
- arg = va_arg (ap, void *);
-
- switch (request)
- {
- case TCGETS:
- result = __tcgetattr (fd, (struct termios *) arg);
- break;
-
- case TCSETS:
- result = __tcsetattr (fd, TCSANOW, (struct termios *) arg);
- break;
-
- case TCSETSW:
- result = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg);
- break;
-
- case TCSETSF:
- result = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg);
- break;
-
- default:
- result = INLINE_SYSCALL (ioctl, 3, fd, request, arg);
- break;
- }
-
- va_end (ap);
-
- return result;
-}
-libc_hidden_def (__ioctl)
-weak_alias (__ioctl, ioctl)
-#if __TIMESIZE != 64
-weak_alias (__ioctl, __ioctl_time64)
-#endif
--
2.32.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] linux: Add fanotify_mark C implementation
2021-11-22 18:54 ` [PATCH 1/6] linux: Add fanotify_mark C implementation Adhemerval Zanella via Libc-alpha
@ 2021-11-24 21:45 ` Stafford Horne via Libc-alpha
2021-11-25 12:55 ` Adhemerval Zanella via Libc-alpha
0 siblings, 1 reply; 16+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-11-24 21:45 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Mon, Nov 22, 2021 at 03:54:32PM -0300, Adhemerval Zanella wrote:
> Passing 64-bit arguments on syscalls.list is tricky: it requires
> to reimplement the expected kernel abi in each architecture. This
> is way to better to represent in C code where we already have
> macros for this (SYSCALL_LL64).
>
> Checked on x86_64-linux-gnu.
> ---
> sysdeps/unix/sysv/linux/Makefile | 3 +-
> sysdeps/unix/sysv/linux/arm/syscalls.list | 2 --
> sysdeps/unix/sysv/linux/fanotify_mark.c | 36 +++++++++++++++++++
> .../linux/generic/wordsize-32/syscalls.list | 1 -
> sysdeps/unix/sysv/linux/hppa/fanotify_mark.c | 2 ++
> sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 -
> sysdeps/unix/sysv/linux/i386/syscalls.list | 2 --
> sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 -
> .../unix/sysv/linux/microblaze/syscalls.list | 1 -
> .../unix/sysv/linux/mips/mips32/syscalls.list | 2 --
> .../sysv/linux/mips/mips64/n32/syscalls.list | 2 --
> .../sysv/linux/mips/mips64/n64/syscalls.list | 2 --
> .../linux/powerpc/powerpc32/syscalls.list | 1 -
> .../sysv/linux/s390/s390-32/syscalls.list | 1 -
> sysdeps/unix/sysv/linux/sh/fanotify_mark.c | 2 ++
> sysdeps/unix/sysv/linux/sh/syscalls.list | 2 --
> .../sysv/linux/sparc/sparc32/syscalls.list | 1 -
> .../unix/sysv/linux/wordsize-64/syscalls.list | 2 --
> 18 files changed, 42 insertions(+), 22 deletions(-)
> create mode 100644 sysdeps/unix/sysv/linux/fanotify_mark.c
> create mode 100644 sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
> create mode 100644 sysdeps/unix/sysv/linux/sh/fanotify_mark.c
>
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index 76ad06361c..c5b4f249cc 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -66,7 +66,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
> fxstatat fxstatat64 \
> xmknod xmknodat convert_scm_timestamps \
> closefrom_fallback \
> - clone3 clone-internal
> + clone3 clone-internal \
> + fanotify_mark \
>
> CFLAGS-gethostid.c = -fexceptions
> CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
> diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
> index 10c3ae9dae..fa26876f90 100644
> --- a/sysdeps/unix/sysv/linux/arm/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
> @@ -17,8 +17,6 @@ setfsuid - setfsuid32 Ei:i setfsuid
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> -
> personality EXTRA personality Ei:i __personality personality
>
> # proper socket implementations:
> diff --git a/sysdeps/unix/sysv/linux/fanotify_mark.c b/sysdeps/unix/sysv/linux/fanotify_mark.c
> new file mode 100644
> index 0000000000..6f8fd2e9cf
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/fanotify_mark.c
> @@ -0,0 +1,36 @@
> +/* Add, remove, or modify an fanotify mark on a filesystem object.
> + Linux specific syscall.
> + Copyright (C) 2020 Free Software Foundation, Inc.
2021?
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <sys/fanotify.h>
> +#include <sysdep.h>
> +
> +int
> +__fanotify_mark (int fd, unsigned int flags, uint64_t mask, int dirfd,
> + const char *pathname)
> +{
> + return INLINE_SYSCALL_CALL (fanotify_mark, fd, flags, SYSCALL_LL64 (mask),
> + dirfd, pathname);
> +}
> +#ifdef VERSION_fanotify_mark
> +# include <shlib-compat.h>
> +versioned_symbol (libc, __fanotify_mark, fanotify_mark,
> + VERSION_fanotify_mark);
> +#else
> +weak_alias (__fanotify_mark, fanotify_mark)
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
> index b775008a37..736edbe654 100644
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
> @@ -2,4 +2,3 @@
>
> # rlimit APIs
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> diff --git a/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
> new file mode 100644
> index 0000000000..ce347a4261
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
> @@ -0,0 +1,2 @@
> +#define VERSION_fanotify_mark GLIBC_2_19
> +#include <sysdeps/unix/sysv/linux/fanotify_mark.c>
> diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
> index 043d884bf9..cc5305a585 100644
> --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
> @@ -10,5 +10,4 @@ socket - socket i:iii __socket socket
> socketpair - socketpair i:iiif __socketpair socketpair
>
> prlimit64 EXTRA prlimit64 i:iipp __prlimit64 prlimit64@@GLIBC_2.17
> -fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.19
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
> index 58020dfae5..d3eaabe61b 100644
> --- a/sysdeps/unix/sysv/linux/i386/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
> @@ -21,6 +21,4 @@ vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> -
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list
> index 55a377b841..44c84bf626 100644
> --- a/sysdeps/unix/sysv/linux/m68k/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list
> @@ -17,5 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid
>
> cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
> index 932c9cccc8..0abdc38bf3 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
> @@ -3,5 +3,4 @@
> cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
> index f357b5c918..dbeb184d73 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
> @@ -1,5 +1,3 @@
> # File name Caller Syscall name # args Strong name Weak names
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
> index 9e6a584685..848028f125 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
> @@ -6,6 +6,4 @@ lseek64 - lseek i:iii __lseek64 __libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>
> -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
> -
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> index e4e16dfa49..84f348c8e5 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
> @@ -2,6 +2,4 @@
>
> prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
>
> -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
> -
> sendfile - sendfile i:iipi sendfile sendfile64
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
> index 966856e64a..d31303250d 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
> @@ -4,4 +4,3 @@ chown - chown i:sii __chown chown@@GLIBC_2.1
> lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
> index 300b13dd01..8e9b7c4b71 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
> @@ -16,5 +16,4 @@ setfsgid - setfsgid32 Ei:i setfsgid
> setfsuid - setfsuid32 Ei:i setfsuid
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/sh/fanotify_mark.c b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c
> new file mode 100644
> index 0000000000..3662f21b60
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c
> @@ -0,0 +1,2 @@
> +#define VERSION_fanotify_mark GLIBC_2_16
> +#include <sysdeps/unix/sysv/linux/fanotify_mark.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
> index 32badd1ee0..6ff3e8eb8a 100644
> --- a/sysdeps/unix/sysv/linux/sh/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/sh/syscalls.list
> @@ -17,6 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>
> -fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.16
> -
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
> index 0b6095ffab..4fcae65451 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
> @@ -16,4 +16,3 @@ setfsgid - setfsgid32 Ei:i setfsgid
> setfsuid - setfsuid32 Ei:i setfsuid
>
> prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> index 68e3c60536..8d97a32344 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> @@ -2,6 +2,4 @@
>
> sendfile - sendfile i:iipi sendfile sendfile64
> prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
> -
> -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
> personality EXTRA personality i:i __personality personality
> --
> 2.32.0
Other thank incorrect date nit, this looks ok to me.
-Stafford
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/6] linux: Add fanotify_mark C implementation
2021-11-24 21:45 ` Stafford Horne via Libc-alpha
@ 2021-11-25 12:55 ` Adhemerval Zanella via Libc-alpha
0 siblings, 0 replies; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-25 12:55 UTC (permalink / raw)
To: Stafford Horne; +Cc: libc-alpha
On 24/11/2021 18:45, Stafford Horne wrote:
> On Mon, Nov 22, 2021 at 03:54:32PM -0300, Adhemerval Zanella wrote:
>> Passing 64-bit arguments on syscalls.list is tricky: it requires
>> to reimplement the expected kernel abi in each architecture. This
>> is way to better to represent in C code where we already have
>> macros for this (SYSCALL_LL64).
>>
>> Checked on x86_64-linux-gnu.
>> ---
>> sysdeps/unix/sysv/linux/Makefile | 3 +-
>> sysdeps/unix/sysv/linux/arm/syscalls.list | 2 --
>> sysdeps/unix/sysv/linux/fanotify_mark.c | 36 +++++++++++++++++++
>> .../linux/generic/wordsize-32/syscalls.list | 1 -
>> sysdeps/unix/sysv/linux/hppa/fanotify_mark.c | 2 ++
>> sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 -
>> sysdeps/unix/sysv/linux/i386/syscalls.list | 2 --
>> sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 -
>> .../unix/sysv/linux/microblaze/syscalls.list | 1 -
>> .../unix/sysv/linux/mips/mips32/syscalls.list | 2 --
>> .../sysv/linux/mips/mips64/n32/syscalls.list | 2 --
>> .../sysv/linux/mips/mips64/n64/syscalls.list | 2 --
>> .../linux/powerpc/powerpc32/syscalls.list | 1 -
>> .../sysv/linux/s390/s390-32/syscalls.list | 1 -
>> sysdeps/unix/sysv/linux/sh/fanotify_mark.c | 2 ++
>> sysdeps/unix/sysv/linux/sh/syscalls.list | 2 --
>> .../sysv/linux/sparc/sparc32/syscalls.list | 1 -
>> .../unix/sysv/linux/wordsize-64/syscalls.list | 2 --
>> 18 files changed, 42 insertions(+), 22 deletions(-)
>> create mode 100644 sysdeps/unix/sysv/linux/fanotify_mark.c
>> create mode 100644 sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
>> create mode 100644 sysdeps/unix/sysv/linux/sh/fanotify_mark.c
>>
>> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
>> index 76ad06361c..c5b4f249cc 100644
>> --- a/sysdeps/unix/sysv/linux/Makefile
>> +++ b/sysdeps/unix/sysv/linux/Makefile
>> @@ -66,7 +66,8 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
>> fxstatat fxstatat64 \
>> xmknod xmknodat convert_scm_timestamps \
>> closefrom_fallback \
>> - clone3 clone-internal
>> + clone3 clone-internal \
>> + fanotify_mark \
>>
>> CFLAGS-gethostid.c = -fexceptions
>> CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
>> diff --git a/sysdeps/unix/sysv/linux/arm/syscalls.list b/sysdeps/unix/sysv/linux/arm/syscalls.list
>> index 10c3ae9dae..fa26876f90 100644
>> --- a/sysdeps/unix/sysv/linux/arm/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/arm/syscalls.list
>> @@ -17,8 +17,6 @@ setfsuid - setfsuid32 Ei:i setfsuid
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>>
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> -
>> personality EXTRA personality Ei:i __personality personality
>>
>> # proper socket implementations:
>> diff --git a/sysdeps/unix/sysv/linux/fanotify_mark.c b/sysdeps/unix/sysv/linux/fanotify_mark.c
>> new file mode 100644
>> index 0000000000..6f8fd2e9cf
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/fanotify_mark.c
>> @@ -0,0 +1,36 @@
>> +/* Add, remove, or modify an fanotify mark on a filesystem object.
>> + Linux specific syscall.
>> + Copyright (C) 2020 Free Software Foundation, Inc.
>
> 2021?
Ack (I did a cherry-pick from an old personal branch).
>
>> + This file is part of the GNU C Library.
>> +
>> + The GNU C Library is free software; you can redistribute it and/or
>> + modify it under the terms of the GNU Lesser General Public
>> + License as published by the Free Software Foundation; either
>> + version 2.1 of the License, or (at your option) any later version.
>> +
>> + The GNU C Library is distributed in the hope that it will be useful,
>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + Lesser General Public License for more details.
>> +
>> + You should have received a copy of the GNU Lesser General Public
>> + License along with the GNU C Library; if not, see
>> + <https://www.gnu.org/licenses/>. */
>> +
>> +#include <sys/fanotify.h>
>> +#include <sysdep.h>
>> +
>> +int
>> +__fanotify_mark (int fd, unsigned int flags, uint64_t mask, int dirfd,
>> + const char *pathname)
>> +{
>> + return INLINE_SYSCALL_CALL (fanotify_mark, fd, flags, SYSCALL_LL64 (mask),
>> + dirfd, pathname);
>> +}
>> +#ifdef VERSION_fanotify_mark
>> +# include <shlib-compat.h>
>> +versioned_symbol (libc, __fanotify_mark, fanotify_mark,
>> + VERSION_fanotify_mark);
>> +#else
>> +weak_alias (__fanotify_mark, fanotify_mark)
>> +#endif
>> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
>> index b775008a37..736edbe654 100644
>> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
>> @@ -2,4 +2,3 @@
>>
>> # rlimit APIs
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> diff --git a/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
>> new file mode 100644
>> index 0000000000..ce347a4261
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/hppa/fanotify_mark.c
>> @@ -0,0 +1,2 @@
>> +#define VERSION_fanotify_mark GLIBC_2_19
>> +#include <sysdeps/unix/sysv/linux/fanotify_mark.c>
>> diff --git a/sysdeps/unix/sysv/linux/hppa/syscalls.list b/sysdeps/unix/sysv/linux/hppa/syscalls.list
>> index 043d884bf9..cc5305a585 100644
>> --- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/hppa/syscalls.list
>> @@ -10,5 +10,4 @@ socket - socket i:iii __socket socket
>> socketpair - socketpair i:iiif __socketpair socketpair
>>
>> prlimit64 EXTRA prlimit64 i:iipp __prlimit64 prlimit64@@GLIBC_2.17
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.19
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
>> index 58020dfae5..d3eaabe61b 100644
>> --- a/sysdeps/unix/sysv/linux/i386/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
>> @@ -21,6 +21,4 @@ vm86 - vm86 i:ip __vm86 vm86@@GLIBC_2.3.4
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>>
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> -
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list
>> index 55a377b841..44c84bf626 100644
>> --- a/sysdeps/unix/sysv/linux/m68k/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list
>> @@ -17,5 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid
>>
>> cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
>> index 932c9cccc8..0abdc38bf3 100644
>> --- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
>> @@ -3,5 +3,4 @@
>> cacheflush EXTRA cacheflush i:iiii __cacheflush cacheflush
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
>> index f357b5c918..dbeb184d73 100644
>> --- a/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
>> @@ -1,5 +1,3 @@
>> # File name Caller Syscall name # args Strong name Weak names
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
>> index 9e6a584685..848028f125 100644
>> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
>> @@ -6,6 +6,4 @@ lseek64 - lseek i:iii __lseek64 __libc_lseek64 lseek64@@GLIBC_2.2 llseek@GLIBC
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>>
>> -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
>> -
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
>> index e4e16dfa49..84f348c8e5 100644
>> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
>> @@ -2,6 +2,4 @@
>>
>> prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
>>
>> -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
>> -
>> sendfile - sendfile i:iipi sendfile sendfile64
>> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
>> index 966856e64a..d31303250d 100644
>> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list
>> @@ -4,4 +4,3 @@ chown - chown i:sii __chown chown@@GLIBC_2.1
>> lchown - lchown i:sii __lchown lchown@@GLIBC_2.0 chown@GLIBC_2.0
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
>> index 300b13dd01..8e9b7c4b71 100644
>> --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
>> @@ -16,5 +16,4 @@ setfsgid - setfsgid32 Ei:i setfsgid
>> setfsuid - setfsuid32 Ei:i setfsuid
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/sh/fanotify_mark.c b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c
>> new file mode 100644
>> index 0000000000..3662f21b60
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/sh/fanotify_mark.c
>> @@ -0,0 +1,2 @@
>> +#define VERSION_fanotify_mark GLIBC_2_16
>> +#include <sysdeps/unix/sysv/linux/fanotify_mark.c>
>> diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
>> index 32badd1ee0..6ff3e8eb8a 100644
>> --- a/sysdeps/unix/sysv/linux/sh/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/sh/syscalls.list
>> @@ -17,6 +17,4 @@ setfsuid - setfsuid32 Ei:i setfsuid
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>>
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis __fanotify_mark fanotify_mark@@GLIBC_2.16
>> -
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
>> index 0b6095ffab..4fcae65451 100644
>> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
>> @@ -16,4 +16,3 @@ setfsgid - setfsgid32 Ei:i setfsgid
>> setfsuid - setfsuid32 Ei:i setfsuid
>>
>> prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark
>> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>> index 68e3c60536..8d97a32344 100644
>> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>> @@ -2,6 +2,4 @@
>>
>> sendfile - sendfile i:iipi sendfile sendfile64
>> prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
>> -
>> -fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
>> personality EXTRA personality i:i __personality personality
>> --
>> 2.32.0
>
> Other thank incorrect date nit, this looks ok to me.
Thanks, I will push it.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/6] linux: Add prlimit64 C implementation
2021-11-22 18:54 ` [PATCH 2/6] linux: Add prlimit64 " Adhemerval Zanella via Libc-alpha
@ 2021-11-25 23:39 ` Stafford Horne via Libc-alpha
2021-11-30 11:51 ` Adhemerval Zanella via Libc-alpha
0 siblings, 1 reply; 16+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-11-25 23:39 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Mon, Nov 22, 2021 at 03:54:33PM -0300, Adhemerval Zanella wrote:
> The LFS prlimit64 requires a arch-specific implementation in
> syscalls.list. Instead add a generic one that handles the
> required symbol alias for __RLIM_T_MATCHES_RLIM64_T.
>
> HPPA is the only outlier which requires a different default
> symbol.
>
> Checked on x86_64-linux-gnu and with build for the affected ABIs.
> ---
> sysdeps/unix/sysv/linux/Makefile | 2 +-
> sysdeps/unix/sysv/linux/arm/syscalls.list | 2 -
> .../linux/generic/wordsize-32/syscalls.list | 4 --
> sysdeps/unix/sysv/linux/hppa/prlimit64.c | 2 +
> sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 -
> sysdeps/unix/sysv/linux/i386/syscalls.list | 2 -
> sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 -
> .../unix/sysv/linux/microblaze/syscalls.list | 1 -
> .../unix/sysv/linux/mips/mips32/syscalls.list | 3 --
> .../sysv/linux/mips/mips64/n32/syscalls.list | 2 -
> .../sysv/linux/mips/mips64/n64/syscalls.list | 2 -
> .../linux/powerpc/powerpc32/syscalls.list | 2 -
> sysdeps/unix/sysv/linux/prlimit.c | 2 +
> sysdeps/unix/sysv/linux/prlimit64.c | 39 +++++++++++++++++++
> .../sysv/linux/s390/s390-32/syscalls.list | 1 -
> sysdeps/unix/sysv/linux/sh/syscalls.list | 2 -
> .../sysv/linux/sparc/sparc32/syscalls.list | 2 -
> .../unix/sysv/linux/wordsize-64/syscalls.list | 1 -
> 18 files changed, 44 insertions(+), 27 deletions(-)
> delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
> create mode 100644 sysdeps/unix/sysv/linux/hppa/prlimit64.c
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
> create mode 100644 sysdeps/unix/sysv/linux/prlimit64.c
> diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c
> index c12de52693..f9d9911a04 100644
> --- a/sysdeps/unix/sysv/linux/prlimit.c
> +++ b/sysdeps/unix/sysv/linux/prlimit.c
> @@ -18,6 +18,7 @@
> #include <sys/resource.h>
> #include <sysdep.h>
Possibly a comment here saying something like.
/* For ports that support the 64-bit ABI we do not need to define prlimit
and instead prlimit aliases to prlimit64. See the prlimit64
implementation. */
> +#if !__RLIM_T_MATCHES_RLIM64_T
> int
> prlimit (__pid_t pid, enum __rlimit_resource resource,
> const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
> @@ -73,3 +74,4 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
>
> return res;
> }
> +#endif /* __RLIM_T_MATCHES_RLIM64_T */
> diff --git a/sysdeps/unix/sysv/linux/prlimit64.c b/sysdeps/unix/sysv/linux/prlimit64.c
> new file mode 100644
> index 0000000000..e3a8718b98
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/prlimit64.c
> @@ -0,0 +1,39 @@
> +/* Get/set resource limits. Linux specific syscall.
> + Copyright (C) 2020 Free Software Foundation, Inc.
2021.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#define prlimit __redirect_prlimit
> +#include <sys/resource.h>
> +#undef prlimit
> +#include <sysdep.h>
> +
> +int
> +__prlimit64 (pid_t pid, enum __rlimit_resource resource,
> + const struct rlimit64 *new_rlimit, struct rlimit64 *old_rlimit)
> +{
> + return INLINE_SYSCALL_CALL (prlimit64, pid, resource, new_rlimit,
> + old_rlimit);
> +}
> +#ifdef VERSION_prlimit64
> +# include <shlib-compat.h>
> +versioned_symbol (libc, __prlimit64, prlimit64, VERSION_prlimit64);
> +#else
> +strong_alias (__prlimit64, prlimit64)
> +# if __RLIM_T_MATCHES_RLIM64_T
> +strong_alias (prlimit64, prlimit)
> +# endif
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
> index 8e9b7c4b71..91d78d91ef 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
> @@ -15,5 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups
> setfsgid - setfsgid32 Ei:i setfsgid
> setfsuid - setfsuid32 Ei:i setfsuid
>
> -prlimit64 EXTRA prlimit64 i:iipp prlimit64
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
> index 6ff3e8eb8a..78b2348c05 100644
> --- a/sysdeps/unix/sysv/linux/sh/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/sh/syscalls.list
> @@ -15,6 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups
> setfsgid - setfsgid32 Ei:i setfsgid
> setfsuid - setfsuid32 Ei:i setfsuid
>
> -prlimit64 EXTRA prlimit64 i:iipp prlimit64
> -
> personality EXTRA personality Ei:i __personality personality
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
> index 4fcae65451..9e4eb0a165 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
> @@ -14,5 +14,3 @@ getgroups - getgroups32 i:ip __getgroups getgroups
>
> setfsgid - setfsgid32 Ei:i setfsgid
> setfsuid - setfsuid32 Ei:i setfsuid
> -
> -prlimit64 EXTRA prlimit64 i:iipp prlimit64
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> index 8d97a32344..3232f11f51 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> @@ -1,5 +1,4 @@
> # File name Caller Syscall name # args Strong name Weak names
>
> sendfile - sendfile i:iipi sendfile sendfile64
> -prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
> personality EXTRA personality i:i __personality personality
> --
> 2.32.0
Other than the year issue (as I understand the patch is from your old branch..).
It looks fine to me.
-Stafford
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/6] linux: Implement mremap in C
2021-11-22 18:54 ` [PATCH 3/6] linux: Implement mremap in C Adhemerval Zanella via Libc-alpha
@ 2021-11-26 0:26 ` Stafford Horne via Libc-alpha
2021-11-30 11:55 ` Adhemerval Zanella via Libc-alpha
0 siblings, 1 reply; 16+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-11-26 0:26 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Mon, Nov 22, 2021 at 03:54:34PM -0300, Adhemerval Zanella wrote:
> Variadic function calls in syscalls.list does not work for all ABIs
> (for instance where the argument are passed on the stack instead of
> registers) and might have underlying issues depending of the variadic
> type (for instance if a 64-bit argument is used).
>
> Checked on x86_64-linux-gnu.
> ---
> sysdeps/unix/sysv/linux/Makefile | 1 +
> sysdeps/unix/sysv/linux/mremap.c | 41 +++++++++++++++++++++++++++
> sysdeps/unix/sysv/linux/syscalls.list | 1 -
> 3 files changed, 42 insertions(+), 1 deletion(-)
> create mode 100644 sysdeps/unix/sysv/linux/mremap.c
>
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index aa10754b98..1dd6ec9ef9 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -68,6 +68,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
> closefrom_fallback \
> clone3 clone-internal \
> fanotify_mark \
> + mremap \
>
> CFLAGS-gethostid.c = -fexceptions
> CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
> diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c
> new file mode 100644
> index 0000000000..83b4e95338
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/mremap.c
> @@ -0,0 +1,41 @@
> +/* Remap a virtual memory address. Linux specific syscall.
> + Copyright (C) 2020 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
2021
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <https://www.gnu.org/licenses/>. */
> +
> +#include <sys/mman.h>
> +#include <sysdep.h>
> +#include <stdarg.h>
> +#include <stddef.h>
> +
> +void *
> +__mremap (void *addr, size_t old_len, size_t new_len, int flags, ...)
> +{
> + va_list va;
> + void *new_addr = NULL;
> +
> + if (flags & MREMAP_FIXED)
> + {
> + va_start (va, flags);
> + new_addr = va_arg (va, void *);
> + va_end (va);
> + }
> +
> + return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags,
> + new_addr);
> +}
> +libc_hidden_def (__mremap)
> +weak_alias (__mremap, mremap)
> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
> index 29899eb264..2acd7551d3 100644
> --- a/sysdeps/unix/sysv/linux/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/syscalls.list
> @@ -35,7 +35,6 @@ mincore - mincore i:aUV mincore
> mlock - mlock i:bU mlock
> mlockall - mlockall i:i mlockall
> mount EXTRA mount i:sssUp __mount mount
> -mremap EXTRA mremap b:aUUip __mremap mremap
> munlock - munlock i:aU munlock
> munlockall - munlockall i: munlockall
> nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28
> --
> 2.32.0
>
This looks OK to me.
Note, I guess this syscall would be broken in or1k at the moment as it passes
variadic args on the stack. However, I didn't see any test failures due to
this.
-Stafford
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2
2021-11-22 18:54 ` [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2 Adhemerval Zanella via Libc-alpha
@ 2021-11-26 23:03 ` Stafford Horne via Libc-alpha
2021-11-30 14:53 ` Adhemerval Zanella via Libc-alpha
0 siblings, 1 reply; 16+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-11-26 23:03 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Mon, Nov 22, 2021 at 03:54:35PM -0300, Adhemerval Zanella wrote:
> It removes the arch-specific implementation for alpha, ia64,
> mips, sh, and sparc which requires a different kernel ABI
> than the usual one.
>
> Checked on x86_64-linux-gnu and with a build for the affected ABIs.
> ---
> sysdeps/unix/alpha/pipe.S | 30 --------------
> sysdeps/unix/mips/pipe.S | 31 ---------------
> sysdeps/unix/sysv/linux/alpha/pipe.S | 1 -
> sysdeps/unix/sysv/linux/ia64/pipe.S | 36 -----------------
> sysdeps/unix/sysv/linux/mips/pipe.S | 1 -
> sysdeps/unix/sysv/linux/{generic => }/pipe.c | 5 ++-
> sysdeps/unix/sysv/linux/sh/pipe.S | 42 --------------------
> sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 38 ------------------
> sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 39 ------------------
> sysdeps/unix/sysv/linux/syscalls.list | 1 -
> 10 files changed, 3 insertions(+), 221 deletions(-)
> delete mode 100644 sysdeps/unix/alpha/pipe.S
> delete mode 100644 sysdeps/unix/mips/pipe.S
> delete mode 100644 sysdeps/unix/sysv/linux/alpha/pipe.S
> delete mode 100644 sysdeps/unix/sysv/linux/ia64/pipe.S
> delete mode 100644 sysdeps/unix/sysv/linux/mips/pipe.S
> rename sysdeps/unix/sysv/linux/{generic => }/pipe.c (87%)
> delete mode 100644 sysdeps/unix/sysv/linux/sh/pipe.S
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
This patch all looks good to me.
We might want to mention in the commit message that this is allowed because:
The syscall pipe2 was added in linux 2.6.27 and glibc requires linux 3.2.0.
For reference, these patches set the tree wided minimum required version most
recently. I dont know what it was before but its fare to say using pipe2 is
safe.
2016: 5b4ecd3f95 ("Require Linux 3.2 except on x86 / x86_64, 3.2 headers everywhere.").
2017: 139ace9575 ("Require Linux kernel 3.2 or later on x86 / x86_64.").
-Stafford
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/6] linux: Add prlimit64 C implementation
2021-11-25 23:39 ` Stafford Horne via Libc-alpha
@ 2021-11-30 11:51 ` Adhemerval Zanella via Libc-alpha
0 siblings, 0 replies; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-30 11:51 UTC (permalink / raw)
To: Stafford Horne; +Cc: libc-alpha
On 25/11/2021 20:39, Stafford Horne wrote:
> On Mon, Nov 22, 2021 at 03:54:33PM -0300, Adhemerval Zanella wrote:
>> The LFS prlimit64 requires a arch-specific implementation in
>> syscalls.list. Instead add a generic one that handles the
>> required symbol alias for __RLIM_T_MATCHES_RLIM64_T.
>>
>> HPPA is the only outlier which requires a different default
>> symbol.
>>
>> Checked on x86_64-linux-gnu and with build for the affected ABIs.
>> ---
>> sysdeps/unix/sysv/linux/Makefile | 2 +-
>> sysdeps/unix/sysv/linux/arm/syscalls.list | 2 -
>> .../linux/generic/wordsize-32/syscalls.list | 4 --
>> sysdeps/unix/sysv/linux/hppa/prlimit64.c | 2 +
>> sysdeps/unix/sysv/linux/hppa/syscalls.list | 1 -
>> sysdeps/unix/sysv/linux/i386/syscalls.list | 2 -
>> sysdeps/unix/sysv/linux/m68k/syscalls.list | 1 -
>> .../unix/sysv/linux/microblaze/syscalls.list | 1 -
>> .../unix/sysv/linux/mips/mips32/syscalls.list | 3 --
>> .../sysv/linux/mips/mips64/n32/syscalls.list | 2 -
>> .../sysv/linux/mips/mips64/n64/syscalls.list | 2 -
>> .../linux/powerpc/powerpc32/syscalls.list | 2 -
>> sysdeps/unix/sysv/linux/prlimit.c | 2 +
>> sysdeps/unix/sysv/linux/prlimit64.c | 39 +++++++++++++++++++
>> .../sysv/linux/s390/s390-32/syscalls.list | 1 -
>> sysdeps/unix/sysv/linux/sh/syscalls.list | 2 -
>> .../sysv/linux/sparc/sparc32/syscalls.list | 2 -
>> .../unix/sysv/linux/wordsize-64/syscalls.list | 1 -
>> 18 files changed, 44 insertions(+), 27 deletions(-)
>> delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list
>> create mode 100644 sysdeps/unix/sysv/linux/hppa/prlimit64.c
>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
>> create mode 100644 sysdeps/unix/sysv/linux/prlimit64.c
>> diff --git a/sysdeps/unix/sysv/linux/prlimit.c b/sysdeps/unix/sysv/linux/prlimit.c
>> index c12de52693..f9d9911a04 100644
>> --- a/sysdeps/unix/sysv/linux/prlimit.c
>> +++ b/sysdeps/unix/sysv/linux/prlimit.c
>> @@ -18,6 +18,7 @@
>> #include <sys/resource.h>
>> #include <sysdep.h>
>
> Possibly a comment here saying something like.
>
> /* For ports that support the 64-bit ABI we do not need to define prlimit
> and instead prlimit aliases to prlimit64. See the prlimit64
> implementation. */
It is kinda implicit for other LFS aliais, but the extra comment is helpful.
Ack.
>
>> +#if !__RLIM_T_MATCHES_RLIM64_T
>> int
>> prlimit (__pid_t pid, enum __rlimit_resource resource,
>> const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
>> @@ -73,3 +74,4 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
>>
>> return res;
>> }
>> +#endif /* __RLIM_T_MATCHES_RLIM64_T */
>> diff --git a/sysdeps/unix/sysv/linux/prlimit64.c b/sysdeps/unix/sysv/linux/prlimit64.c
>> new file mode 100644
>> index 0000000000..e3a8718b98
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/prlimit64.c
>> @@ -0,0 +1,39 @@
>> +/* Get/set resource limits. Linux specific syscall.
>> + Copyright (C) 2020 Free Software Foundation, Inc.
>
> 2021.
Ack.
>
>> + This file is part of the GNU C Library.
>> +
>> + The GNU C Library is free software; you can redistribute it and/or
>> + modify it under the terms of the GNU Lesser General Public
>> + License as published by the Free Software Foundation; either
>> + version 2.1 of the License, or (at your option) any later version.
>> +
>> + The GNU C Library is distributed in the hope that it will be useful,
>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + Lesser General Public License for more details.
>> +
>> + You should have received a copy of the GNU Lesser General Public
>> + License along with the GNU C Library; if not, see
>> + <https://www.gnu.org/licenses/>. */
>> +
>> +#define prlimit __redirect_prlimit
>> +#include <sys/resource.h>
>> +#undef prlimit
>> +#include <sysdep.h>
>> +
>> +int
>> +__prlimit64 (pid_t pid, enum __rlimit_resource resource,
>> + const struct rlimit64 *new_rlimit, struct rlimit64 *old_rlimit)
>> +{
>> + return INLINE_SYSCALL_CALL (prlimit64, pid, resource, new_rlimit,
>> + old_rlimit);
>> +}
>> +#ifdef VERSION_prlimit64
>> +# include <shlib-compat.h>
>> +versioned_symbol (libc, __prlimit64, prlimit64, VERSION_prlimit64);
>> +#else
>> +strong_alias (__prlimit64, prlimit64)
>> +# if __RLIM_T_MATCHES_RLIM64_T
>> +strong_alias (prlimit64, prlimit)
>> +# endif
>> +#endif
>> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
>> index 8e9b7c4b71..91d78d91ef 100644
>> --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
>> @@ -15,5 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups
>> setfsgid - setfsgid32 Ei:i setfsgid
>> setfsuid - setfsuid32 Ei:i setfsuid
>>
>> -prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
>> index 6ff3e8eb8a..78b2348c05 100644
>> --- a/sysdeps/unix/sysv/linux/sh/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/sh/syscalls.list
>> @@ -15,6 +15,4 @@ getgroups - getgroups32 i:ip __getgroups getgroups
>> setfsgid - setfsgid32 Ei:i setfsgid
>> setfsuid - setfsuid32 Ei:i setfsuid
>>
>> -prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> -
>> personality EXTRA personality Ei:i __personality personality
>> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
>> index 4fcae65451..9e4eb0a165 100644
>> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
>> @@ -14,5 +14,3 @@ getgroups - getgroups32 i:ip __getgroups getgroups
>>
>> setfsgid - setfsgid32 Ei:i setfsgid
>> setfsuid - setfsuid32 Ei:i setfsuid
>> -
>> -prlimit64 EXTRA prlimit64 i:iipp prlimit64
>> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>> index 8d97a32344..3232f11f51 100644
>> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
>> @@ -1,5 +1,4 @@
>> # File name Caller Syscall name # args Strong name Weak names
>>
>> sendfile - sendfile i:iipi sendfile sendfile64
>> -prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
>> personality EXTRA personality i:i __personality personality
>> --
>> 2.32.0
>
> Other than the year issue (as I understand the patch is from your old branch..).
>
> It looks fine to me.
>
> -Stafford
Ack.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/6] linux: Implement mremap in C
2021-11-26 0:26 ` Stafford Horne via Libc-alpha
@ 2021-11-30 11:55 ` Adhemerval Zanella via Libc-alpha
0 siblings, 0 replies; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-30 11:55 UTC (permalink / raw)
To: Stafford Horne; +Cc: libc-alpha
On 25/11/2021 21:26, Stafford Horne wrote:
> On Mon, Nov 22, 2021 at 03:54:34PM -0300, Adhemerval Zanella wrote:
>> Variadic function calls in syscalls.list does not work for all ABIs
>> (for instance where the argument are passed on the stack instead of
>> registers) and might have underlying issues depending of the variadic
>> type (for instance if a 64-bit argument is used).
>>
>> Checked on x86_64-linux-gnu.
>> ---
>> sysdeps/unix/sysv/linux/Makefile | 1 +
>> sysdeps/unix/sysv/linux/mremap.c | 41 +++++++++++++++++++++++++++
>> sysdeps/unix/sysv/linux/syscalls.list | 1 -
>> 3 files changed, 42 insertions(+), 1 deletion(-)
>> create mode 100644 sysdeps/unix/sysv/linux/mremap.c
>>
>> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
>> index aa10754b98..1dd6ec9ef9 100644
>> --- a/sysdeps/unix/sysv/linux/Makefile
>> +++ b/sysdeps/unix/sysv/linux/Makefile
>> @@ -68,6 +68,7 @@ sysdep_routines += adjtimex clone umount umount2 readahead sysctl \
>> closefrom_fallback \
>> clone3 clone-internal \
>> fanotify_mark \
>> + mremap \
>>
>> CFLAGS-gethostid.c = -fexceptions
>> CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
>> diff --git a/sysdeps/unix/sysv/linux/mremap.c b/sysdeps/unix/sysv/linux/mremap.c
>> new file mode 100644
>> index 0000000000..83b4e95338
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/mremap.c
>> @@ -0,0 +1,41 @@
>> +/* Remap a virtual memory address. Linux specific syscall.
>> + Copyright (C) 2020 Free Software Foundation, Inc.
>> + This file is part of the GNU C Library.
>
> 2021
Ack.
>
>> +
>> + The GNU C Library is free software; you can redistribute it and/or
>> + modify it under the terms of the GNU Lesser General Public
>> + License as published by the Free Software Foundation; either
>> + version 2.1 of the License, or (at your option) any later version.
>> +
>> + The GNU C Library is distributed in the hope that it will be useful,
>> + but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
>> + Lesser General Public License for more details.
>> +
>> + You should have received a copy of the GNU Lesser General Public
>> + License along with the GNU C Library; if not, see
>> + <https://www.gnu.org/licenses/>. */
>> +
>> +#include <sys/mman.h>
>> +#include <sysdep.h>
>> +#include <stdarg.h>
>> +#include <stddef.h>
>> +
>> +void *
>> +__mremap (void *addr, size_t old_len, size_t new_len, int flags, ...)
>> +{
>> + va_list va;
>> + void *new_addr = NULL;
>> +
>> + if (flags & MREMAP_FIXED)
>> + {
>> + va_start (va, flags);
>> + new_addr = va_arg (va, void *);
>> + va_end (va);
>> + }
>> +
>> + return (void *) INLINE_SYSCALL_CALL (mremap, addr, old_len, new_len, flags,
>> + new_addr);
>> +}
>> +libc_hidden_def (__mremap)
>> +weak_alias (__mremap, mremap)
>> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
>> index 29899eb264..2acd7551d3 100644
>> --- a/sysdeps/unix/sysv/linux/syscalls.list
>> +++ b/sysdeps/unix/sysv/linux/syscalls.list
>> @@ -35,7 +35,6 @@ mincore - mincore i:aUV mincore
>> mlock - mlock i:bU mlock
>> mlockall - mlockall i:i mlockall
>> mount EXTRA mount i:sssUp __mount mount
>> -mremap EXTRA mremap b:aUUip __mremap mremap
>> munlock - munlock i:aU munlock
>> munlockall - munlockall i: munlockall
>> nfsservctl EXTRA nfsservctl i:ipp __compat_nfsservctl nfsservctl@GLIBC_2.0:GLIBC_2.28
>> --
>> 2.32.0
>>
>
> This looks OK to me.
>
> Note, I guess this syscall would be broken in or1k at the moment as it passes
> variadic args on the stack. However, I didn't see any test failures due to
> this.
I think it would be for MREMAP_FIXED and the there is no failures because we
don't use the flag neither internally nor on any test.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2
2021-11-26 23:03 ` Stafford Horne via Libc-alpha
@ 2021-11-30 14:53 ` Adhemerval Zanella via Libc-alpha
0 siblings, 0 replies; 16+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-11-30 14:53 UTC (permalink / raw)
To: Stafford Horne; +Cc: libc-alpha
On 26/11/2021 20:03, Stafford Horne wrote:
> On Mon, Nov 22, 2021 at 03:54:35PM -0300, Adhemerval Zanella wrote:
>> It removes the arch-specific implementation for alpha, ia64,
>> mips, sh, and sparc which requires a different kernel ABI
>> than the usual one.
>>
>> Checked on x86_64-linux-gnu and with a build for the affected ABIs.
>> ---
>> sysdeps/unix/alpha/pipe.S | 30 --------------
>> sysdeps/unix/mips/pipe.S | 31 ---------------
>> sysdeps/unix/sysv/linux/alpha/pipe.S | 1 -
>> sysdeps/unix/sysv/linux/ia64/pipe.S | 36 -----------------
>> sysdeps/unix/sysv/linux/mips/pipe.S | 1 -
>> sysdeps/unix/sysv/linux/{generic => }/pipe.c | 5 ++-
>> sysdeps/unix/sysv/linux/sh/pipe.S | 42 --------------------
>> sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 38 ------------------
>> sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 39 ------------------
>> sysdeps/unix/sysv/linux/syscalls.list | 1 -
>> 10 files changed, 3 insertions(+), 221 deletions(-)
>> delete mode 100644 sysdeps/unix/alpha/pipe.S
>> delete mode 100644 sysdeps/unix/mips/pipe.S
>> delete mode 100644 sysdeps/unix/sysv/linux/alpha/pipe.S
>> delete mode 100644 sysdeps/unix/sysv/linux/ia64/pipe.S
>> delete mode 100644 sysdeps/unix/sysv/linux/mips/pipe.S
>> rename sysdeps/unix/sysv/linux/{generic => }/pipe.c (87%)
>> delete mode 100644 sysdeps/unix/sysv/linux/sh/pipe.S
>> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S
>> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S
>
> This patch all looks good to me.
>
> We might want to mention in the commit message that this is allowed because:
>
> The syscall pipe2 was added in linux 2.6.27 and glibc requires linux 3.2.0.
Ack.
>
> For reference, these patches set the tree wided minimum required version most
> recently. I dont know what it was before but its fare to say using pipe2 is
> safe.
>
> 2016: 5b4ecd3f95 ("Require Linux 3.2 except on x86 / x86_64, 3.2 headers everywhere.").
> 2017: 139ace9575 ("Require Linux kernel 3.2 or later on x86 / x86_64.").
>
> -Stafford
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 6/6] linux: Add generic ioctl implementation
2021-11-22 18:54 ` [PATCH 6/6] linux: Add generic ioctl implementation Adhemerval Zanella via Libc-alpha
@ 2021-12-04 7:50 ` Stafford Horne via Libc-alpha
0 siblings, 0 replies; 16+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-12-04 7:50 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Mon, Nov 22, 2021 at 03:54:37PM -0300, Adhemerval Zanella wrote:
> The powerpc is refactor to use the default implementation.
> ---
> sysdeps/unix/sysv/linux/internal-ioctl.h | 25 +++++++
> sysdeps/unix/sysv/linux/ioctl.c | 49 +++++++++++++
> .../unix/sysv/linux/powerpc/internal-ioctl.h | 46 +++++++++++++
> sysdeps/unix/sysv/linux/powerpc/ioctl.c | 68 -------------------
> 4 files changed, 120 insertions(+), 68 deletions(-)
> create mode 100644 sysdeps/unix/sysv/linux/internal-ioctl.h
> create mode 100644 sysdeps/unix/sysv/linux/ioctl.c
> create mode 100644 sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/ioctl.c
I don't see this pushed upstream yet.
Just in case you forgot.
-Stafford
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2021-12-04 7:51 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 18:54 [PATCH 0/6] linux: Some syscall refactors Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 1/6] linux: Add fanotify_mark C implementation Adhemerval Zanella via Libc-alpha
2021-11-24 21:45 ` Stafford Horne via Libc-alpha
2021-11-25 12:55 ` Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 2/6] linux: Add prlimit64 " Adhemerval Zanella via Libc-alpha
2021-11-25 23:39 ` Stafford Horne via Libc-alpha
2021-11-30 11:51 ` Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 3/6] linux: Implement mremap in C Adhemerval Zanella via Libc-alpha
2021-11-26 0:26 ` Stafford Horne via Libc-alpha
2021-11-30 11:55 ` Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 4/6] linux: Implement pipe in terms of __NR_pipe2 Adhemerval Zanella via Libc-alpha
2021-11-26 23:03 ` Stafford Horne via Libc-alpha
2021-11-30 14:53 ` Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 5/6] linux: Add generic syscall implementation Adhemerval Zanella via Libc-alpha
2021-11-22 18:54 ` [PATCH 6/6] linux: Add generic ioctl implementation Adhemerval Zanella via Libc-alpha
2021-12-04 7:50 ` Stafford Horne via Libc-alpha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).