diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-10-05 05:37:31 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-10-05 05:16:51 -0700 |
commit | 97b564c708fbb44cf1ac512d7eaca701767120d5 (patch) | |
tree | de605c7208cc9134619e243f9913c52058ddec4d /libglusterfs/src/stack.h | |
parent | 7e6c9643e69e1f8172e5be3564213d35332ae099 (diff) |
libglusterfs: Add STACK_UNWIND_STRICT macro.
STACK_UNWIND_STRICT (op, frame, this, op_ret, op_errno, ...)
The "op" argument is the name of the fop (lookup, open, etc.).
This macro makes sure that the number and type of arguments
passed match those of the callback function for the fop.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 269 (Add a specialized STACK_UNWIND macro for each FOP)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=269
Diffstat (limited to 'libglusterfs/src/stack.h')
-rw-r--r-- | libglusterfs/src/stack.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 942972556..e03f95ca1 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -215,6 +215,24 @@ STACK_DESTROY (call_stack_t *stack) } while (0) +/* return from function in type-safe way */ +#define STACK_UNWIND_STRICT(op, frame, params ...) \ + do { \ + fop_##op##_cbk_t fn = NULL; \ + call_frame_t *_parent = NULL; \ + xlator_t *old_THIS = NULL; \ + \ + fn = (fop_##op##_cbk_t )frame->ret; \ + _parent = frame->parent; \ + _parent->ref_count--; \ + old_THIS = THIS; \ + THIS = _parent->this; \ + frame->complete = _gf_true; \ + fn (_parent, frame->cookie, _parent->this, params); \ + THIS = old_THIS; \ + } while (0) + + static inline call_frame_t * copy_frame (call_frame_t *frame) { |