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