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