about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-12-02 08:21:38 +0000
committerUlrich Drepper <drepper@redhat.com>1999-12-02 08:21:38 +0000
commitd7a4856e5d2e91b76309e308b6d084d23bafa6fe (patch)
treefaa95993e1d14fe13cf435dd0d6f441c12c533c6 /sysdeps/unix/sysv/linux
parente099035591cffba3b024f6cddeb90f8ac5e45bfd (diff)
downloadglibc-d7a4856e5d2e91b76309e308b6d084d23bafa6fe.tar.gz
glibc-d7a4856e5d2e91b76309e308b6d084d23bafa6fe.tar.xz
glibc-d7a4856e5d2e91b76309e308b6d084d23bafa6fe.zip
Update.
1999-12-01  Andreas Jaeger  <aj@suse.de>

	* sysdeps/generic/if_index.c (__protocol_available): Add missing
	int for parameter.

	* stdio/stdio.h: Fix typo.
	Patches by Marcus G. Daniels <mgd@santafe.edu>.

1999-12-01  Andreas Jaeger  <aj@suse.de>

	* scripts/test-installation.pl (installation_problem): Filter out
	libpthread_db.

1999-12-01  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/alpha/bits/types.h: Fix signedness of
	__rlim_t and __rlim64_t.
	* sysdeps/unix/sysv/linux/mips/bits/types.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/types.h: Likewise.

1999-12-01  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add
	oldgetrlimit64 and oldsetrlimit64 for subdir = resource.
	* sysdeps/unix/sysv/linux/Versions: Add getrlimit, setrlimit,
	getrlimit64 and setrlimit64 to version GLIBC_2.1.3.
	* sysdeps/unix/sysv/linux/setrlimit.c: Correct handling of old and
	new kernel version.  Add symbol versions.
	* sysdeps/unix/sysv/linux/syscalls.list: Add oldsetrlimit and
	oldgetrlimit.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Add s_getrlimit
	and s_ugetrlimit.
	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/getrlimit.c: New file.
	* sysdeps/unix/sysv/linux/getrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/oldgetrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/oldsetrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/setrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/alpha/oldgetrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/alpha/oldsetrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/oldgetrlimit64.c: New
	file.
	* sysdeps/unix/sysv/linux/sparc/sparc64/oldsetrlimit64.c: New
	file.
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/Makefile4
-rw-r--r--sysdeps/unix/sysv/linux/Versions4
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/types.h4
-rw-r--r--sysdeps/unix/sysv/linux/alpha/oldgetrlimit64.c1
-rw-r--r--sysdeps/unix/sysv/linux/alpha/oldsetrlimit64.c1
-rw-r--r--sysdeps/unix/sysv/linux/alpha/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/getrlimit.c87
-rw-r--r--sysdeps/unix/sysv/linux/getrlimit64.c28
-rw-r--r--sysdeps/unix/sysv/linux/i386/getrlimit.c64
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/types.h4
-rw-r--r--sysdeps/unix/sysv/linux/oldgetrlimit64.c53
-rw-r--r--sysdeps/unix/sysv/linux/oldsetrlimit64.c52
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/setrlimit.c67
-rw-r--r--sysdeps/unix/sysv/linux/setrlimit64.c28
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/types.h4
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/oldgetrlimit64.c1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/oldsetrlimit64.c1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list2
21 files changed, 317 insertions, 96 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 4d7594d1ec..4c5b7ea612 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -106,3 +106,7 @@ endif
 ifeq ($(subdir),nis)
 CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
 endif
+
+ifeq ($(subdir),resource)
+sysdep_routines += oldgetrlimit64 oldsetrlimit64
+endif
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 6210830cce..4088643189 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -82,4 +82,8 @@ libc {
     # u*
     umount2;
   }
+  GLIBC_2.1.3 {
+    # New rlimit interface
+    getrlimit; setrlimit; getrlimit64; setrlimit64;
+  }
 }
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/types.h b/sysdeps/unix/sysv/linux/alpha/bits/types.h
index d98ed8ad8c..d55fee384c 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/types.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/types.h
@@ -57,8 +57,8 @@ typedef __int64_t  __off64_t;		/*  "" (LFS) */
 typedef __int64_t  __loff_t;		/* Type of file sizes and offsets.  */
 typedef __int32_t  __pid_t;		/* Type of process identifications.  */
 typedef __int64_t  __ssize_t;		/* Type of a byte count, or error.  */
