• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef	_SYS_RESOURCE_H
2 #define	_SYS_RESOURCE_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <features.h>
9 #include <sys/time.h>
10 
11 #define __NEED_id_t
12 
13 #ifdef _GNU_SOURCE
14 #define __NEED_pid_t
15 #endif
16 
17 #include <bits/alltypes.h>
18 #include <bits/resource.h>
19 
20 typedef unsigned long long rlim_t;
21 
22 struct rlimit {
23 	rlim_t rlim_cur;
24 	rlim_t rlim_max;
25 };
26 
27 struct rusage {
28 	struct timeval ru_utime;
29 	struct timeval ru_stime;
30 	/* linux extensions, 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 #define prlimit64 prlimit
59 #endif
60 
61 #define PRIO_MIN (-20)
62 #define PRIO_MAX 20
63 
64 #define PRIO_PROCESS 0
65 #define PRIO_PGRP    1
66 #define PRIO_USER    2
67 
68 #define RUSAGE_SELF     0
69 #define RUSAGE_CHILDREN (-1)
70 #define RUSAGE_THREAD   1
71 
72 #define RLIM_INFINITY (~0ULL)
73 #define RLIM_SAVED_CUR RLIM_INFINITY
74 #define RLIM_SAVED_MAX RLIM_INFINITY
75 
76 #define RLIMIT_CPU     0
77 #define RLIMIT_FSIZE   1
78 #define RLIMIT_DATA    2
79 #define RLIMIT_STACK   3
80 #define RLIMIT_CORE    4
81 #ifndef RLIMIT_RSS
82 #define RLIMIT_RSS     5
83 #define RLIMIT_NPROC   6
84 #define RLIMIT_NOFILE  7
85 #define RLIMIT_MEMLOCK 8
86 #define RLIMIT_AS      9
87 #endif
88 #define RLIMIT_LOCKS   10
89 #define RLIMIT_SIGPENDING 11
90 #define RLIMIT_MSGQUEUE 12
91 #define RLIMIT_NICE    13
92 #define RLIMIT_RTPRIO  14
93 #define RLIMIT_RTTIME  15
94 #define RLIMIT_NLIMITS 16
95 
96 #define RLIM_NLIMITS RLIMIT_NLIMITS
97 
98 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
99 #define RLIM64_INFINITY RLIM_INFINITY
100 #define RLIM64_SAVED_CUR RLIM_SAVED_CUR
101 #define RLIM64_SAVED_MAX RLIM_SAVED_MAX
102 #define getrlimit64 getrlimit
103 #define setrlimit64 setrlimit
104 #define rlimit64 rlimit
105 #define rlim64_t rlim_t
106 #endif
107 
108 #if _REDIR_TIME64
109 __REDIR(getrusage, __getrusage_time64);
110 #endif
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif
117