This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] *rlimit* fixes for main trunk


Hi!

Enclosed is a trunk patch. I wonder how arm setrlimit could work, when it
was using i386 *rlimit* stubs but with RLIM_INFINITY (~0UL>>1), so this
patch adds arm resource.h, plus there is really no need to limit the old
getrlimit64/setrlimit64 to 2GB when RLIM64_INFINITY is much larger and
we're using a 64bit type to hold resource limits. This e.g. removes the need
for two different setrlimit64 calls (because both are the same and equal to
the generic version) and oldgetrlimit64 will report rlimits up to 4GB.

2000-01-24  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/unix/sysv/linux/arm/bits/resource.h: New file.
	* sysdeps/unix/sysv/linux/arm/Makefile: Remove oldsetrlimit64.c.
	* sysdeps/unix/sysv/linux/i386/Makefile: Likewise.
	* sysdeps/unix/sysv/linux/i386/Dist: Likewise.
	* sysdeps/unix/sysv/linux/arm/Versions: Remove
	setrlimit64@GLIBC_2.1.3.
	* sysdeps/unix/sysv/linux/i386/Versions: Likewise.
	* sysdeps/unix/sysv/linux/arm/oldsetrlimit64.c: Remove.
	* sysdeps/unix/sysv/linux/i386/oldsetrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/setrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setrlimit64.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Call __new_getrlimit,
	so that setrlimit64@GLIBC_2.1 can report limits above 2G.
	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list (getrlimit,
	setrlimit): Remove syscall stubs, add normal syscalls.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (setrlimit):
	Remove syscall stub.