-typedef __int64_t  __rlim_t;		/* Type of resource counts.  */
-typedef __int64_t  __rlim64_t;		/*  "" (LFS) */
+typedef __uint64_t  __rlim_t;		/* Type of resource counts.  */
+typedef __uint64_t  __rlim64_t;		/*  "" (LFS) */
 typedef __uint32_t __blksize_t;		/* Type to represnet block size.  */
 typedef __uint32_t __blkcnt_t;		/* Type to count nr disk blocks.  */
 typedef __uint64_t __blkcnt64_t;	/*  "" (LFS) */
diff --git a/sysdeps/unix/sysv/linux/alpha/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/alpha/oldgetrlimit64.c
new file mode 100644
index 0000000000..9feab0e6b8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/oldgetrlimit64.c
@@ -0,0 +1 @@
+/* getrlimit64 is the same as getrlimit. */
diff --git a/sysdeps/unix/sysv/linux/alpha/oldsetrlimit64.c b/sysdeps/unix/sysv/linux/alpha/oldsetrlimit64.c
new file mode 100644
index 0000000000..8edcff0086
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/alpha/oldsetrlimit64.c
@@ -0,0 +1 @@
+/* setrlimit64 is the same as setrlimit. */
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index ba20cd0d72..49f2b11a50 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -29,6 +29,8 @@ fstatfs		-	fstatfs		2	__fstatfs	fstatfs fstatfs64
 statfs		-	statfs		2	__statfs	statfs statfs64
 getrlimit	-	getrlimit	2	__getrlimit	getrlimit getrlimit64
 setrlimit	-	setrlimit	2	setrlimit	setrlimit64
+oldgetrlimit	EXTRA	getrlimit	2	__old_getrlimit	getrlimit@GLIBC_2.0 getrlimit64@GLIBC_2.1
+oldsetrlimit	EXTRA	setrlimit	2	__old_setrlimit	setrlimit@GLIBC_2.0 setrlimit64@GLIBC_2.1
 ftruncate	-	ftruncate	2	__ftruncate	ftruncate ftruncate64
 truncate	-	truncate	2	truncate	truncate64
 
