Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 1 | #ifndef _SYS_RESOURCE_H |
| 2 | #define _SYS_RESOURCE_H |
| 3 | |
Rich Felker | 3ed8c9f | 2011-11-10 20:40:06 -0500 | [diff] [blame] | 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
Rich Felker | c1a9658 | 2012-09-07 23:13:55 -0400 | [diff] [blame] | 8 | #include <features.h> |
Rich Felker | 9448b05 | 2013-07-22 11:22:36 -0400 | [diff] [blame] | 9 | #include <sys/time.h> |
Rich Felker | c1a9658 | 2012-09-07 23:13:55 -0400 | [diff] [blame] | 10 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 11 | #define __NEED_id_t |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 12 | |
Rich Felker | 26f3832 | 2012-01-20 22:10:47 -0500 | [diff] [blame] | 13 | #ifdef _GNU_SOURCE |
| 14 | #define __NEED_pid_t |
| 15 | #endif |
| 16 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 17 | #include <bits/alltypes.h> |
Szabolcs Nagy | fcea534 | 2014-04-14 17:42:49 +0200 | [diff] [blame^] | 18 | #include <bits/resource.h> |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 19 | |
| 20 | typedef unsigned long long rlim_t; |
| 21 | |
| 22 | struct rlimit |
| 23 | { |
| 24 | rlim_t rlim_cur; |
| 25 | rlim_t rlim_max; |
| 26 | }; |
| 27 | |
| 28 | struct rusage |
| 29 | { |
| 30 | struct timeval ru_utime; |
| 31 | struct timeval ru_stime; |
| 32 | /* linux extentions, but useful */ |
| 33 | long ru_maxrss; |
| 34 | long ru_ixrss; |
| 35 | long ru_idrss; |
| 36 | long ru_isrss; |
| 37 | long ru_minflt; |
| 38 | long ru_majflt; |
| 39 | long ru_nswap; |
| 40 | long ru_inblock; |
| 41 | long ru_oublock; |
| 42 | long ru_msgsnd; |
| 43 | long ru_msgrcv; |
| 44 | long ru_nsignals; |
| 45 | long ru_nvcsw; |
| 46 | long ru_nivcsw; |
| 47 | /* room for more... */ |
| 48 | long __reserved[16]; |
| 49 | }; |
| 50 | |
| 51 | int getrlimit (int, struct rlimit *); |
| 52 | int setrlimit (int, const struct rlimit *); |
| 53 | int getrusage (int, struct rusage *); |
| 54 | |
| 55 | int getpriority (int, id_t); |
| 56 | int setpriority (int, id_t, int); |
| 57 | |
Rich Felker | 26f3832 | 2012-01-20 22:10:47 -0500 | [diff] [blame] | 58 | #ifdef _GNU_SOURCE |
| 59 | int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); |
Rich Felker | f600105 | 2012-09-21 04:05:01 -0400 | [diff] [blame] | 60 | #define prlimit64 prlimit |
Rich Felker | 26f3832 | 2012-01-20 22:10:47 -0500 | [diff] [blame] | 61 | #endif |
| 62 | |
Szabolcs Nagy | 90710df | 2013-09-15 15:32:07 +0000 | [diff] [blame] | 63 | #define PRIO_MIN (-20) |
| 64 | #define PRIO_MAX 20 |
| 65 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 66 | #define PRIO_PROCESS 0 |
| 67 | #define PRIO_PGRP 1 |
| 68 | #define PRIO_USER 2 |
| 69 | |
| 70 | #define RUSAGE_SELF 0 |
| 71 | #define RUSAGE_CHILDREN 1 |
| 72 | |
| 73 | #define RLIM_INFINITY (~0ULL) |
| 74 | #define RLIM_SAVED_CUR RLIM_INFINITY |
| 75 | #define RLIM_SAVED_MAX RLIM_INFINITY |
| 76 | |
| 77 | #define RLIMIT_CPU 0 |
| 78 | #define RLIMIT_FSIZE 1 |
| 79 | #define RLIMIT_DATA 2 |
| 80 | #define RLIMIT_STACK 3 |
| 81 | #define RLIMIT_CORE 4 |
Szabolcs Nagy | fcea534 | 2014-04-14 17:42:49 +0200 | [diff] [blame^] | 82 | #ifndef RLIMIT_RSS |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 83 | #define RLIMIT_RSS 5 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 84 | #define RLIMIT_NPROC 6 |
Szabolcs Nagy | fcea534 | 2014-04-14 17:42:49 +0200 | [diff] [blame^] | 85 | #define RLIMIT_NOFILE 7 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 86 | #define RLIMIT_MEMLOCK 8 |
Szabolcs Nagy | fcea534 | 2014-04-14 17:42:49 +0200 | [diff] [blame^] | 87 | #define RLIMIT_AS 9 |
| 88 | #endif |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 89 | #define RLIMIT_LOCKS 10 |
Rich Felker | 209f2bb | 2011-04-12 11:50:14 -0400 | [diff] [blame] | 90 | #define RLIMIT_SIGPENDING 11 |
| 91 | #define RLIMIT_MSGQUEUE 12 |
| 92 | #define RLIMIT_NICE 13 |
| 93 | #define RLIMIT_RTPRIO 14 |
| 94 | #define RLIMIT_NLIMITS 15 |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 95 | |
Rich Felker | 45a3219 | 2011-04-13 13:22:19 -0400 | [diff] [blame] | 96 | #define RLIM_NLIMITS RLIMIT_NLIMITS |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 97 | |
Rich Felker | 3b94dab | 2012-06-04 08:03:56 -0400 | [diff] [blame] | 98 | #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
Rich Felker | f0b85fd | 2012-05-04 00:31:25 -0400 | [diff] [blame] | 99 | #define getrlimit64 getrlimit |
| 100 | #define setrlimit64 setrlimit |
| 101 | #define rlimit64 rlimit |
| 102 | #define rlim64_t rlim_t |
| 103 | #endif |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 104 | |
Rich Felker | 3ed8c9f | 2011-11-10 20:40:06 -0500 | [diff] [blame] | 105 | #ifdef __cplusplus |
| 106 | } |
| 107 | #endif |
| 108 | |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 109 | #endif |