4 #include "vserver/limit.h"
5 #include "vserver/debug.h"
6 #include "vserver/limit_int.h"
9 #define vx_acc_cres(v,d,p,r) \
10 __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
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__)
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)
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)
27 /* process and file limits */
29 #define vx_nproc_inc(p) \
30 vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
32 #define vx_nproc_dec(p) \
33 vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
35 #define vx_files_inc(f) \
36 vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
38 #define vx_files_dec(f) \
39 vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
41 #define vx_locks_inc(l) \
42 vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
44 #define vx_locks_dec(l) \
45 vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
47 #define vx_openfd_inc(f) \
48 vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
50 #define vx_openfd_dec(f) \
51 vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)
54 #define vx_cres_avail(v,n,r) \
55 __vx_cres_avail(v, r, n, __FILE__, __LINE__)
58 #define vx_nproc_avail(n) \
59 vx_cres_avail(current->vx_info, n, RLIMIT_NPROC)
61 #define vx_files_avail(n) \
62 vx_cres_avail(current->vx_info, n, RLIMIT_NOFILE)
64 #define vx_locks_avail(n) \
65 vx_cres_avail(current->vx_info, n, RLIMIT_LOCKS)
67 #define vx_openfd_avail(n) \
68 vx_cres_avail(current->vx_info, n, VLIMIT_OPENFD)
73 #define vx_sock_inc(s) \
74 vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
76 #define vx_sock_dec(s) \
77 vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
79 #define vx_sock_avail(n) \
80 vx_cres_avail(current->vx_info, n, VLIMIT_NSOCK)
83 /* ipc resource limits */
85 #define vx_ipcmsg_add(v,u,a) \
86 vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
88 #define vx_ipcmsg_sub(v,u,a) \
89 vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
91 #define vx_ipcmsg_avail(v,a) \
92 vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
95 #define vx_ipcshm_add(v,k,a) \
96 vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
98 #define vx_ipcshm_sub(v,k,a) \
99 vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
101 #define vx_ipcshm_avail(v,a) \
102 vx_cres_avail(v, a, VLIMIT_SHMEM)
106 #warning duplicate inclusion