-static inline void __vx_acc_cres(struct vx_info *vxi,
- int res, int dir, void *_data, char *_file, int _line)
-{
- if (VXD_RLIMIT(res, RLIMIT_NOFILE) ||
- VXD_RLIMIT(res, RLIMIT_NPROC) ||
- VXD_RLIMIT(res, VLIMIT_NSOCK))
- vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5d%s (%p)",
- (vxi?vxi->vx_id:-1), vlimit_name[res], res,
- (vxi?atomic_read(&vxi->limit.rcur[res]):0),
- (dir>0)?"++":"--", _data, _file, _line);
- if (vxi) {
- if (dir > 0)
- atomic_inc(&vxi->limit.rcur[res]);
- else
- atomic_dec(&vxi->limit.rcur[res]);
- }
-}
+#define vx_add_cres(v,a,p,r) \
+ __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
+#define vx_sub_cres(v,a,p,r) vx_add_cres(v,-(a),p,r)
+
+#define vx_add_cres_cond(x,a,p,r) \
+ __vx_add_cres(((x) == vx_current_xid()) ? current->vx_info : 0, \
+ r, a, p, __FILE__, __LINE__)
+#define vx_sub_cres_cond(x,a,p,r) vx_add_cres_cond(x,-(a),p,r)
+
+
+/* process and file limits */
+
+#define vx_nproc_inc(p) \
+ vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
+
+#define vx_nproc_dec(p) \
+ vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
+
+#define vx_files_inc(f) \
+ vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
+
+#define vx_files_dec(f) \
+ vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
+
+#define vx_locks_inc(l) \
+ vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
+
+#define vx_locks_dec(l) \
+ vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
+
+#define vx_openfd_inc(f) \
+ vx_acc_cres(current->vx_info, 1, (void *)(long)(f), VLIMIT_OPENFD)
+
+#define vx_openfd_dec(f) \
+ vx_acc_cres(current->vx_info,-1, (void *)(long)(f), VLIMIT_OPENFD)