1 | #ifndef _SYS_RESOURCE_H |
---|
2 | #define _SYS_RESOURCE_H |
---|
3 | |
---|
4 | #include <time.h> |
---|
5 | #include <sys/cdefs.h> |
---|
6 | |
---|
7 | __BEGIN_DECLS |
---|
8 | |
---|
9 | #define RUSAGE_SELF 0 |
---|
10 | #define RUSAGE_CHILDREN (-1) |
---|
11 | #define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ |
---|
12 | |
---|
13 | struct rusage { |
---|
14 | struct timeval ru_utime; /* user time used */ |
---|
15 | struct timeval ru_stime; /* system time used */ |
---|
16 | long ru_maxrss; /* maximum resident set size */ |
---|
17 | long ru_ixrss; /* integral shared memory size */ |
---|
18 | long ru_idrss; /* integral unshared data size */ |
---|
19 | long ru_isrss; /* integral unshared stack size */ |
---|
20 | long ru_minflt; /* page reclaims */ |
---|
21 | long ru_majflt; /* page faults */ |
---|
22 | long ru_nswap; /* swaps */ |
---|
23 | long ru_inblock; /* block input operations */ |
---|
24 | long ru_oublock; /* block output operations */ |
---|
25 | long ru_msgsnd; /* messages sent */ |
---|
26 | long ru_msgrcv; /* messages received */ |
---|
27 | long ru_nsignals; /* signals received */ |
---|
28 | long ru_nvcsw; /* voluntary context switches */ |
---|
29 | long ru_nivcsw; /* involuntary " */ |
---|
30 | }; |
---|
31 | |
---|
32 | struct rlimit { |
---|
33 | unsigned long rlim_cur; |
---|
34 | unsigned long rlim_max; |
---|
35 | }; |
---|
36 | |
---|
37 | #define PRIO_MIN (-20) |
---|
38 | #define PRIO_MAX 20 |
---|
39 | |
---|
40 | #define PRIO_PROCESS 0 |
---|
41 | #define PRIO_PGRP 1 |
---|
42 | #define PRIO_USER 2 |
---|
43 | |
---|
44 | #define RLIMIT_CPU 0 /* CPU time in ms */ |
---|
45 | #define RLIMIT_FSIZE 1 /* Maximum filesize */ |
---|
46 | #define RLIMIT_DATA 2 /* max data size */ |
---|
47 | #define RLIMIT_STACK 3 /* max stack size */ |
---|
48 | #define RLIMIT_CORE 4 /* max core file size */ |
---|
49 | #if defined(__alpha__) |
---|
50 | #define RLIMIT_RSS 5 /* max resident set size */ |
---|
51 | #define RLIMIT_NPROC 8 /* max number of processes */ |
---|
52 | #define RLIMIT_NOFILE 6 /* max number of open files */ |
---|
53 | #define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space */ |
---|
54 | #define RLIMIT_AS 7 /* address space limit */ |
---|
55 | #elif defined(__mips__) |
---|
56 | #define RLIMIT_RSS 7 /* max resident set size */ |
---|
57 | #define RLIMIT_NPROC 8 /* max number of processes */ |
---|
58 | #define RLIMIT_NOFILE 5 /* max number of open files */ |
---|
59 | #define RLIMIT_MEMLOCK 9 /* max locked-in-memory address space */ |
---|
60 | #define RLIMIT_AS 6 /* address space limit */ |
---|
61 | #elif defined(__sparc__) |
---|
62 | #define RLIMIT_RSS 5 /* max resident set size */ |
---|
63 | #define RLIMIT_NPROC 7 /* max number of processes */ |
---|
64 | #define RLIMIT_NOFILE 6 /* max number of open files */ |
---|
65 | #define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ |
---|
66 | #define RLIMIT_AS 9 /* address space limit */ |
---|
67 | #else |
---|
68 | #define RLIMIT_RSS 5 /* max resident set size */ |
---|
69 | #define RLIMIT_NPROC 6 /* max number of processes */ |
---|
70 | #define RLIMIT_NOFILE 7 /* max number of open files */ |
---|
71 | #define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ |
---|
72 | #define RLIMIT_AS 9 /* address space limit */ |
---|
73 | #endif |
---|
74 | #define RLIMIT_LOCKS 10 /* maximum file locks held */ |
---|
75 | #define RLIMIT_SIGPENDING 11 /* max number of pending signals */ |
---|
76 | #define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */ |
---|
77 | #define RLIMIT_NICE 13 /* max nice prio allowed to raise to |
---|
78 | 0-39 for nice level 19 .. -20 */ |
---|
79 | #define RLIMIT_RTPRIO 14 /* maximum realtime priority */ |
---|
80 | #define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */ |
---|
81 | #define RLIM_NLIMITS 16 |
---|
82 | |
---|
83 | #if defined(__alpha__) || defined(__mips__) || defined(__sparc__) |
---|
84 | #define RLIM_INFINITY ((long)(~0UL>>1)) |
---|
85 | #else |
---|
86 | #define RLIM_INFINITY (~0UL) |
---|
87 | #endif |
---|
88 | |
---|
89 | int getpriority(int which, int who) __THROW; |
---|
90 | int setpriority(int which, int who, int prio) __THROW; |
---|
91 | |
---|
92 | int getrlimit (int resource, struct rlimit *rlim); |
---|
93 | int getrusage (int who, struct rusage *usage); |
---|
94 | int setrlimit (int resource, const struct rlimit *rlim); |
---|
95 | |
---|
96 | typedef unsigned long rlim_t; |
---|
97 | |
---|
98 | __END_DECLS |
---|
99 | |
---|
100 | #endif |
---|