about summary refs log tree commit diff
path: root/REORG.TODO/resource
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/resource')
-rw-r--r--REORG.TODO/resource/Makefile30
-rw-r--r--REORG.TODO/resource/Versions28
-rw-r--r--REORG.TODO/resource/bug-ulimit1.c21
-rw-r--r--REORG.TODO/resource/getpriority.c34
-rw-r--r--REORG.TODO/resource/getrlimit.c33
-rw-r--r--REORG.TODO/resource/getrlimit64.c45
-rw-r--r--REORG.TODO/resource/getrusage.c31
-rw-r--r--REORG.TODO/resource/nice.c30
-rw-r--r--REORG.TODO/resource/setpriority.c32
-rw-r--r--REORG.TODO/resource/setrlimit.c34
-rw-r--r--REORG.TODO/resource/setrlimit64.c40
-rw-r--r--REORG.TODO/resource/sys/resource.h102
-rw-r--r--REORG.TODO/resource/sys/vlimit.h67
-rw-r--r--REORG.TODO/resource/sys/vtimes.h68
-rw-r--r--REORG.TODO/resource/tst-getrlimit.c112
-rw-r--r--REORG.TODO/resource/ulimit.c37
-rw-r--r--REORG.TODO/resource/ulimit.h47
-rw-r--r--REORG.TODO/resource/vlimit.c48
-rw-r--r--REORG.TODO/resource/vtimes.c62
19 files changed, 901 insertions, 0 deletions
diff --git a/REORG.TODO/resource/Makefile b/REORG.TODO/resource/Makefile
new file mode 100644
index 0000000000..8235770737
--- /dev/null
+++ b/REORG.TODO/resource/Makefile
@@ -0,0 +1,30 @@
+# Copyright (C) 1991-2017 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
+# <http://www.gnu.org/licenses/>.
+
+subdir := resource
+
+include ../Makeconfig
+
+headers	  := sys/resource.h bits/resource.h sys/vlimit.h sys/vtimes.h	\
+	     ulimit.h
+
+routines := getrlimit setrlimit getrlimit64 setrlimit64 getrusage ulimit      \
+	    vlimit vtimes getpriority setpriority nice
+
+tests = tst-getrlimit bug-ulimit1
+
+include ../Rules
diff --git a/REORG.TODO/resource/Versions b/REORG.TODO/resource/Versions
new file mode 100644
index 0000000000..d6c2ccee1b
--- /dev/null
+++ b/REORG.TODO/resource/Versions
@@ -0,0 +1,28 @@
+libc {
+  GLIBC_2.0 {
+    # g*
+    getpriority; getrlimit; getrusage;
+
+    # n*
+    nice;
+
+    # s*
+    setpriority; setrlimit;
+
+    # u*
+    ulimit;
+
+    # v*
+    vlimit; vtimes;
+  }
+  GLIBC_2.1 {
+    # g*
+    getrlimit64;
+
+    # s*
+    setrlimit64;
+  }
+  GLIBC_PRIVATE {
+    __getrlimit;
+  }
+}
diff --git a/REORG.TODO/resource/bug-ulimit1.c b/REORG.TODO/resource/bug-ulimit1.c
new file mode 100644
index 0000000000..334d7fff04
--- /dev/null
+++ b/REORG.TODO/resource/bug-ulimit1.c
@@ -0,0 +1,21 @@
+#include <ulimit.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+  int retval = 0;
+  long int res;
+
+  res = ulimit (UL_SETFSIZE, 10000);
+  printf ("Result of ulimit (UL_SETFSIZE, 10000): %ld\n", res);
+  if (res != 10000)
+    retval = 1;
+
+  res = ulimit (UL_GETFSIZE);
+  printf ("Result of ulimit(UL_GETFSIZE): %ld\n", res);
+  if (res != 10000)
+    retval = 1;
+
+  return retval;
+}
diff --git a/REORG.TODO/resource/getpriority.c b/REORG.TODO/resource/getpriority.c
new file mode 100644
index 0000000000..f198608051
--- /dev/null
+++ b/REORG.TODO/resource/getpriority.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+
+/* Return the highest priority of any process specified by WHICH and WHO
+   (see <sys/resource.h>); if WHO is zero, the current process, process group,
+   or user (as specified by WHO) is used.  A lower priority number means higher
+   priority.  Priorities range from PRIO_MIN to PRIO_MAX.  */
+int
+__getpriority (enum __priority_which which, id_t who)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+libc_hidden_def (__getpriority)
+weak_alias (__getpriority, getpriority)
+
+stub_warning (getpriority)
diff --git a/REORG.TODO/resource/getrlimit.c b/REORG.TODO/resource/getrlimit.c
new file mode 100644
index 0000000000..fe1d8562ab
--- /dev/null
+++ b/REORG.TODO/resource/getrlimit.c
@@ -0,0 +1,33 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+/* Put the soft and hard limits for RESOURCE in *RLIMITS.
+   Returns 0 if successful, -1 if not (and sets errno).  */
+int
+__getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+libc_hidden_def (__getrlimit)
+weak_alias (__getrlimit, getrlimit)
+
+stub_warning (getrlimit)
diff --git a/REORG.TODO/resource/getrlimit64.c b/REORG.TODO/resource/getrlimit64.c
new file mode 100644
index 0000000000..705945bf5f
--- /dev/null
+++ b/REORG.TODO/resource/getrlimit64.c
@@ -0,0 +1,45 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+/* Put the soft and hard limits for RESOURCE in *RLIMITS.
+   Returns 0 if successful, -1 if not (and sets errno).  */
+int
+__getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
+{
+  struct rlimit rlimits32;
+
+  if (__getrlimit (resource, &rlimits32) < 0)
+    return -1;
+
+  if (rlimits32.rlim_cur == RLIM_INFINITY)
+    rlimits->rlim_cur = RLIM64_INFINITY;
+  else
+    rlimits->rlim_cur = rlimits32.rlim_cur;
+  if (rlimits32.rlim_max == RLIM_INFINITY)
+    rlimits->rlim_max = RLIM64_INFINITY;
+  else
+    rlimits->rlim_max = rlimits32.rlim_max;
+
+  return 0;
+}
+libc_hidden_def (__getrlimit64)
+weak_alias (__getrlimit64, getrlimit64)
+libc_hidden_weak (getrlimit64)
diff --git a/REORG.TODO/resource/getrusage.c b/REORG.TODO/resource/getrusage.c
new file mode 100644
index 0000000000..0f7fdd6843
--- /dev/null
+++ b/REORG.TODO/resource/getrusage.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Return resource usage information on process indicated by WHO
+   and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
+int
+__getrusage (enum __rusage_who who, struct rusage *usage)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (getrusage)
+
+weak_alias (__getrusage, getrusage)
diff --git a/REORG.TODO/resource/nice.c b/REORG.TODO/resource/nice.c
new file mode 100644
index 0000000000..773be298ba
--- /dev/null
+++ b/REORG.TODO/resource/nice.c
@@ -0,0 +1,30 @@
+/* Copyright (C) 1992-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Increment the scheduling priority of the calling process by INCR.
+   The superuser may use a negative INCR to decrement the priority.  */
+int
+nice (int incr)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (nice)
diff --git a/REORG.TODO/resource/setpriority.c b/REORG.TODO/resource/setpriority.c
new file mode 100644
index 0000000000..69c17d1e3f
--- /dev/null
+++ b/REORG.TODO/resource/setpriority.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+
+/* Set the priority of all processes specified by WHICH and WHO
+   to PRIO.  Returns 0 on success, -1 on errors.  */
+int
+__setpriority (enum __priority_which which, id_t who, int prio)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+libc_hidden_def (__setpriority)
+weak_alias (__setpriority, setpriority)
+
+stub_warning (setpriority)
diff --git a/REORG.TODO/resource/setrlimit.c b/REORG.TODO/resource/setrlimit.c
new file mode 100644
index 0000000000..6e3a1fbc54
--- /dev/null
+++ b/REORG.TODO/resource/setrlimit.c
@@ -0,0 +1,34 @@
+/* Set process resource limits.  Stub version.
+   Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+/* 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
+__setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+weak_alias (__setrlimit, setrlimit)
+
+stub_warning (setrlimit)
diff --git a/REORG.TODO/resource/setrlimit64.c b/REORG.TODO/resource/setrlimit64.c
new file mode 100644
index 0000000000..810a240129
--- /dev/null
+++ b/REORG.TODO/resource/setrlimit64.c
@@ -0,0 +1,40 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+
+/* 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
+setrlimit64 (enum __rlimit_resource resource, const struct rlimit64 *rlimits)
+{
+  struct rlimit rlimits32;
+
+  if (rlimits->rlim_cur >= RLIM_INFINITY)
+    rlimits32.rlim_cur = RLIM_INFINITY;
+  else
+    rlimits32.rlim_cur = rlimits->rlim_cur;
+  if (rlimits->rlim_max >= RLIM_INFINITY)
+    rlimits32.rlim_max = RLIM_INFINITY;
+  else
+    rlimits32.rlim_max = rlimits->rlim_max;
+
+  return __setrlimit (resource, &rlimits32);
+}
diff --git a/REORG.TODO/resource/sys/resource.h b/REORG.TODO/resource/sys/resource.h
new file mode 100644
index 0000000000..423ac62a34
--- /dev/null
+++ b/REORG.TODO/resource/sys/resource.h
@@ -0,0 +1,102 @@
+/* Copyright (C) 1992-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef	_SYS_RESOURCE_H
+#define	_SYS_RESOURCE_H	1
+
+#include <features.h>
+
+/* Get the system-dependent definitions of structures and bit values.  */
+#include <bits/resource.h>
+
+#ifndef __id_t_defined
+typedef __id_t id_t;
+# define __id_t_defined
+#endif
+
+__BEGIN_DECLS
+
+/* The X/Open standard defines that all the functions below must use
+   `int' as the type for the first argument.  When we are compiling with
+   GNU extensions we change this slightly to provide better error
+   checking.  */
+#if defined __USE_GNU && !defined __cplusplus
+typedef enum __rlimit_resource __rlimit_resource_t;
+typedef enum __rusage_who __rusage_who_t;
+typedef enum __priority_which __priority_which_t;
+#else
+typedef int __rlimit_resource_t;
+typedef int __rusage_who_t;
+typedef int __priority_which_t;
+#endif
+
+/* Put the soft and hard limits for RESOURCE in *RLIMITS.
+   Returns 0 if successful, -1 if not (and sets errno).  */
+#ifndef __USE_FILE_OFFSET64
+extern int getrlimit (__rlimit_resource_t __resource,
+		      struct rlimit *__rlimits) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource,
+				       struct rlimit *__rlimits), getrlimit64);
+# else
+#  define getrlimit getrlimit64
+# endif
+#endif
+#ifdef __USE_LARGEFILE64
+extern int getrlimit64 (__rlimit_resource_t __resource,
+			struct rlimit64 *__rlimits) __THROW;
+#endif
+
+/* 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).  */
+#ifndef __USE_FILE_OFFSET64
+extern int setrlimit (__rlimit_resource_t __resource,
+		      const struct rlimit *__rlimits) __THROW;
+#else
+# ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
+				       const struct rlimit *__rlimits),
+			   setrlimit64);
+# else
+#  define setrlimit setrlimit64
+# endif
+#endif
+#ifdef __USE_LARGEFILE64
+extern int setrlimit64 (__rlimit_resource_t __resource,
+			const struct rlimit64 *__rlimits) __THROW;
+#endif
+
+/* Return resource usage information on process indicated by WHO
+   and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
+extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
+
+/* Return the highest priority of any process specified by WHICH and WHO
+   (see above); if WHO is zero, the current process, process group, or user
+   (as specified by WHO) is used.  A lower priority number means higher
+   priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */
+extern int getpriority (__priority_which_t __which, id_t __who) __THROW;
+
+/* Set the priority of all processes specified by WHICH and WHO (see above)
+   to PRIO.  Returns 0 on success, -1 on errors.  */
+extern int setpriority (__priority_which_t __which, id_t __who, int __prio)
+     __THROW;
+
+__END_DECLS
+
+#endif	/* sys/resource.h  */
diff --git a/REORG.TODO/resource/sys/vlimit.h b/REORG.TODO/resource/sys/vlimit.h
new file mode 100644
index 0000000000..93912c67a1
--- /dev/null
+++ b/REORG.TODO/resource/sys/vlimit.h
@@ -0,0 +1,67 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_VLIMIT_H
+#define _SYS_VLIMIT_H	1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* This interface is obsolete, and is superseded by <sys/resource.h>.  */
+
+/* Kinds of resource limit.  */
+enum __vlimit_resource
+{
+  /* Setting this non-zero makes it impossible to raise limits.
+     Only the super-use can set it to zero.
+
+     This is not implemented in recent versions of BSD, nor by
+     the GNU C library.  */
+  LIM_NORAISE,
+
+  /* CPU time available for each process (seconds).  */
+  LIM_CPU,
+
+  /* Largest file which can be created (bytes).  */
+  LIM_FSIZE,
+
+  /* Maximum size of the data segment (bytes).  */
+  LIM_DATA,
+
+  /* Maximum size of the stack segment (bytes).  */
+  LIM_STACK,
+
+  /* Largest core file that will be created (bytes).  */
+  LIM_CORE,
+
+  /* Resident set size (bytes).  */
+  LIM_MAXRSS
+};
+
+/* This means no limit.  */
+#define INFINITY 0x7fffffff
+
+
+/* Set the soft limit for RESOURCE to be VALUE.
+   Returns 0 for success, -1 for failure.  */
+extern int vlimit (enum __vlimit_resource __resource, int __value) __THROW;
+
+
+__END_DECLS
+
+#endif /* sys/vlimit.h  */
diff --git a/REORG.TODO/resource/sys/vtimes.h b/REORG.TODO/resource/sys/vtimes.h
new file mode 100644
index 0000000000..455ce979b1
--- /dev/null
+++ b/REORG.TODO/resource/sys/vtimes.h
@@ -0,0 +1,68 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_VTIMES_H
+#define _SYS_VTIMES_H	1
+
+#include <features.h>
+
+__BEGIN_DECLS
+
+/* This interface is obsolete; use `getrusage' instead.  */
+
+/* Granularity of the `vm_utime' and `vm_stime' fields of a `struct vtimes'.
+   (This is the frequency of the machine's power supply, in Hz.)  */
+#define	VTIMES_UNITS_PER_SECOND	60
+
+struct vtimes
+{
+  /* User time used in units of 1/VTIMES_UNITS_PER_SECOND seconds.  */
+  int vm_utime;
+  /* System time used in units of 1/VTIMES_UNITS_PER_SECOND seconds.  */
+  int vm_stime;
+
+  /* Amount of data and stack memory used (kilobyte-seconds).  */
+  unsigned int vm_idsrss;
+  /* Amount of text memory used (kilobyte-seconds).  */
+  unsigned int vm_ixrss;
+  /* Maximum resident set size (text, data, and stack) (kilobytes).  */
+  int vm_maxrss;
+
+  /* Number of hard page faults (i.e. those that required I/O).  */
+  int vm_majflt;
+  /* Number of soft page faults (i.e. those serviced by reclaiming
+     a page from the list of pages awaiting reallocation.  */
+  int vm_minflt;
+
+  /* Number of times a process was swapped out of physical memory.  */
+  int vm_nswap;
+
+  /* Number of input operations via the file system.  Note: This
+     and `ru_oublock' do not include operations with the cache.  */
+  int vm_inblk;
+  /* Number of output operations via the file system.  */
+  int vm_oublk;
+};
+
+/* If CURRENT is not NULL, write statistics for the current process into
+   *CURRENT.  If CHILD is not NULL, write statistics for all terminated child
+   processes into *CHILD.  Returns 0 for success, -1 for failure.  */
+extern int vtimes (struct vtimes * __current, struct vtimes * __child) __THROW;
+
+__END_DECLS
+
+#endif /* sys/vtimes.h  */
diff --git a/REORG.TODO/resource/tst-getrlimit.c b/REORG.TODO/resource/tst-getrlimit.c
new file mode 100644
index 0000000000..67480340f0
--- /dev/null
+++ b/REORG.TODO/resource/tst-getrlimit.c
@@ -0,0 +1,112 @@
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/resource.h>
+
+
+static struct
+{
+  const char *name;
+  int resource;
+  bool required;
+} tests[] =
+  {
+    /* The following 7 limits are part of POSIX and must exist.  */
+    { "RLIMIT_CORE", RLIMIT_CORE, true },
+    { "RLIMIT_CPU", RLIMIT_CPU, true },
+    { "RLIMIT_DATA", RLIMIT_DATA, true },
+    { "RLIMIT_FSIZE", RLIMIT_FSIZE, true },
+    { "RLIMIT_NOFILE", RLIMIT_NOFILE, true },
+    { "RLIMIT_STACK", RLIMIT_STACK, true },
+    { "RLIMIT_AS", RLIMIT_AS, true },
+    /* The following are traditional Unix limits which are also
+       expected (by us).  */
+    { "RLIMIT_RSS", RLIMIT_RSS, true },
+    { "RLIMIT_NPROC", RLIMIT_NPROC, true },
+    /* The following are extensions.  */
+#ifdef RLIMIT_MEMLOCK
+    { "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK, false },
+#endif
+#ifdef RLIMIT_LOCKS
+    { "RLIMIT_LOCKS", RLIMIT_LOCKS, false },
+#endif
+#ifdef RLIMIT_SIGPENDING
+    { "RLIMIT_SIGPENDING", RLIMIT_SIGPENDING, false },
+#endif
+#ifdef RLIMIT_MSGQUEUE
+    { "RLIMIT_MSGQUEUE", RLIMIT_MSGQUEUE, false },
+#endif
+#ifdef RLIMIT_NICE
+    { "RLIMIT_NICE", RLIMIT_NICE, false },
+#endif
+#ifdef RLIMIT_RTPRIO
+    { "RLIMIT_RTPRIO", RLIMIT_RTPRIO, false },
+#endif
+  };
+#define ntests (sizeof (tests) / sizeof (tests[0]))
+
+
+static int
+do_test (void)
+{
+  int status = 0;
+
+  for (int i = 0; i < ntests; ++i)
+    {
+      bool this_ok = true;
+
+      struct rlimit r;
+      int res = getrlimit (tests[i].resource, &r);
+      if (res == -1)
+	{
+	  if (errno == EINVAL)
+	    {
+	      if (tests[i].required)
+		{
+		  printf ("limit %s expectedly not available for getrlimit\n",
+			  tests[i].name);
+		  status = 1;
+		  this_ok = false;
+		}
+	    }
+	  else
+	    {
+	      printf ("getrlimit for %s returned unexpected error: %m\n",
+		      tests[i].name);
+	      status = 1;
+	      this_ok = false;
+	    }
+	}
+
+      struct rlimit64 r64;
+      res = getrlimit64 (tests[i].resource, &r64);
+      if (res == -1)
+	{
+	  if (errno == EINVAL)
+	    {
+	      if (tests[i].required)
+		{
+		  printf ("limit %s expectedly not available for getrlimit64"
+			  "\n", tests[i].name);
+		  status = 1;
+		  this_ok = false;
+		}
+	    }
+	  else
+	    {
+	      printf ("getrlimit64 for %s returned unexpected error: %m\n",
+		      tests[i].name);
+	      status = 1;
+	      this_ok = false;
+	    }
+	}
+
+      if (this_ok)
+	printf ("limit %s OK\n", tests[i].name);
+    }
+
+  return status;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/REORG.TODO/resource/ulimit.c b/REORG.TODO/resource/ulimit.c
new file mode 100644
index 0000000000..c07f2d4914
--- /dev/null
+++ b/REORG.TODO/resource/ulimit.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <sys/resource.h>
+
+/* Function depends on CMD:
+   1 = Return the limit on the size of a file, in units of 512 bytes.
+   2 = Set the limit on the size of a file to NEWLIMIT.  Only the
+       super-user can increase the limit.
+   3 = Return the maximum possible address of the data segment.
+   4 = Return the maximum number of files that the calling process
+       can open.
+   Returns -1 on errors.  */
+long int
+__ulimit (int cmd, ...)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+weak_alias (__ulimit, ulimit)
+
+stub_warning (ulimit)
diff --git a/REORG.TODO/resource/ulimit.h b/REORG.TODO/resource/ulimit.h
new file mode 100644
index 0000000000..8af59d0dad
--- /dev/null
+++ b/REORG.TODO/resource/ulimit.h
@@ -0,0 +1,47 @@
+/* Copyright (C) 1997-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _ULIMIT_H
+#define _ULIMIT_H	1
+
+#include <features.h>
+
+/* Constants used as the first parameter for `ulimit'.  They denote limits
+   which can be set or retrieved using this function.  */
+enum
+{
+  UL_GETFSIZE = 1,			/* Return limit on the size of a file,
+					   in units of 512 bytes.  */
+#define UL_GETFSIZE	UL_GETFSIZE
+  UL_SETFSIZE,				/* Set limit on the size of a file to
+					   second argument.  */
+#define UL_SETFSIZE	UL_SETFSIZE
+  __UL_GETMAXBRK,			/* Return the maximum possible address
+					   of the data segment.  */
+  __UL_GETOPENMAX			/* Return the maximum number of files
+					   that the calling process can open.*/
+};
+
+
+__BEGIN_DECLS
+
+/* Control process limits according to CMD.  */
+extern long int ulimit (int __cmd, ...) __THROW;
+
+__END_DECLS
+
+#endif /* ulimit.h */
diff --git a/REORG.TODO/resource/vlimit.c b/REORG.TODO/resource/vlimit.c
new file mode 100644
index 0000000000..69f5efb829
--- /dev/null
+++ b/REORG.TODO/resource/vlimit.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This is generic in the sense that it will work with the BSD, SYSV,
+   or stub versions of getrlimit.  Separate versions could be written
+   for efficiency, but it's probably not worth it.  */
+
+#include <sys/vlimit.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* Set the soft limit for RESOURCE to be VALUE.
+   Returns 0 for success, -1 for failure.  */
+int
+vlimit (enum __vlimit_resource resource, int value)
+{
+  if (resource >= LIM_CPU && resource <= LIM_MAXRSS)
+    {
+      /* The rlimit codes happen to each be one less
+	 than the corresponding vlimit codes.  */
+      enum __rlimit_resource rlimit_res =
+	(enum __rlimit_resource) ((int) resource - 1);
+      struct rlimit lims;
+
+      if (__getrlimit (rlimit_res, &lims) < 0)
+	return -1;
+
+      lims.rlim_cur = value;
+      return __setrlimit (rlimit_res, &lims);
+    }
+
+  __set_errno (EINVAL);
+  return -1;
+}
diff --git a/REORG.TODO/resource/vtimes.c b/REORG.TODO/resource/vtimes.c
new file mode 100644
index 0000000000..20aae81228
--- /dev/null
+++ b/REORG.TODO/resource/vtimes.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 1991-2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+#include <sys/vtimes.h>
+#include <sys/resource.h>
+
+/* Return the number of 1/VTIMES_UNITS_PER_SECOND-second
+   units in the `struct timeval' TV.  */
+#define TIMEVAL_TO_VTIMES(tv) \
+  ((tv.tv_sec * VTIMES_UNITS_PER_SECOND) + \
+   (tv.tv_usec * VTIMES_UNITS_PER_SECOND / 1000000))
+
+/* If VT is not NULL, write statistics for WHO into *VT.
+   Return 0 for success, -1 for failure.  */
+static int
+vtimes_one (struct vtimes *vt, enum __rusage_who who)
+{
+  if (vt != NULL)
+    {
+      struct rusage usage;
+
+      if (__getrusage (who, &usage) < 0)
+	return -1;
+
+      vt->vm_utime = TIMEVAL_TO_VTIMES (usage.ru_utime);
+      vt->vm_stime = TIMEVAL_TO_VTIMES (usage.ru_stime);
+      vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss;
+      vt->vm_majflt = usage.ru_majflt;
+      vt->vm_minflt = usage.ru_minflt;
+      vt->vm_nswap = usage.ru_nswap;
+      vt->vm_inblk = usage.ru_inblock;
+      vt->vm_oublk = usage.ru_oublock;
+    }
+  return 0;
+}
+
+/* If CURRENT is not NULL, write statistics for the current process into
+   *CURRENT.  If CHILD is not NULL, write statistics for all terminated child
+   processes into *CHILD.  Returns 0 for success, -1 for failure.  */
+int
+vtimes (struct vtimes *current, struct vtimes *child)
+{
+  if (vtimes_one (current, RUSAGE_SELF) < 0
+      || vtimes_one (child, RUSAGE_CHILDREN) < 0)
+    return -1;
+  return 0;
+}