diff mbox series

[20/28] linux: Add prlimit64 C implementation

Message ID 20201118195552.2687336-21-adhemerval.zanella@linaro.org
State New
Headers show
Series More Linux syscall refactor | expand

Commit Message

Adhemerval Zanella Nov. 18, 2020, 7:55 p.m. UTC
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    |  3 --
 sysdeps/unix/sysv/linux/i386/syscalls.list    |  2 -
 sysdeps/unix/sysv/linux/m68k/syscalls.list    |  1 -
 .../unix/sysv/linux/microblaze/syscalls.list  |  2 -
 .../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     |  2 -
 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(+), 31 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/hppa/syscalls.list
 delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/syscalls.list
 create mode 100644 sysdeps/unix/sysv/linux/prlimit64.c
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 71bb4cbddd..c3b24f9332 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 ef35963e82..8340745c86 100644
--- a/sysdeps/unix/sysv/linux/arm/syscalls.list
+++ b/sysdeps/unix/sysv/linux/arm/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/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
deleted file mode 100644
index a20bdc7726..0000000000
--- a/sysdeps/unix/sysv/linux/hppa/syscalls.list
+++ /dev/null
@@ -1,3 +0,0 @@ 
-# File name	Caller	Syscall name	# args	Strong name	Weak names
-
-prlimit64	EXTRA	prlimit64	i:iipp	__prlimit64	prlimit64@@GLIBC_2.17
diff --git a/sysdeps/unix/sysv/linux/i386/syscalls.list b/sysdeps/unix/sysv/linux/i386/syscalls.list
index a20d6ebf24..24412aabbc 100644
--- a/sysdeps/unix/sysv/linux/i386/syscalls.list
+++ b/sysdeps/unix/sysv/linux/i386/syscalls.list
@@ -18,5 +18,3 @@  setfsuid	-	setfsuid32	Ei:i	setfsuid
 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
diff --git a/sysdeps/unix/sysv/linux/m68k/syscalls.list b/sysdeps/unix/sysv/linux/m68k/syscalls.list
index e28ccc2c45..e1e964dd1c 100644
--- a/sysdeps/unix/sysv/linux/m68k/syscalls.list
+++ b/sysdeps/unix/sysv/linux/m68k/syscalls.list
@@ -16,4 +16,3 @@  setfsgid	-	setfsgid32	Ei:i	setfsgid
 setfsuid	-	setfsuid32	Ei:i	setfsuid
 
 cacheflush	EXTRA	cacheflush	i:iiii	__cacheflush	cacheflush
-prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
diff --git a/sysdeps/unix/sysv/linux/microblaze/syscalls.list b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
index f479ef0826..5367ef0d0b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/syscalls.list
+++ b/sysdeps/unix/sysv/linux/microblaze/syscalls.list
@@ -1,5 +1,3 @@ 
 # File name	Caller	Syscall name	Args	Strong name	Weak names
 
 cacheflush	EXTRA	cacheflush	i:iiii	__cacheflush	cacheflush
-
-prlimit64	EXTRA	prlimit64	i:iipp	prlimit64
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 6135436182..6f665635e0 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
@@ -3,5 +3,3 @@ 
 # C syscall macros cannot be used because this syscall has a 64-bit
 # 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
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
index ecf9d80ed4..50ab64d3c2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
@@ -1,7 +1,5 @@ 
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64
-
 fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
 statfs		-	statfs		i:sp	__statfs	statfs statfs64 __statfs64
 
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 e12eb4e9bc..6707cf6b1e 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 1c565e9ba5..fa05bac4d5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/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/sh/syscalls.list b/sysdeps/unix/sysv/linux/sh/syscalls.list
index ef35963e82..8340745c86 100644
--- a/sysdeps/unix/sysv/linux/sh/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sh/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/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 0404a1c0d7..c5b839e7c2 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -3,4 +3,3 @@ 
 fstatfs		-	fstatfs		i:ip	__fstatfs	fstatfs fstatfs64 __fstatfs64
 statfs		-	statfs		i:sp	__statfs	statfs statfs64
 sendfile	-	sendfile	i:iipi	sendfile	sendfile64
-prlimit		EXTRA	prlimit64	i:iipp	prlimit		prlimit64