--- libc/sysdeps/unix/sysv/linux/arm/bits/resource.h.jj	Mon Jan 24 09:42:18 2000
+++ libc/sysdeps/unix/sysv/linux/arm/bits/resource.h	Sun Dec 19 00:49:02 1999
@@ -0,0 +1,205 @@
+/* Bit values & structures for resource limits.  Linux version.
+   Copyright (C) 1994, 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.  */
+
+#ifndef _SYS_RESOURCE_H
+# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
+#endif
+
+#include <bits/types.h>
+
+/* Transmute defines to enumerations.  The macro re-definitions are
+   necessary because some programs want to test for operating system
+   features with #ifdef RUSAGE_SELF.  In ISO C the reflexive
+   definition is a no-op.  */
+
+/* Kinds of resource limit.  */
+enum __rlimit_resource
+{
+  /* Per-process CPU limit, in seconds.  */
+  RLIMIT_CPU = 0,
+#define RLIMIT_CPU RLIMIT_CPU
+
+  /* Largest file that can be created, in bytes.  */
+  RLIMIT_FSIZE = 1,
+#define	RLIMIT_FSIZE RLIMIT_FSIZE
+
+  /* Maximum size of data segment, in bytes.  */
+  RLIMIT_DATA = 2,
+#define	RLIMIT_DATA RLIMIT_DATA
+
+  /* Maximum size of stack segment, in bytes.  */
+  RLIMIT_STACK = 3,
+#define	RLIMIT_STACK RLIMIT_STACK
+
+  /* Largest core file that can be created, in bytes.  */
+  RLIMIT_CORE = 4,
+#define	RLIMIT_CORE RLIMIT_CORE
+
+  /* Largest resident set size, in bytes.
+     This affects swapping; processes that are exceeding their
+     resident set size will be more likely to have physical memory
+     taken from them.  */
+  RLIMIT_RSS = 5,
+#define	RLIMIT_RSS RLIMIT_RSS
+
+  /* Number of open files.  */
+  RLIMIT_NOFILE = 7,
+  RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same.  */
+#define RLIMIT_NOFILE RLIMIT_NOFILE
+#define RLIMIT_OFILE RLIMIT_OFILE
+
+  /* Address space limit.  */
+  RLIMIT_AS = 9,
+#define RLIMIT_AS RLIMIT_AS
+
+  /* Number of processes.  */
+  RLIMIT_NPROC = 6,
+#define RLIMIT_NPROC RLIMIT_NPROC
+
+  /* Locked-in-memory address space.  */
+  RLIMIT_MEMLOCK = 8,
+#define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
+
+  RLIMIT_NLIMITS = 10,
+  RLIM_NLIMITS = RLIMIT_NLIMITS
+#define RLIMIT_NLIMITS RLIMIT_NLIMITS
+#define RLIM_NLIMITS RLIM_NLIMITS
+};
+
+/* Value to indicate that there is no limit.  */
+#ifndef __USE_FILE_OFFSET64
+# define RLIM_INFINITY ((unsigned long int)(~0UL))
+#else
+# define RLIM_INFINITY 0xffffffffffffffffuLL
+#endif
+
+#ifdef __USE_LARGEFILE64
+# define RLIM64_INFINITY 0xffffffffffffffffuLL
+#endif
+
+/* We can represent all limits.  */
+#define RLIM_SAVED_MAX	RLIM_INFINITY
+#define RLIM_SAVED_CUR	RLIM_INFINITY
+
+
+/* Type for resource quantity measurement.  */
+#ifndef __USE_FILE_OFFSET64
+typedef __rlim_t rlim_t;
+#else
+typedef __rlim64_t rlim_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef __rlim64_t rlim64_t;
+#endif
+
+struct rlimit
+  {
+    /* The current (soft) limit.  */
+    rlim_t rlim_cur;
+    /* The hard limit.  */
+    rlim_t rlim_max;
+  };
+
+#ifdef __USE_LARGEFILE64
+struct rlimit64
+  {
+    /* The current (soft) limit.  */
+    rlim64_t rlim_cur;
+    /* The hard limit.  */
+    rlim64_t rlim_max;
+ };
+#endif
+
+/* Whose usage statistics do you want?  */
+enum __rusage_who
+{
+  /* The calling process.  */
+  RUSAGE_SELF = 0,
+#define RUSAGE_SELF RUSAGE_SELF
+
+  /* All of its terminated child processes.  */
+  RUSAGE_CHILDREN = -1,
+#define RUSAGE_CHILDREN RUSAGE_CHILDREN
+
+  /* Both.  */
+  RUSAGE_BOTH = -2
+#define RUSAGE_BOTH RUSAGE_BOTH
+};
+
+#define __need_timeval
+#include <bits/time.h>		/* For `struct timeval'.  */
+
+/* Structure which says how much of each resource has been used.  */
+struct rusage
+  {
+    /* Total amount of user time used.  */
+    struct timeval ru_utime;
+    /* Total amount of system time used.  */
+    struct timeval ru_stime;
+    /* Maximum resident set size (in kilobytes).  */
+    long int ru_maxrss;
+    /* Amount of sharing of text segment memory
+       with other processes (kilobyte-seconds).  */
+    long int ru_ixrss;
+    /* Amount of data segment memory used (kilobyte-seconds).  */
+    long int ru_idrss;
+    /* Amount of stack memory used (kilobyte-seconds).  */
+    long int ru_isrss;
+    /* Number of soft page faults (i.e. those serviced by reclaiming
+       a page from the list of pages awaiting reallocation.  */
+    long int ru_minflt;
+    /* Number of hard page faults (i.e. those that required I/O).  */
+    long int ru_majflt;
+    /* Number of times a process was swapped out of physical memory.  */
+    long int ru_nswap;
+    /* Number of input operations via the file system.  Note: This
+       and `ru_oublock' do not include operations with the cache.  */
+    long int ru_inblock;
+    /* Number of output operations via the file system.  */
+    long int ru_oublock;
+    /* Number of IPC messages sent.  */
+    long int ru_msgsnd;
+    /* Number of IPC messages received.  */
+    long int ru_msgrcv;
+    /* Number of signals delivered.  */
+    long int ru_nsignals;
+    /* Number of voluntary context switches, i.e. because the process
+       gave up the process before it had to (usually to wait for some
+       resource to be available).  */
+    long int ru_nvcsw;
+    /* Number of involuntary context switches, i.e. a higher priority process
+       became runnable or the current process used up its time slice.  */
+    long int ru_nivcsw;
+  };
+
+/* Priority limits.  */
+#define PRIO_MIN	-20	/* Minimum priority a process can have.  */
+#define PRIO_MAX	20	/* Maximum priority a process can have.  */
+
+/* The type of the WHICH argument to `getpriority' and `setpriority',
+   indicating what flavor of entity the WHO argument specifies.  */
+enum __priority_which
+{
+  PRIO_PROCESS = 0,		/* WHO is a process ID.  */
+#define PRIO_PROCESS PRIO_PROCESS
+  PRIO_PGRP = 1,		/* WHO is a process group ID.  */
+#define PRIO_PGRP PRIO_PGRP
+  PRIO_USER = 2			/* WHO is a user ID.  */
+#define PRIO_USER PRIO_USER
+};
--- libc/sysdeps/unix/sysv/linux/arm/Makefile.jj	Mon Jan 24 08:12:21 2000
+++ libc/sysdeps/unix/sysv/linux/arm/Makefile	Mon Jan 24 09:40:11 2000
@@ -10,5 +10,5 @@ sysdep_routines += rt_sigsuspend rt_sigp
 endif
 
 ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64 oldsetrlimit64
