From 225dba6f5844417a2e294fe194211e9253a8c90b Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sat, 8 Feb 2014 11:35:39 +0100 Subject: [PATCH] Don't hide type real type, smx_process_t, behind a void*. --- include/simgrid/simix.h | 19 +++++++++---------- src/bindings/java/smx_context_cojava.c | 20 ++++++++++---------- src/bindings/java/smx_context_java.c | 16 ++++++++-------- src/simix/smx_context_base.c | 19 +++++++++---------- src/simix/smx_context_raw.c | 12 ++++++------ src/simix/smx_context_sysv.c | 22 ++++++++++++---------- src/simix/smx_context_thread.c | 10 +++++----- src/simix/smx_private.h | 8 ++++---- src/simix/smx_process.c | 2 +- 9 files changed, 64 insertions(+), 64 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 6bd38df59c..a50748be23 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -140,8 +140,8 @@ typedef void (*void_pfn_smxhost_t) (smx_host_t); factory should implement */ -typedef smx_context_t(*smx_pfn_context_factory_create_context_t) - (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data); +typedef smx_context_t (*smx_pfn_context_factory_create_context_t)( + xbt_main_func_t, int, char **, void_pfn_smxprocess_t, smx_process_t process); typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*); typedef void (*smx_pfn_context_free_t) (smx_context_t); typedef void (*smx_pfn_context_start_t) (smx_context_t); @@ -149,7 +149,7 @@ typedef void (*smx_pfn_context_stop_t) (smx_context_t); typedef void (*smx_pfn_context_suspend_t) (smx_context_t context); typedef void (*smx_pfn_context_runall_t) (void); typedef smx_context_t (*smx_pfn_context_self_t) (void); -typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context); +typedef smx_process_t (*smx_pfn_context_get_process_t) (smx_context_t context); /* interface of the context factories */ typedef struct s_smx_context_factory { @@ -161,7 +161,7 @@ typedef struct s_smx_context_factory { smx_pfn_context_suspend_t suspend; smx_pfn_context_runall_t runall; smx_pfn_context_self_t self; - smx_pfn_context_get_data_t get_data; + smx_pfn_context_get_process_t get_process; } s_smx_context_factory_t; /* Hack: let msg load directly the right factory */ @@ -182,7 +182,7 @@ typedef struct s_smx_context { s_xbt_swag_hookup_t hookup; xbt_main_func_t code; void_pfn_smxprocess_t cleanup_func; - void *data; /* Here SIMIX stores the smx_process_t containing the context */ + smx_process_t process; char **argv; int argc; unsigned iwannadie:1; @@ -193,15 +193,14 @@ XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory); XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory); XBT_PUBLIC(smx_context_t) -smx_ctx_base_factory_create_context_sized(size_t size, - xbt_main_func_t code, int argc, - char **argv, +smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code, + int argc, char **argv, void_pfn_smxprocess_t cleanup, - void* data); + smx_process_t process); XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context); XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context); XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void); -XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context); +XBT_PUBLIC(smx_process_t) smx_ctx_base_get_process(smx_context_t context); XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void); XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID); diff --git a/src/bindings/java/smx_context_cojava.c b/src/bindings/java/smx_context_cojava.c index fd064e8c82..3503536084 100644 --- a/src/bindings/java/smx_context_cojava.c +++ b/src/bindings/java/smx_context_cojava.c @@ -38,10 +38,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg); static smx_context_t -smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc, - char **argv, - void_pfn_smxprocess_t cleanup_func, - void *data); +smx_ctx_cojava_factory_create_context(xbt_main_func_t code, + int argc, char **argv, + void_pfn_smxprocess_t cleanup_func, + smx_process_t process); static void smx_ctx_cojava_free(smx_context_t context); static void smx_ctx_cojava_suspend(smx_context_t context); @@ -63,7 +63,7 @@ void SIMIX_ctx_cojava_factory_init(smx_context_factory_t * factory) (*factory)->name = "ctx_cojava_factory"; //(*factory)->finalize = smx_ctx_base_factory_finalize; (*factory)->self = smx_ctx_cojava_self; - (*factory)->get_data = smx_ctx_base_get_data; + (*factory)->get_process = smx_ctx_base_get_process; global_env = get_current_thread_env(); @@ -114,10 +114,10 @@ smx_context_t smx_ctx_cojava_self(void) } static smx_context_t -smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc, - char **argv, - void_pfn_smxprocess_t cleanup_func, - void* data) +smx_ctx_cojava_factory_create_context(xbt_main_func_t code, + int argc, char **argv, + void_pfn_smxprocess_t cleanup_func, + smx_process_t process) { smx_ctx_cojava_t context = xbt_new0(s_smx_ctx_cojava_t, 1); /* If the user provided a function for the process then use it @@ -143,7 +143,7 @@ smx_ctx_cojava_factory_create_context(xbt_main_func_t code, int argc, maestro_context = (smx_context_t)context; } context->bound = 0; - context->super.data = data; + context->super.process = process; return (smx_context_t) context; } diff --git a/src/bindings/java/smx_context_java.c b/src/bindings/java/smx_context_java.c index e20568266e..de3518834b 100644 --- a/src/bindings/java/smx_context_java.c +++ b/src/bindings/java/smx_context_java.c @@ -17,10 +17,10 @@ extern JavaVM *__java_vm; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jmsg, bindings, "MSG for Java(TM)"); static smx_context_t -smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, - char **argv, +smx_ctx_java_factory_create_context(xbt_main_func_t code, + int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void *data); + smx_process_t process); static void smx_ctx_java_free(smx_context_t context); static void smx_ctx_java_suspend(smx_context_t context); @@ -41,7 +41,7 @@ void SIMIX_ctx_java_factory_init(smx_context_factory_t * factory) (*factory)->name = "ctx_java_factory"; //(*factory)->finalize = smx_ctx_base_factory_finalize; (*factory)->self = smx_ctx_java_self; - (*factory)->get_data = smx_ctx_base_get_data; + (*factory)->get_process = smx_ctx_base_get_process; } smx_context_t smx_ctx_java_self(void) { @@ -49,10 +49,10 @@ smx_context_t smx_ctx_java_self(void) } static smx_context_t -smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, - char **argv, +smx_ctx_java_factory_create_context(xbt_main_func_t code, + int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void* data) + smx_process_t process) { static int thread_amount=0; smx_ctx_java_t context = xbt_new0(s_smx_ctx_java_t, 1); @@ -86,7 +86,7 @@ smx_ctx_java_factory_create_context(xbt_main_func_t code, int argc, context->thread = NULL; xbt_os_thread_set_extra_data(context); } - context->super.data = data; + context->super.process = process; return (smx_context_t) context; } diff --git a/src/simix/smx_context_base.c b/src/simix/smx_context_base.c index 313541530e..848b8d71e0 100644 --- a/src/simix/smx_context_base.c +++ b/src/simix/smx_context_base.c @@ -25,7 +25,7 @@ void smx_ctx_base_factory_init(smx_context_factory_t *factory) (*factory)->suspend = NULL; (*factory)->runall = NULL; (*factory)->self = smx_ctx_base_self; - (*factory)->get_data = smx_ctx_base_get_data; + (*factory)->get_process = smx_ctx_base_get_process; (*factory)->name = "base context factory"; } @@ -38,11 +38,10 @@ int smx_ctx_base_factory_finalize(smx_context_factory_t * factory) } smx_context_t -smx_ctx_base_factory_create_context_sized(size_t size, - xbt_main_func_t code, int argc, - char **argv, +smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code, + int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void *data) + smx_process_t process) { smx_context_t context = xbt_malloc0(size); @@ -61,7 +60,7 @@ smx_ctx_base_factory_create_context_sized(size_t size, } else { SIMIX_context_set_current(context); } - context->data = data; + context->process = process; return context; } @@ -87,9 +86,9 @@ void smx_ctx_base_free(smx_context_t context) void smx_ctx_base_stop(smx_context_t context) { if (context->cleanup_func) - context->cleanup_func(context->data); + context->cleanup_func(context->process); context->iwannadie = 0; - simcall_process_cleanup(context->data); + simcall_process_cleanup(context->process); context->iwannadie = 1; } @@ -98,7 +97,7 @@ smx_context_t smx_ctx_base_self(void) return SIMIX_context_get_current(); } -void *smx_ctx_base_get_data(smx_context_t context) +smx_process_t smx_ctx_base_get_process(smx_context_t context) { - return context->data; + return context->process; } diff --git a/src/simix/smx_context_raw.c b/src/simix/smx_context_raw.c index 7bf2b87112..d475f6be53 100644 --- a/src/simix/smx_context_raw.c +++ b/src/simix/smx_context_raw.c @@ -210,7 +210,7 @@ static char new_sr = 0; static void smx_ctx_raw_wrapper(smx_ctx_raw_t context); static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory); static smx_context_t smx_ctx_raw_create_context(xbt_main_func_t code, int argc, - char **argv, void_pfn_smxprocess_t cleanup_func, void *data); + char **argv, void_pfn_smxprocess_t cleanup_func, smx_process_t process); static void smx_ctx_raw_free(smx_context_t context); static void smx_ctx_raw_wrapper(smx_ctx_raw_t context); static void smx_ctx_raw_stop(smx_context_t context); @@ -296,12 +296,12 @@ static int smx_ctx_raw_factory_finalize(smx_context_factory_t *factory) * \param argv arguments to pass to the main function * \param cleanup_func a function to call to free the user data when the * context finished - * \param data user data + * \param process SIMIX process */ static smx_context_t smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv, - void_pfn_smxprocess_t cleanup_func, - void *data) + void_pfn_smxprocess_t cleanup_func, + smx_process_t process) { smx_ctx_raw_t context = @@ -311,7 +311,7 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv, argc, argv, cleanup_func, - data); + process); /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ @@ -328,7 +328,7 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv, #endif /* HAVE_VALGRIND_VALGRIND_H */ } else { - if(data != NULL && raw_maestro_context==NULL) + if(process != NULL && raw_maestro_context==NULL) raw_maestro_context = context; if(MC_is_active()) diff --git a/src/simix/smx_context_sysv.c b/src/simix/smx_context_sysv.c index f97b92b9be..b1906cc105 100644 --- a/src/simix/smx_context_sysv.c +++ b/src/simix/smx_context_sysv.c @@ -51,11 +51,11 @@ smx_ctx_sysv_create_context_sized(size_t structure_size, xbt_main_func_t code, int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void *data); + smx_process_t process); static void smx_ctx_sysv_free(smx_context_t context); static smx_context_t smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv, - void_pfn_smxprocess_t cleanup_func, void* data); + void_pfn_smxprocess_t cleanup_func, smx_process_t process); static void smx_ctx_sysv_wrapper(int count, ...); @@ -120,7 +120,7 @@ static smx_context_t smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code, int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void *data) + smx_process_t process) { int ctx_addr[CTX_ADDR_LEN]; smx_ctx_sysv_t context = @@ -129,7 +129,7 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code, argc, argv, cleanup_func, - data); + process); /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ @@ -166,25 +166,27 @@ smx_ctx_sysv_create_context_sized(size_t size, xbt_main_func_t code, sizeof(smx_ctx_sysv_t), sizeof(int), CTX_ADDR_LEN); } } else { - if(data != NULL && sysv_maestro_context == NULL) + if (process != NULL && sysv_maestro_context == NULL) sysv_maestro_context = context; } if(MC_is_active() && code) - MC_new_stack_area(context, ((smx_process_t)((smx_context_t)context)->data)->name, &(context->uc), size); + MC_new_stack_area(context, ((smx_context_t)context)->process->name, + &(context->uc), size); return (smx_context_t) context; } static smx_context_t smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv, - void_pfn_smxprocess_t cleanup_func, - void *data) + void_pfn_smxprocess_t cleanup_func, + smx_process_t process) { - return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) + smx_context_stack_size, + return smx_ctx_sysv_create_context_sized(sizeof(s_smx_ctx_sysv_t) + + smx_context_stack_size, code, argc, argv, cleanup_func, - data); + process); } diff --git a/src/simix/smx_context_thread.c b/src/simix/smx_context_thread.c index 7e7d933b6e..ea06db0105 100644 --- a/src/simix/smx_context_thread.c +++ b/src/simix/smx_context_thread.c @@ -25,10 +25,10 @@ typedef struct s_smx_ctx_thread { static xbt_os_sem_t smx_ctx_thread_sem; static smx_context_t -smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc, - char **argv, +smx_ctx_thread_factory_create_context(xbt_main_func_t code, + int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void *data); + smx_process_t process); static void smx_ctx_thread_free(smx_context_t context); static void smx_ctx_thread_stop(smx_context_t context); @@ -80,12 +80,12 @@ static smx_context_t smx_ctx_thread_factory_create_context(xbt_main_func_t code, int argc, char **argv, void_pfn_smxprocess_t cleanup_func, - void *data) + smx_process_t process) { smx_ctx_thread_t context = (smx_ctx_thread_t) smx_ctx_base_factory_create_context_sized(sizeof(s_smx_ctx_thread_t), code, argc, argv, - cleanup_func, data); + cleanup_func, process); /* If the user provided a function for the process then use it otherwise is the context for maestro */ diff --git a/src/simix/smx_private.h b/src/simix/smx_private.h index 4b1b6bc962..8462493973 100644 --- a/src/simix/smx_private.h +++ b/src/simix/smx_private.h @@ -320,13 +320,13 @@ static XBT_INLINE smx_context_t SIMIX_context_self(void) } /** - \brief returns the data associated to a context + \brief returns the SIMIX process associated to a context \param context The context - \return The data + \return The SIMIX process */ -static XBT_INLINE void* SIMIX_context_get_data(smx_context_t context) +static XBT_INLINE smx_process_t SIMIX_context_get_process(smx_context_t context) { - return simix_global->context_factory->get_data(context); + return simix_global->context_factory->get_process(context); } XBT_PUBLIC(int) SIMIX_process_get_maxpid(void); diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 737ea00179..74a4d26ba3 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -26,7 +26,7 @@ XBT_INLINE smx_process_t SIMIX_process_self(void) { smx_context_t self_context = SIMIX_context_self(); - return self_context ? SIMIX_context_get_data(self_context) : NULL; + return self_context ? SIMIX_context_get_process(self_context) : NULL; } /** -- 2.20.1