From f561324441741058a611c6d3fabac107ad9f770b Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 11 Jul 2007 07:46:56 +0000 Subject: [PATCH] cosmetics: enforce prototype checking on callbacks in SIMIX_function_register_process_create/kill git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3723 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/include/simix/simix.h | 11 +++++++++-- src/msg/deployment.c | 4 ++-- src/msg/m_process.c | 25 +++++++++++++++---------- src/msg/private.h | 7 ++++--- src/simix/private.h | 4 ++-- src/simix/smx_global.c | 4 ++-- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/include/simix/simix.h b/src/include/simix/simix.h index 4fefabbe8c..5e2e97b6ca 100644 --- a/src/include/simix/simix.h +++ b/src/include/simix/simix.h @@ -45,8 +45,15 @@ XBT_PUBLIC(void) __SIMIX_main(void); * int argc, char **argv: parameters passed to code * * */ -XBT_PUBLIC(void) SIMIX_function_register_process_create(void * function); -XBT_PUBLIC(void) SIMIX_function_register_process_kill(void * function); +typedef void *(smx_creation_func_t)(/*name*/ const char *, + /*code*/ xbt_main_func_t, + /*userdata*/ void *, + /*hostname*/ char *, + /* argc */ int, + /* argv */ char **); +XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t *function); + +XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_f_pvoid_t *function); /************************** Host handling ***********************************/ diff --git a/src/msg/deployment.c b/src/msg/deployment.c index 97308f291f..4e05ed1465 100644 --- a/src/msg/deployment.c +++ b/src/msg/deployment.c @@ -31,8 +31,8 @@ void MSG_launch_application(const char *file) { xbt_assert0(msg_global,"MSG_global_init_args has to be called before MSG_launch_application."); - SIMIX_function_register_process_create(&__MSG_process_create_with_arguments); - SIMIX_function_register_process_kill(&MSG_process_kill); + SIMIX_function_register_process_create(_MSG_process_create_from_SIMIX); + SIMIX_function_register_process_kill(_MSG_process_kill_from_SIMIX); SIMIX_launch_application(file); return; diff --git a/src/msg/m_process.c b/src/msg/m_process.c index 586e756134..96a8e4593b 100644 --- a/src/msg/m_process.c +++ b/src/msg/m_process.c @@ -57,6 +57,16 @@ void __MSG_process_cleanup(void *arg) return; } +/* This function creates a MSG process. It has the prototype by SIMIX_function_register_process_create */ +void *_MSG_process_create_from_SIMIX(const char *name, + xbt_main_func_t code, void *data, + char * hostname, int argc, char **argv) +{ + m_host_t host = MSG_get_host_by_name(hostname); + return (void*)MSG_process_create_with_arguments(name,code,data,host,argc,argv); +} + + /** \ingroup m_process_management * \brief Creates and runs a new #m_process_t. @@ -82,16 +92,6 @@ void __MSG_process_cleanup(void *arg) * \return The new corresponding object. */ - - -m_process_t __MSG_process_create_with_arguments(const char *name, - xbt_main_func_t code, void *data, - char * hostname, int argc, char **argv) -{ - m_host_t host = MSG_get_host_by_name(hostname); - return MSG_process_create_with_arguments(name,code,data,host,argc,argv); -} - m_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, m_host_t host, int argc, char **argv) @@ -128,6 +128,11 @@ m_process_t MSG_process_create_with_arguments(const char *name, return process; } + +void _MSG_process_kill_from_SIMIX(void *p) { + MSG_process_kill((m_process_t)p); +} + /** \ingroup m_process_management * \param process poor victim * diff --git a/src/msg/private.h b/src/msg/private.h index 459a10b981..d193688e77 100644 --- a/src/msg/private.h +++ b/src/msg/private.h @@ -105,9 +105,10 @@ void __MSG_host_destroy(m_host_t host); void __MSG_display_process_status(void); void __MSG_process_cleanup(void *arg); -m_process_t __MSG_process_create_with_arguments(const char *name, - xbt_main_func_t code, void *data, - char * hostname, int argc, char **argv); +void *_MSG_process_create_from_SIMIX(const char *name, + xbt_main_func_t code, void *data, + char * hostname, int argc, char **argv); +void _MSG_process_kill_from_SIMIX(void *p); #endif diff --git a/src/simix/private.h b/src/simix/private.h index 1c7ac7dc58..2c70b1eaaa 100644 --- a/src/simix/private.h +++ b/src/simix/private.h @@ -38,8 +38,8 @@ typedef struct SIMIX_Global { smx_process_t current_process; xbt_dict_t registered_functions; - void* (*create_process_function) (); - void* (*kill_process_function)(); + smx_creation_func_t *create_process_function; + void_f_pvoid_t* kill_process_function; } s_SIMIX_Global_t, *SIMIX_Global_t; extern SIMIX_Global_t simix_global; diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index 98aca67fa0..81f097b3b4 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -354,7 +354,7 @@ int SIMIX_timer_get(void **function, void **arg) * \param function Create process function * */ -void SIMIX_function_register_process_create(void * function) +void SIMIX_function_register_process_create(smx_creation_func_t* function) { xbt_assert0((simix_global->create_process_function == NULL), "Data already set"); @@ -371,7 +371,7 @@ void SIMIX_function_register_process_create(void * function) * \param function Kill process function * */ -void SIMIX_function_register_process_kill(void * function) +void SIMIX_function_register_process_kill(void_f_pvoid_t* function) { xbt_assert0((simix_global->kill_process_function == NULL), "Data already set"); -- 2.20.1