diff --git a/sysdeps/unix/sysv/linux/getrlimit.c b/sysdeps/unix/sysv/linux/getrlimit.c
new file mode 100644
index 0000000000..3eee05c108
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getrlimit.c
@@ -0,0 +1,87 @@
+/* Copyright (C) 1999 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+#include "kernel-features.h"
+
+extern int __syscall_ugetrlimit __P ((unsigned int resource,
+				      struct rlimit *rlimits));
+extern int __syscall_getrlimit __P ((unsigned int resource,
+				     struct rlimit *rlimits));
+
+/* Linux 2.3.25 introduced a new system call since the types used for
+   the limits are now unsigned.  */
+#if defined __NR_ugetrlimit && !defined __ASSUME_NEW_GETRLIMIT_SYSCALL
+int __have_no_new_getrlimit;
+#endif
+
+int
+__new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
+{
+#ifdef __ASSUME_NEW_GETRLIMIT_SYSCALL
+  return INLINE_SYSCALL (ugetrlimit, 2, resource, rlimits);
+#else
+  int result;
+
+# ifdef __NR_ugetrlimit
+  if (__have_no_new_getrlimit <= 0)
+    {
+      result = INLINE_SYSCALL (ugetrlimit, 2, resource, rlimits);
+
+      /* If the system call is available remember this fact and return.  */
+      if (result != -1 || errno != ENOSYS)
+	{
+	  __have_no_new_getrlimit = -1;
+	  return result;
+	}
+
+      /* Remember that the system call is not available.  */
+      __have_no_new_getrlimit = 1;
+    }
+# endif
+
+  /* Fall back to the old system call.  */
+  result = INLINE_SYSCALL (getrlimit, 2, resource, rlimits);
+
+  if (result == -1)
+    return result;
+
+  /* We might have to correct the limits values.  Since the old values
+     were signed the infinity value is too small.  */
+  if (rlimits->rlim_cur == RLIM_INFINITY >> 1)
+    rlimits->rlim_cur = RLIM_INFINITY;
+  if (rlimits->rlim_max == RLIM_INFINITY >> 1)
+    rlimits->rlim_max = RLIM_INFINITY;
+
+  return result;
+#endif
+}
+
+#if defined PIC && DO_VERSIONING
+default_symbol_version (__new_getrlimit, __getrlimit, GLIBC_2.1.3);
+strong_alias (__new_getrlimit, _new_getrlimit);
+default_symbol_version (_new_getrlimit, getrlimit, GLIBC_2.1.3);
+#else
+weak_alias (__new_getrlimit, __getrlimit);
+weak_alias (__new_getrlimit, getrlimit);
+#endif
diff --git a/sysdeps/unix/sysv/linux/getrlimit64.c b/sysdeps/unix/sysv/linux/getrlimit64.c
new file mode 100644
index 0000000000..602dd28d8a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/getrlimit64.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define getrlimit64 __new_getrlimit64
+
+#include <sysdeps/generic/getrlimit64.c>
+
+#undef getrlimit64
+#if defined PIC && defined DO_VERSIONING
+default_symbol_version (__new_getrlimit64, getrlimit64, GLIBC_2.1.3);
+#else
+weak_alias (__new_getrlimit64, getrlimit64);
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/getrlimit.c b/sysdeps/unix/sysv/linux/i386/getrlimit.c
deleted file mode 100644
index 25d0d3b458..0000000000
--- a/sysdeps/unix/sysv/linux/i386/getrlimit.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (C) 1999 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 Library General Public License as
-   published by the Free Software Foundation; either version 2 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
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
-
-#include <errno.h>
-#include <sys/resource.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-#include "../kernel-features.h"
-
-
-/* Linux 2.3.25 introduced a new system call since the types used for
-   the limits are now unsigned.  */
-#if !defined __ASSUME_NEW_GETRLIMIT_SYSCALL && defined __NR_ugetrlimit
-static int no_new_getrlimit;
-#else
-# define no_new_getrlimit	0
-#endif
-
-int
-__getrlimit (resource, rlimits)
-     enum __rlimit_resource resource;
-     struct rlimit *rlimits;
-{
-#ifdef __NR_ugetrlimit
-  if (! no_new_getrlimit)
-    {
-      int result = INLINE_SYSCALL (ugetrlimit, 2, resource, rlimits);
-
-# ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
-      /* If the system call is available return.  */
-      if (result != -1 || errno != ENOSYS)
-# endif
-	return result;
-
-# ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
-      /* Remember that the system call is not available.  */
-      no_new_getrlimit = 1;
-# endif
-    }
-#endif
-
-#ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
-  /* Fall back on the old system call.  */
-  return INLINE_SYSCALL (getrlimit, 2, resource, rlimits);
-#endif
-}
-weak_alias (__getrlimit, getrlimit)
diff --git a/sysdeps/unix/sysv/linux/mips/bits/types.h b/sysdeps/unix/sysv/linux/mips/bits/types.h
index 37c3f21c5b..a52bb8022b 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/types.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/types.h
@@ -68,8 +68,8 @@ typedef long int __off_t;		/* Type of file sizes and offsets.  */
 typedef __quad_t __loff_t;		/* Type of file sizes and offsets.  */
 typedef int __pid_t;			/* Type of process identifications.  */
 typedef int __ssize_t;			/* Type of a byte count, or error.  */
-typedef long int __rlim_t;		/* Type of resource counts.  */
-typedef __quad_t __rlim64_t;		/* Type of resource counts (LFS).  */
+typedef __u_long __rlim_t;		/* Type of resource counts.  */
+typedef __u_quad_t __rlim64_t;		/* Type of resource counts (LFS).  */
 typedef __u_int __id_t;			/* General type for ID.  */
 
 typedef struct