+sysdep_routines += oldgetrlimit64
 endif
--- libc/sysdeps/unix/sysv/linux/arm/Versions.jj	Thu Jan 13 10:47:56 2000
+++ libc/sysdeps/unix/sysv/linux/arm/Versions	Mon Jan 24 09:40:23 2000
@@ -6,6 +6,6 @@ libc {
   }
   GLIBC_2.1.3 {
     # New rlimit interface
-    getrlimit; setrlimit; getrlimit64; setrlimit64;
+    getrlimit; setrlimit; getrlimit64;
   }
 }
--- libc/sysdeps/unix/sysv/linux/arm/oldsetrlimit64.c.jj	Wed Jan 12 11:24:10 2000
+++ libc/sysdeps/unix/sysv/linux/arm/oldsetrlimit64.c	Mon Jan 24 09:40:34 2000
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/oldsetrlimit64.c>
--- libc/sysdeps/unix/sysv/linux/arm/setrlimit64.c.jj	Wed Jan 12 11:24:01 2000
+++ libc/sysdeps/unix/sysv/linux/arm/setrlimit64.c	Mon Jan 24 09:40:47 2000
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/setrlimit64.c>
--- libc/sysdeps/unix/sysv/linux/i386/Dist.jj	Thu Jan 13 10:47:56 2000
+++ libc/sysdeps/unix/sysv/linux/i386/Dist	Mon Jan 24 09:36:03 2000
@@ -1,6 +1,5 @@
 clone.S
 oldgetrlimit64.c
-oldsetrlimit64.c
 setresuid.c
 setresgid.c
 setfsuid.c
--- libc/sysdeps/unix/sysv/linux/i386/setrlimit64.c.jj	Mon Jan 24 09:24:57 2000
+++ libc/sysdeps/unix/sysv/linux/i386/setrlimit64.c	Mon Jan 24 09:33:29 2000
@@ -1,28 +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.  */
-
-#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
--- libc/sysdeps/unix/sysv/linux/i386/oldsetrlimit64.c.jj	Sat Dec 18 20:42:20 1999
+++ libc/sysdeps/unix/sysv/linux/i386/oldsetrlimit64.c	Mon Jan 24 09:06:23 2000
@@ -1,52 +0,0 @@
-/* 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 */
--- libc/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c.jj	Sat Dec 18 20:42:11 1999
+++ libc/sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c	Mon Jan 24 09:35:29 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995-1999, 2000 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
@@ -24,7 +24,7 @@
 #include <sys/resource.h>
 #include <sys/types.h>
 
