resource.h 2.1 KB
Newer Older
R
Rich Felker 已提交
1 2 3
#ifndef	_SYS_RESOURCE_H
#define	_SYS_RESOURCE_H

4 5 6 7
#ifdef __cplusplus
extern "C" {
#endif

8
#include <features.h>
9
#include <sys/time.h>
10

R
Rich Felker 已提交
11 12
#define __NEED_id_t

R
Rich Felker 已提交
13 14 15 16
#ifdef _GNU_SOURCE
#define __NEED_pid_t
#endif

R
Rich Felker 已提交
17
#include <bits/alltypes.h>
S
Szabolcs Nagy 已提交
18
#include <bits/resource.h>
R
Rich Felker 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

typedef unsigned long long rlim_t;

struct rlimit
{
	rlim_t rlim_cur;
	rlim_t rlim_max;
};

struct rusage
{
	struct timeval ru_utime;
	struct timeval ru_stime;
	/* linux extentions, but useful */
	long	ru_maxrss;
	long	ru_ixrss;
	long	ru_idrss;
	long	ru_isrss;
	long	ru_minflt;
	long	ru_majflt;
	long	ru_nswap;
	long	ru_inblock;
	long	ru_oublock;
	long	ru_msgsnd;
	long	ru_msgrcv;
	long	ru_nsignals;
	long	ru_nvcsw;
	long	ru_nivcsw;
	/* room for more... */
	long    __reserved[16];
};

int getrlimit (int, struct rlimit *);
int setrlimit (int, const struct rlimit *);
int getrusage (int, struct rusage *);

int getpriority (int, id_t);
int setpriority (int, id_t, int);

R
Rich Felker 已提交
58 59
#ifdef _GNU_SOURCE
int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
R
Rich Felker 已提交
60
#define prlimit64 prlimit
R
Rich Felker 已提交
61 62
#endif

63 64 65
#define PRIO_MIN (-20)
#define PRIO_MAX 20

R
Rich Felker 已提交
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
#define PRIO_PROCESS 0
#define PRIO_PGRP    1
#define PRIO_USER    2

#define RUSAGE_SELF     0
#define RUSAGE_CHILDREN 1

#define RLIM_INFINITY (~0ULL)
#define RLIM_SAVED_CUR RLIM_INFINITY
#define RLIM_SAVED_MAX RLIM_INFINITY

#define RLIMIT_CPU     0
#define RLIMIT_FSIZE   1
#define RLIMIT_DATA    2
#define RLIMIT_STACK   3
#define RLIMIT_CORE    4
S
Szabolcs Nagy 已提交
82
#ifndef RLIMIT_RSS
R
Rich Felker 已提交
83 84
#define RLIMIT_RSS     5
#define RLIMIT_NPROC   6
S
Szabolcs Nagy 已提交
85
#define RLIMIT_NOFILE  7
R
Rich Felker 已提交
86
#define RLIMIT_MEMLOCK 8
S
Szabolcs Nagy 已提交
87 88
#define RLIMIT_AS      9
#endif
R
Rich Felker 已提交
89
#define RLIMIT_LOCKS   10
R
Rich Felker 已提交
90 91 92 93 94
#define RLIMIT_SIGPENDING 11
#define RLIMIT_MSGQUEUE 12
#define RLIMIT_NICE    13
#define RLIMIT_RTPRIO  14
#define RLIMIT_NLIMITS 15
R
Rich Felker 已提交
95

96
#define RLIM_NLIMITS RLIMIT_NLIMITS
R
Rich Felker 已提交
97

98
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
99 100 101
#define RLIM64_INFINITY RLIM_INFINITY
#define RLIM64_SAVED_CUR RLIM_SAVED_CUR
#define RLIM64_SAVED_MAX RLIM_SAVED_MAX
R
Rich Felker 已提交
102 103 104 105 106
#define getrlimit64 getrlimit
#define setrlimit64 setrlimit
#define rlimit64 rlimit
#define rlim64_t rlim_t
#endif
R
Rich Felker 已提交
107

108 109 110 111
#ifdef __cplusplus
}
#endif

R
Rich Felker 已提交
112
#endif