Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / include / linux / vs_limit.h
1 #ifndef _VX_VS_LIMIT_H
2 #define _VX_VS_LIMIT_H
3
4 #include "vserver/limit.h"
5 #include "vserver/debug.h"
6 #include "vserver/limit_int.h"
7
8
9 #define vx_acc_cres(v,d,p,r) \
10         __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
11
12 #define vx_acc_cres_cond(x,d,p,r) \
13         __vx_acc_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
14         r, d, p, __FILE__, __LINE__)
15
16
17 #define vx_add_cres(v,a,p,r) \
18         __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
19 #define vx_sub_cres(v,a,p,r)            vx_add_cres(v,-(a),p,r)
20
21 #define vx_add_cres_cond(x,a,p,r) \
22         __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
23         r, a, p, __FILE__, __LINE__)
24 #define vx_sub_cres_cond(x,a,p,r)       vx_add_cres_cond(x,-(a),p,r)
25
26
27 /* process and file limits */
28
29 #define vx_nproc_inc(p) \
30         vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
31
32 #define vx_nproc_dec(p) \
33         vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
34
35 #define vx_files_inc(f) \
36         vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
37
38 #define vx_files_dec(f) \
39         vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
40
41 #define vx_locks_inc(l) \
42         vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
43
44 #define vx_locks_dec(l) \
45         vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
46
47 #define vx_openfd_inc(f) \
48         vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
49
50 #define vx_openfd_dec(f) \
51         vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
52
53
54 #define vx_cres_avail(v,n,r) \
55         __vx_cres_avail(v, r, n, __FILE__, __LINE__)
56
57
58 #define vx_nproc_avail(n) \
59         vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
60
61 #define vx_files_avail(n) \
62         vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
63
64 #define vx_locks_avail(n) \
65         vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
66
67 #define vx_openfd_avail(n) \
68         vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
69
70
71 /* socket limits */
72
73 #define vx_sock_inc(s) \
74         vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
75
76 #define vx_sock_dec(s) \
77         vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
78
79 #define vx_sock_avail(n) \
80         vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
81
82
83 /* ipc resource limits */
84
85 #define vx_ipcmsg_add(v,u,a) \
86         vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
87
88 #define vx_ipcmsg_sub(v,u,a) \
89         vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
90
91 #define vx_ipcmsg_avail(v,a) \
92         vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
93
94
95 #define vx_ipcshm_add(v,k,a) \
96         vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
97
98 #define vx_ipcshm_sub(v,k,a) \
99         vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
100
101 #define vx_ipcshm_avail(v,a) \
102         vx_cres_avail(v, a, VLIMIT_SHMEM)
103
104
105 #else
106 #warning duplicate inclusion
107 #endif