diff --git a/sysdeps/unix/sysv/linux/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/oldgetrlimit64.c
new file mode 100644
index 0000000000..5fb0becfbe
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldgetrlimit64.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 1991, 1995, 1996, 1997, 1998, 1999 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This is a compatibility file.  If we don't build the libc with
+   versioning don't compile this file.  */
+#if defined PIC && DO_VERSIONING
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+extern int __old_getrlimit (enum __rlimit_resource, struct rlimit *);
+
+/* Put the soft and hard limits for RESOURCE in *RLIMITS.
+   Returns 0 if successful, -1 if not (and sets errno).  */
+int
+__old_getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
+{
+  struct rlimit rlimits32;
+
+  if (__old_getrlimit (resource, &rlimits32) < 0)
+    return -1;
+
+  if (rlimits32.rlim_cur == RLIM_INFINITY >> 1)
+    rlimits->rlim_cur = RLIM64_INFINITY >> 1;
+  else
+    rlimits->rlim_cur = rlimits32.rlim_cur;
+  if (rlimits32.rlim_max == RLIM_INFINITY >> 1)
+    rlimits->rlim_max = RLIM64_INFINITY >> 1;
+  else
+    rlimits->rlim_max = rlimits32.rlim_max;
+
+  return 0;
+}
+
+symbol_version (__old_getrlimit64, getrlimit64, GLIBC_2.1);
+
+#endif /* PIC && DO_VERSIONING */
diff --git a/sysdeps/unix/sysv/linux/oldsetrlimit64.c b/sysdeps/unix/sysv/linux/oldsetrlimit64.c
new file mode 100644
index 0000000000..c5448dcdce
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/oldsetrlimit64.c
@@ -0,0 +1,52 @@
+/* Copyright (C) 1991, 95, 96, 97, 98, 1999 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This is a compatibility file.  If we don't build the libc with
+   versioning don't compile this file.  */
+#if defined PIC && DO_VERSIONING
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+extern int __old_setrlimit (enum __rlimit_resource, const struct rlimit *);
+
+/* Set the soft and hard limits for RESOURCE to *RLIMITS.
+   Only the super-user can increase hard limits.
+   Return 0 if successful, -1 if not (and sets errno).  */
+int
+__old_setrlimit64 (enum __rlimit_resource resource,
+		   const struct rlimit64 *rlimits)
+{
+  struct rlimit rlimits32;
+
+  if (rlimits->rlim_cur >= RLIM_INFINITY >> 1)
+    rlimits32.rlim_cur = RLIM_INFINITY >> 1;
+  else
+    rlimits32.rlim_cur = rlimits->rlim_cur;
+  if (rlimits->rlim_max >= RLIM_INFINITY >> 1)
+    rlimits32.rlim_max = RLIM_INFINITY >> 1;
+  else
+    rlimits32.rlim_max = rlimits->rlim_max;
+
+  return __old_setrlimit (resource, &rlimits32);
+}
+
+symbol_version (__old_setrlimit64, setrlimit64, GLIBC_2.1);
+
+#endif /* PIC && DO_VERSIONING */
diff --git a/sysdeps/unix/sysv/linux/powerpc/syscalls.list b/sysdeps/unix/sysv/linux/powerpc/syscalls.list
index 1d8df00505..c207270a86 100644
--- a/sysdeps/unix/sysv/linux/powerpc/syscalls.list
+++ b/sysdeps/unix/sysv/linux/powerpc/syscalls.list
@@ -17,6 +17,7 @@ s_getdents	getdents getdents	3	__syscall_getdents
 s_getpriority	getpriority getpriority	2	__syscall_getpriority
 s_getresgid	getresgid getresgid	3	__syscall_getresgid
 s_getresuid	getresuid getresuid	3	__syscall_getresuid
+s_getrlimit	getrlimit getrlimit	2	__syscall_getrlimit
 s_poll		poll	poll		3	__syscall_poll
 s_pread64	pread64	pread		5	__syscall_pread
 s_ptrace	ptrace	ptrace		4	__syscall_ptrace
@@ -28,6 +29,7 @@ s_sigpending	sigpending sigpending	1	__syscall_sigpending
 s_sigprocmask	sigprocmask sigprocmask	3	__syscall_sigprocmask
 s_sigsuspend	sigsuspend sigsuspend	3	__syscall_sigsuspend
 s_sysctl	sysctl	_sysctl		1	__syscall__sysctl
+s_ugetrlimit	getrlimit ugetrlimit	2	__syscall_ugetrlimit
 s_ustat		ustat	ustat		2	__syscall_ustat
 s_vfork		vfork	vfork		0	__syscall_vfork
 sys_fstat	fxstat	fstat		2	__syscall_fstat
diff --git a/sysdeps/unix/sysv/linux/setrlimit.c b/sysdeps/unix/sysv/linux/setrlimit.c
index 43bfdbbbc4..882f0c55cc 100644
--- a/sysdeps/unix/sysv/linux/setrlimit.c
+++ b/sysdeps/unix/sysv/linux/setrlimit.c
@@ -27,52 +27,67 @@
 
 extern int __syscall_setrlimit (unsigned int resource,
 				const struct rlimit *rlimits);