-extern int __old_getrlimit (enum __rlimit_resource, struct rlimit *);
+extern int __new_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).  */
@@ -33,14 +33,14 @@ __old_getrlimit64 (enum __rlimit_resourc
 {
   struct rlimit rlimits32;
 
-  if (__old_getrlimit (resource, &rlimits32) < 0)
+  if (__new_getrlimit (resource, &rlimits32) < 0)
     return -1;
 
-  if (rlimits32.rlim_cur == RLIM_INFINITY >> 1)
+  if (rlimits32.rlim_cur == RLIM_INFINITY)
     rlimits->rlim_cur = RLIM64_INFINITY >> 1;
   else
     rlimits->rlim_cur = rlimits32.rlim_cur;
-  if (rlimits32.rlim_max == RLIM_INFINITY >> 1)
+  if (rlimits32.rlim_max == RLIM_INFINITY)
     rlimits->rlim_max = RLIM64_INFINITY >> 1;
   else
     rlimits->rlim_max = rlimits32.rlim_max;
--- libc/sysdeps/unix/sysv/linux/i386/Makefile.jj	Mon Jan 24 08:12:21 2000
+++ libc/sysdeps/unix/sysv/linux/i386/Makefile	Mon Jan 24 09:36:22 2000
@@ -13,5 +13,5 @@ CFLAGS-initfini.s += -DWEAK_GMON_START
 endif
 
 ifeq ($(subdir),resource)
-sysdep_routines += oldgetrlimit64 oldsetrlimit64
+sysdep_routines += oldgetrlimit64
 endif
--- libc/sysdeps/unix/sysv/linux/i386/Versions.jj	Fri Dec 10 15:15:34 1999
+++ libc/sysdeps/unix/sysv/linux/i386/Versions	Mon Jan 24 09:36:42 2000
@@ -9,6 +9,6 @@ libc {
   }
   GLIBC_2.1.3 {
     # New rlimit interface
-    getrlimit; setrlimit; getrlimit64; setrlimit64;
+    getrlimit; setrlimit; getrlimit64;
   }
 }
--- libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list.jj	Wed Jan 19 21:36:11 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list	Mon Jan 24 09:15:41 2000
@@ -9,7 +9,8 @@ s_setgid	setgid	setgid		1	__syscall_setg
 s_setgroups	setgroups setgroups	2	__syscall_setgroups
 s_setregid	setregid setregid	2	__syscall_setregid
 s_setreuid	setreuid setreuid	2	__syscall_setreuid
-s_setrlimit	setrlimit setrlimit	3	__syscall_setrlimit
+setrlimit	-	setrlimit	3	setrlimit
+getrlimit	-	getrlimit	2	__getrlimit	getrlimit
 s_ipc		msgget	ipc		5	__syscall_ipc
 s_setuid	setuid	setuid		1	__syscall_setuid
 setresuid	EXTRA	setresuid32	3	__setresuid	setresuid
@@ -32,7 +33,6 @@ s_getdents	getdents getdents	3	__syscall
 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_lstat64	lxstat64 lstat64	2	__syscall_lstat64
 s_mmap2		mmap64	mmap2		6	__syscall_mmap2
 s_poll		poll	poll		3	__syscall_poll
--- libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list.jj	Tue Dec 28 11:33:43 1999
+++ libc/sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list	Mon Jan 24 09:14:12 2000
@@ -51,7 +51,6 @@ s_ipc		msgget	ipc		5	__syscall_ipc
 s_poll		poll	poll		3	__syscall_poll
 s_ptrace	ptrace	ptrace		4	__syscall_ptrace
 s_reboot	reboot	reboot		3	__syscall_reboot
-s_setrlimit	setrlimit setrlimit	3	__syscall_setrlimit
 s_sigaction	sigaction sigaction	3	__syscall_sigaction
 s_sigpending	sigpending sigpending	1	__syscall_sigpending
 s_sigprocmask	sigprocmask sigprocmask	3	__syscall_sigprocmask

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.40 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]