add prlimit syscall wrapper
[musl] / include / sys / resource.h
1 #ifndef _SYS_RESOURCE_H
2 #define _SYS_RESOURCE_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #define __NEED_id_t
9 #define __NEED_time_t
10 #define __NEED_struct_timeval
11
12 #ifdef _GNU_SOURCE
13 #define __NEED_pid_t
14 #endif
15
16 #include <bits/alltypes.h>
17
18 typedef unsigned long long rlim_t;
19
20 struct rlimit
21 {
22         rlim_t rlim_cur;
23         rlim_t rlim_max;
24 };
25
26 struct rusage
27 {
28         struct timeval ru_utime;
29         struct timeval ru_stime;
30         /* linux extentions, but useful */
31         long    ru_maxrss;
32         long    ru_ixrss;
33         long    ru_idrss;
34         long    ru_isrss;
35         long    ru_minflt;
36         long    ru_majflt;
37         long    ru_nswap;
38         long    ru_inblock;
39         long    ru_oublock;
40         long    ru_msgsnd;
41         long    ru_msgrcv;
42         long    ru_nsignals;
43         long    ru_nvcsw;
44         long    ru_nivcsw;
45         /* room for more... */
46         long    __reserved[16];
47 };
48
49 int getrlimit (int, struct rlimit *);
50 int setrlimit (int, const struct rlimit *);
51 int getrusage (int, struct rusage *);
52
53 int getpriority (int, id_t);
54 int setpriority (int, id_t, int);
55
56 #ifdef _GNU_SOURCE
57 int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
58 #endif
59
60 #define PRIO_PROCESS 0
61 #define PRIO_PGRP    1
62 #define PRIO_USER    2
63
64 #define RUSAGE_SELF     0
65 #define RUSAGE_CHILDREN 1
66
67 #define RLIM_INFINITY (~0ULL)
68 #define RLIM_SAVED_CUR RLIM_INFINITY
69 #define RLIM_SAVED_MAX RLIM_INFINITY
70
71 #define RLIMIT_CPU     0
72 #define RLIMIT_FSIZE   1
73 #define RLIMIT_DATA    2
74 #define RLIMIT_STACK   3
75 #define RLIMIT_CORE    4
76 #define RLIMIT_RSS     5
77 #define RLIMIT_NOFILE  7
78 #define RLIMIT_AS      9
79 #define RLIMIT_NPROC   6
80 #define RLIMIT_MEMLOCK 8
81 #define RLIMIT_LOCKS   10
82 #define RLIMIT_SIGPENDING 11
83 #define RLIMIT_MSGQUEUE 12
84 #define RLIMIT_NICE    13
85 #define RLIMIT_RTPRIO  14
86 #define RLIMIT_NLIMITS 15
87
88 #define RLIM_NLIMITS RLIMIT_NLIMITS
89
90
91 #ifdef __cplusplus
92 }
93 #endif
94
95 #endif