+extern int __syscall_ugetrlimit (unsigned int resource,
+				 const struct rlimit *rlimits);
 
 /* Linux 2.3.25 introduced a new system call since the types used for
    the limits are now unsigned.  */
-#if !defined __ASSUME_NEW_GETRLIMIT_SYSCALL && defined __NR_ugetrlimit
-static int no_new_getrlimit;
-#else
-# define no_new_getrlimit	0
+#if defined __NR_ugetrlimit && !defined __ASSUME_NEW_GETRLIMIT_SYSCALL
+extern int __have_no_new_getrlimit; /* from getrlimit.c */
 #endif
 
 int
-__setrlimit (resource, rlimits)
-     enum __rlimit_resource resource;
-     const struct rlimit *rlimits;
+__new_setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits)
 {
-#ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
+#ifdef __ASSUME_NEW_GETRLIMIT_SYSCALL
+  return INLINE_SYSCALL (setrlimit, 2, resource, rlimits);
+#else
   struct rlimit rlimits_small;
-#endif
 
-#ifdef __NR_ugetrlimit
-  if (! no_new_getrlimit)
+# ifdef __NR_ugetrlimit
+  if (__have_no_new_getrlimit <= 0)
     {
       int result = INLINE_SYSCALL (setrlimit, 2, resource, rlimits);
 
-# ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
-      /* If the system call is available return.  */
-      if (result != -1 || errno != ENOSYS)
-# endif
+      /* Return if the values are not out of range or if we positively
+         know that the ugetrlimit system call exists.  */
+      if (result != -1 || errno != EINVAL || __have_no_new_getrlimit < 0)
 	return result;
 
-# ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
-      /* Remember that the system call is not available.  */
-      no_new_getrlimit = 1;
-# endif
+      /* Check if the new ugetrlimit syscall exists.  */
+      if (INLINE_SYSCALL (ugetrlimit, 2, resource, &rlimits_small) != -1
+	  || errno != ENOSYS)
+	{
+	  /* There was some other error, probably RESOURCE out of range.
+             Remember that the ugetrlimit system call really exists.  */
+	  __have_no_new_getrlimit = -1;
+	  /* Restore previous errno value.  */
+	  __set_errno (EINVAL);
+	  return result;
+	}
+
+      /* Remember that the kernel uses the old interface.  */
+      __have_no_new_getrlimit = 1;
     }
-#endif
+# endif
 
-#ifndef __ASSUME_NEW_GETRLIMIT_SYSCALL
   /* We might have to correct the limits values.  Since the old values
-     were signed the new values are too large.  */
+     were signed the new values might be too large.  */
   rlimits_small.rlim_cur = MIN ((unsigned long int) rlimits->rlim_cur,
-				RLIM_INFINITY >> 2);
+				RLIM_INFINITY >> 1);
   rlimits_small.rlim_max = MIN ((unsigned long int) rlimits->rlim_max,
-				RLIM_INFINITY >> 2);
+				RLIM_INFINITY >> 1);
 
-  /* Fall back on the old system call.  */
+  /* Try again with the adjusted values.  */
   return INLINE_SYSCALL (setrlimit, 2, resource, &rlimits_small);
 #endif
 }
-weak_alias (__setrlimit, setrlimit)
+
+#if defined PIC && DO_VERSIONING
+default_symbol_version (__new_setrlimit, __setrlimit, GLIBC_2.1.3);
+strong_alias (__new_setrlimit, _new_setrlimit);
+default_symbol_version (_new_setrlimit, setrlimit, GLIBC_2.1.3);
+#else
+weak_alias (__new_setrlimit, __setrlimit);
+weak_alias (__new_setrlimit, setrlimit);
+#endif
diff --git a/sysdeps/unix/sysv/linux/setrlimit64.c b/sysdeps/unix/sysv/linux/setrlimit64.c
new file mode 100644
index 0000000000..3e7e5cc0e0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/setrlimit64.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 1999 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#define setrlimit64 __new_setrlimit64
+
+#include <sysdeps/generic/setrlimit64.c>
+
+#undef setrlimit64
+#if defined PIC && defined DO_VERSIONING
+default_symbol_version (__new_setrlimit64, setrlimit64, GLIBC_2.1.3);
+#else
+weak_alias (__new_setrlimit64, setrlimit64);
+#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/types.h b/sysdeps/unix/sysv/linux/sparc/bits/types.h
index 89b3ad9c07..ad217bf6ad 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/types.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/types.h
@@ -85,8 +85,8 @@ typedef long long int __ssize_t;	/* Type of a byte count, or error.  */
 #else
 typedef int __ssize_t;			/* Type of a byte count, or error.  */
 #endif
