]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/bits/resource.h
Update copyright notices with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / bits / resource.h
index cb3acf16228eadf9bde16e7b88a596af5b7eda7e..27207ce0adc1569e78caa21e628791a2168eb2cd 100644 (file)
@@ -1,6 +1,5 @@
 /* Bit values & structures for resource limits.  Linux version.
-   Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1994-2013 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
@@ -14,9 +13,8 @@
    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, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _SYS_RESOURCE_H
 # error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
@@ -100,7 +98,13 @@ enum __rlimit_resource
   __RLIMIT_RTPRIO = 14,
 #define RLIMIT_RTPRIO __RLIMIT_RTPRIO
 
-  __RLIMIT_NLIMITS = 15,
+  /* Maximum CPU time in µs that a process scheduled under a real-time
+     scheduling policy may consume without making a blocking system
+     call before being forcibly descheduled.  */
+  __RLIMIT_RTTIME = 15,
+#define RLIMIT_RTTIME __RLIMIT_RTTIME
+
+  __RLIMIT_NLIMITS = 16,
   __RLIM_NLIMITS = __RLIMIT_NLIMITS
 #define RLIMIT_NLIMITS __RLIMIT_NLIMITS
 #define RLIM_NLIMITS __RLIM_NLIMITS
@@ -108,7 +112,7 @@ enum __rlimit_resource
 
 /* Value to indicate that there is no limit.  */
 #ifndef __USE_FILE_OFFSET64
-# define RLIM_INFINITY ((unsigned long int)(~0UL))
+# define RLIM_INFINITY ((__rlim_t) -1)
 #else
 # define RLIM_INFINITY 0xffffffffffffffffuLL
 #endif
@@ -175,6 +179,11 @@ enum __rusage_who
 #include <bits/time.h>         /* For `struct timeval'.  */
 
 /* Structure which says how much of each resource has been used.  */
+
+/* The purpose of all the unions is to have the kernel-compatible layout
+   while keeping the API type as 'long int', and among machines where
+   __syscall_slong_t is not 'long int', this only does the right thing
+   for little-endian ones, like x32.  */
 struct rusage
   {
     /* Total amount of user time used.  */
@@ -182,39 +191,96 @@ struct rusage
     /* Total amount of system time used.  */
     struct timeval ru_stime;
     /* Maximum resident set size (in kilobytes).  */
-    long int ru_maxrss;
+    __extension__ union
+      {
+       long int ru_maxrss;
+       __syscall_slong_t __ru_maxrss_word;
+      };
     /* Amount of sharing of text segment memory
        with other processes (kilobyte-seconds).  */
-    long int ru_ixrss;
+    /* Maximum resident set size (in kilobytes).  */
+    __extension__ union
+      {
+       long int ru_ixrss;
+       __syscall_slong_t __ru_ixrss_word;
+      };
     /* Amount of data segment memory used (kilobyte-seconds).  */
-    long int ru_idrss;
+    __extension__ union
+      {
+       long int ru_idrss;
+       __syscall_slong_t __ru_idrss_word;
+      };
     /* Amount of stack memory used (kilobyte-seconds).  */
-    long int ru_isrss;
+    __extension__ union
+      {
+       long int ru_isrss;
+        __syscall_slong_t __ru_isrss_word;
+      };
     /* Number of soft page faults (i.e. those serviced by reclaiming
        a page from the list of pages awaiting reallocation.  */
-    long int ru_minflt;
+    __extension__ union
+      {
+       long int ru_minflt;
+       __syscall_slong_t __ru_minflt_word;
+      };
     /* Number of hard page faults (i.e. those that required I/O).  */
-    long int ru_majflt;
+    __extension__ union
+      {
+       long int ru_majflt;
+       __syscall_slong_t __ru_majflt_word;
+      };
     /* Number of times a process was swapped out of physical memory.  */
-    long int ru_nswap;
+    __extension__ union
+      {
+       long int ru_nswap;
+       __syscall_slong_t __ru_nswap_word;
+      };
     /* Number of input operations via the file system.  Note: This
        and `ru_oublock' do not include operations with the cache.  */
-    long int ru_inblock;
+    __extension__ union
+      {
+       long int ru_inblock;
+       __syscall_slong_t __ru_inblock_word;
+      };
     /* Number of output operations via the file system.  */
-    long int ru_oublock;
+    __extension__ union
+      {
+       long int ru_oublock;
+       __syscall_slong_t __ru_oublock_word;
+      };
     /* Number of IPC messages sent.  */
-    long int ru_msgsnd;
+    __extension__ union
+      {
+       long int ru_msgsnd;
+       __syscall_slong_t __ru_msgsnd_word;
+      };
     /* Number of IPC messages received.  */
-    long int ru_msgrcv;
+    __extension__ union
+      {
+       long int ru_msgrcv;
+       __syscall_slong_t __ru_msgrcv_word;
+      };
     /* Number of signals delivered.  */
-    long int ru_nsignals;
+    __extension__ union
+      {
+       long int ru_nsignals;
+       __syscall_slong_t __ru_nsignals_word;
+      };
     /* 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;
+    __extension__ union
+      {
+       long int ru_nvcsw;
+       __syscall_slong_t __ru_nvcsw_word;
+      };
     /* 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;
+    __extension__ union
+      {
+       long int ru_nivcsw;
+       __syscall_slong_t __ru_nivcsw_word;
+      };
   };
 
 /* Priority limits.  */
@@ -232,3 +298,31 @@ enum __priority_which
   PRIO_USER = 2                        /* WHO is a user ID.  */
 #define PRIO_USER PRIO_USER
 };
+
+
+__BEGIN_DECLS
+
+#ifdef __USE_GNU
+/* Modify and return resource limits of a process atomically.  */
+# ifndef __USE_FILE_OFFSET64
+extern int prlimit (__pid_t __pid, enum __rlimit_resource __resource,
+                   const struct rlimit *__new_limit,
+                   struct rlimit *__old_limit) __THROW;
+# else
+#  ifdef __REDIRECT_NTH
+extern int __REDIRECT_NTH (prlimit, (__pid_t __pid,
+                                    enum __rlimit_resource __resource,
+                                    const struct rlimit *__new_limit,
+                                    struct rlimit *__old_limit), prlimit64);
+#  else
+#   define prlimit prlimit64
+#  endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int prlimit64 (__pid_t __pid, enum __rlimit_resource __resource,
+                     const struct rlimit64 *__new_limit,
+                     struct rlimit64 *__old_limit) __THROW;
+# endif
+#endif
+
+__END_DECLS