about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-06-11 17:41:16 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-11-30 13:13:03 -0300
commit83008fa495535aaef74def5ab4ed59967fff1bb6 (patch)
tree0ba20ad426e1d301233f777263a366734659eb36
parentdf4cb2280e32187380520f71bd27ab32252cbc85 (diff)
downloadglibc-83008fa495535aaef74def5ab4ed59967fff1bb6.tar.gz
glibc-83008fa495535aaef74def5ab4ed59967fff1bb6.tar.xz
glibc-83008fa495535aaef74def5ab4ed59967fff1bb6.zip
linux: Add prlimit64 C implementation
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.
-rw-r--r--sysdeps/unix/sysv/linux/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/arm/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/generic/wordsize-32/syscalls.list4
-rw-r--r--sysdeps/unix/sysv/linux/hppa/prlimit64.c2
-rw-r--r--sysdeps/unix/sysv/linux/hppa/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/i386/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/m68k/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/syscalls.list3
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/prlimit.c5
-rw-r--r--sysdeps/unix/sysv/linux/prlimit64.c39
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/sh/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/syscalls.list1
18 files changed, 47 insertions, 27 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 695535716a..e8574f3c6f 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..d4e0b73bce 100644
--- a/sysdeps/unix/sysv/linux/prlimit.c
+++ b/sysdeps/unix/sysv/linux/prlimit.c
@@ -18,6 +18,10 @@
 #include <sys/resource.h>
 #include <sysdep.h>
 
+/* 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 +77,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..1565b849d2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/prlimit64.c
@@ -0,0 +1,39 @@
+/* Get/set resource limits.  Linux specific syscall.
+   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/>.  */
+
+#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