-typedef long int __rlim_t;		/* Type of resource counts.  */
-typedef __quad_t __rlim64_t;		/* Type of resource counts (LFS).  */
+typedef __u_long __rlim_t;		/* Type of resource counts.  */
+typedef __u_quad_t __rlim64_t;		/* Type of resource counts (LFS).  */
 typedef __u_int __id_t;			/* General type for IDs.  */
 
 typedef struct
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
index 3ce7d31908..c80056f003 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list
@@ -28,6 +28,7 @@ s_getdents	getdents getdents	3	__syscall_getdents
 s_getpriority	getpriority getpriority	2	__syscall_getpriority
 s_getresgid	getresgid getresgid	3	__syscall_getresgid
 s_getresuid	getresuid getresuid	3	__syscall_getresuid
+s_getrlimit	getrlimit getrlimit	2	__syscall_getrlimit
 s_poll		poll	poll		3	__syscall_poll
 s_pread64	pread64	pread		5	__syscall_pread
 s_ptrace	ptrace	ptrace		4	__syscall_ptrace
@@ -38,6 +39,7 @@ s_sigpending	sigpending sigpending	1	__syscall_sigpending
 s_sigprocmask	sigprocmask sigprocmask	3	__syscall_sigprocmask
 s_sigsuspend	sigsuspend sigsuspend	3	__syscall_sigsuspend
 s_sysctl	sysctl	_sysctl		1	__syscall__sysctl
+s_ugetrlimit	getrlimit ugetrlimit	2	__syscall_ugetrlimit
 s_ustat		ustat	ustat		2	__syscall_ustat
 sys_fstat	fxstat	fstat		2	__syscall_fstat
 sys_lstat	lxstat	lstat		2	__syscall_lstat
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/oldgetrlimit64.c b/sysdeps/unix/sysv/linux/sparc/sparc64/oldgetrlimit64.c
new file mode 100644
index 0000000000..9feab0e6b8
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/oldgetrlimit64.c
@@ -0,0 +1 @@
+/* getrlimit64 is the same as getrlimit. */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/oldsetrlimit64.c b/sysdeps/unix/sysv/linux/sparc/sparc64/oldsetrlimit64.c
new file mode 100644
index 0000000000..8edcff0086
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/oldsetrlimit64.c
@@ -0,0 +1 @@
+/* setrlimit64 is the same as setrlimit. */
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
index 679722f37d..c857cf880f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list
@@ -8,6 +8,8 @@ fstatfs		-	fstatfs		2	__fstatfs	fstatfs fstatfs64
 statfs		-	statfs		2	__statfs	statfs statfs64
 getrlimit	-	getrlimit	2	__getrlimit	getrlimit getrlimit64
 setrlimit	-	setrlimit	2	setrlimit	setrlimit64
+oldgetrlimit	EXTRA	getrlimit	2	__old_getrlimit	getrlimit@GLIBC_2.0 getrlimit64@GLIBC_2.1
+oldsetrlimit	EXTRA	setrlimit	2	__old_setrlimit	setrlimit@GLIBC_2.0 setrlimit64@GLIBC_2.1
 ftruncate	-	ftruncate	2	__ftruncate	ftruncate ftruncate64
 truncate	-	truncate	2	truncate	truncate64
 mmap		-	mmap		6	__mmap		mmap __mmap64 mmap64
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 6215973fc3..50f1cc9803 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -33,6 +33,8 @@ munlock		EXTRA	munlock		2	__munlock	munlock
 munlockall	EXTRA	munlockall	0	__munlockall	munlockall
 nanosleep	-	nanosleep	2	__libc_nanosleep	__nanosleep nanosleep
 nfsservctl	EXTRA	nfsservctl	3	nfsservctl
+oldgetrlimit	EXTRA	getrlimit	2	__old_getrlimit	getrlimit@GLIBC_2.0
+oldsetrlimit	EXTRA	setrlimit	2	__old_setrlimit	setrlimit@GLIBC_2.0
 pause		-	pause		0	__libc_pause	pause
 personality	init-first personality	1	__personality	personality
 pipe		-	pipe		1	__pipe		pipe