xref: /haiku/headers/posix/sys/resource.h (revision 4f00613311d0bd6b70fa82ce19931c41f071ea4e)
1 #ifndef _SYS_RESOURCE_H
2 #define _SYS_RESOURCE_H
3 /*
4 ** Distributed under the terms of the OpenBeOS License.
5 */
6 
7 
8 #include <sys/time.h>
9 
10 
11 /* getrlimit()/setrlimit() definitions */
12 
13 typedef unsigned long rlim_t;
14 
15 struct rlimit {
16 	rlim_t	rlim_cur;		/* current soft limit */
17 	rlim_t	rlim_max;		/* hard limit */
18 };
19 
20 // ToDo: the only supported mode is RLIMIT_NOFILE right now
21 #define RLIMIT_CORE		0	/* size of the core file */
22 #define RLIMIT_CPU		1	/* CPU time per team */
23 #define	RLIMIT_DATA		2	/* data segment size */
24 #define RLIMIT_FSIZE	3	/* file size */
25 #define RLIMIT_NOFILE	4	/* number of open files */
26 #define RLIMIT_STACK	5	/* stack size */
27 #define RLIMIT_AS		6	/* address space size */
28 
29 #define RLIM_INFINITY	(0xffffffffUL)
30 #define RLIM_SAVED_MAX	RLIM_INFINITY
31 #define RLIM_SAVED_CUR	RLIM_INFINITY
32 
33 
34 /* getrusage() definitions */
35 
36 struct rusage {
37 	struct timeval ru_utime;	/* user time used */
38 	struct timeval ru_stime;	/* system time used */
39 };
40 
41 #define RUSAGE_SELF     0
42 #define RUSAGE_CHILDREN -1
43 
44 
45 /* getpriority()/setpriority() definitions */
46 
47 #define PRIO_PROCESS	0
48 #define PRIO_PGRP		1
49 #define PRIO_USER		2
50 
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 extern int getrusage(int who, struct rusage *rusage);
57 
58 extern int getrlimit(int resource, struct rlimit * rlp);
59 extern int setrlimit(int resource, const struct rlimit * rlp);
60 
61 // ToDo: The following POSIX calls are missing (in BeOS as well):
62 //int getpriority(int which, id_t who);
63 //int setpriority(int which, id_t who, int priority);
64 
65 #ifdef __cplusplus
66 }
67 #endif
68 
69 #endif	/* _SYS_RESOURCE_H */
70