Commit 26d68cdd authored by Matthieu Dorier's avatar Matthieu Dorier

put hooks to simplify macros

parent be528ff8
......@@ -926,10 +926,15 @@ void __margo_internal_decr_pending(margo_instance_id mid);
* @private
* Internal function used by DEFINE_MARGO_RPC_HANDLER, not supposed to be
* called by users!
*
* @param rpc_breadcrumb RPC tracking breadcrumb
*/
void __margo_internal_breadcrumb_handler_set(uint64_t rpc_breadcrumb);
void __margo_internal_pre_wrapper_hooks(margo_instance_id mid, hg_handle_t handle);
/**
* @private
* Internal function used by DEFINE_MARGO_RPC_HANDLER, not supposed to be
* called by users!
*/
void __margo_internal_post_wrapper_hooks(margo_instance_id mid);
/**
* macro that registers a function as an RPC.
......@@ -952,18 +957,10 @@ void __margo_internal_breadcrumb_handler_set(uint64_t rpc_breadcrumb);
#define __MARGO_INTERNAL_RPC_WRAPPER_BODY(__name) \
margo_instance_id __mid; \
hg_return_t __ret; \
uint64_t *__rpc_breadcrumb; \
__mid = margo_hg_handle_get_instance(handle); \
__ret = HG_Get_input_buf(handle, (void**)&__rpc_breadcrumb, NULL); \
assert(__ret == HG_SUCCESS); \
*__rpc_breadcrumb = le64toh(*__rpc_breadcrumb); \
__margo_internal_breadcrumb_handler_set((*__rpc_breadcrumb) << 16); \
__margo_internal_pre_wrapper_hooks(__mid, handle); \
__name(handle); \
__margo_internal_decr_pending(__mid); \
if(__margo_internal_finalize_requested(__mid)) { \
margo_finalize(__mid); \
}
__margo_internal_post_wrapper_hooks(__mid);
#define __MARGO_INTERNAL_RPC_WRAPPER(__name) \
void __name##_wrapper(hg_handle_t handle) { \
......
......@@ -1933,7 +1933,7 @@ static void margo_breadcrumb_measure(margo_instance_id mid, uint64_t rpc_breadcr
return;
}
void __margo_internal_breadcrumb_handler_set(uint64_t rpc_breadcrumb)
static void margo_internal_breadcrumb_handler_set(uint64_t rpc_breadcrumb)
{
uint64_t *val;
......@@ -1953,3 +1953,21 @@ void __margo_internal_breadcrumb_handler_set(uint64_t rpc_breadcrumb)
return;
}
void __margo_internal_pre_wrapper_hooks(margo_instance_id mid, hg_handle_t handle)
{
hg_return_t ret;
uint64_t *rpc_breadcrumb;
ret = HG_Get_input_buf(handle, (void**)&rpc_breadcrumb, NULL);
assert(ret == HG_SUCCESS);
*rpc_breadcrumb = le64toh(*rpc_breadcrumb);
margo_internal_breadcrumb_handler_set((*rpc_breadcrumb) << 16);
}
void __margo_internal_post_wrapper_hooks(margo_instance_id mid)
{
__margo_internal_decr_pending(mid);
if(__margo_internal_finalize_requested(mid)) {
margo_finalize(mid);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment