From: Martin Quinson Date: Sat, 16 Jan 2016 08:55:08 +0000 (+0100) Subject: Kill a deprecated function, deprecate another one, and inline a simcall X-Git-Tag: v3_13~1224 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/65ba2d986262a9d812fe5def15cc49af1da2ac02 Kill a deprecated function, deprecate another one, and inline a simcall - SIMIX_host_get_name is replaced by sg_host_get_name - One day, MSG_host_get_name will die - the host_off simcall now use the closure simcall --- diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index de9e014756..52e382b14b 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -296,7 +296,10 @@ XBT_PUBLIC(msg_host_t) MSG_host_by_name(const char *name); #define MSG_get_host_by_name(n) MSG_host_by_name(n) /* Rewrite the old name into the new one transparently */ XBT_PUBLIC(msg_error_t) MSG_host_set_data(msg_host_t host, void *data); XBT_PUBLIC(void *) MSG_host_get_data(msg_host_t host); -XBT_PUBLIC(const char *) MSG_host_get_name(msg_host_t host); +/** \ingroup m_host_management + * + * \brief Return the name of the #msg_host_t. */ +#define MSG_host_get_name(host) sg_host_get_name(host) XBT_PUBLIC(void) MSG_host_on(msg_host_t host); XBT_PUBLIC(void) MSG_host_off(msg_host_t host); XBT_PUBLIC(msg_host_t) MSG_host_self(void); diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 12e805b1f3..d28e29c15a 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -213,7 +213,6 @@ XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host, /*********************************** Host *************************************/ XBT_PUBLIC(sg_host_t) SIMIX_host_self(void); XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void); -#define SIMIX_host_get_name(h) sg_host_get_name(h) /* DEPRECATED: SIMIX_host_get_name */ XBT_PUBLIC(void) SIMIX_host_on(sg_host_t host); XBT_PUBLIC(void) SIMIX_host_off(sg_host_t host, smx_process_t issuer); XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data); diff --git a/src/msg/instr_msg_process.cpp b/src/msg/instr_msg_process.cpp index db8621630a..c784fa4d57 100644 --- a/src/msg/instr_msg_process.cpp +++ b/src/msg/instr_msg_process.cpp @@ -58,7 +58,7 @@ void TRACE_msg_process_create (const char *process_name, int process_pid, msg_ho int len = INSTR_DEFAULT_STR_SIZE; char str[INSTR_DEFAULT_STR_SIZE]; - container_t host_container = PJ_container_get (SIMIX_host_get_name(host)); + container_t host_container = PJ_container_get (sg_host_get_name(host)); PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container); } } diff --git a/src/msg/instr_msg_vm.cpp b/src/msg/instr_msg_vm.cpp index cf8fa354cf..c002413a1a 100644 --- a/src/msg/instr_msg_vm.cpp +++ b/src/msg/instr_msg_vm.cpp @@ -45,7 +45,7 @@ void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, msg_host_t new_h PJ_container_free(existing_container); //create new container on the new_host location - PJ_container_new(instr_vm_id(vm, str, len), INSTR_MSG_VM, PJ_container_get(SIMIX_host_get_name(new_host))); + PJ_container_new(instr_vm_id(vm, str, len), INSTR_MSG_VM, PJ_container_get(sg_host_get_name(new_host))); //end link msg = PJ_container_get(instr_vm_id(vm, str, len)); @@ -60,7 +60,7 @@ void TRACE_msg_vm_create(const char *vm_name, msg_host_t host) int len = INSTR_DEFAULT_STR_SIZE; char str[INSTR_DEFAULT_STR_SIZE]; - container_t host_container = PJ_container_get (SIMIX_host_get_name(host)); + container_t host_container = PJ_container_get (sg_host_get_name(host)); PJ_container_new(instr_vm_id_2(vm_name, str, len), INSTR_MSG_VM, host_container); } } diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index 46bb0c81fd..22fc30751b 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -99,17 +99,6 @@ void *MSG_host_get_data(msg_host_t host) { return sg_host_user(host); } -/** \ingroup m_host_management - * - * \brief Return the name of the #msg_host_t. - * - * This functions checks whether \a host is a valid pointer or not and return - its name. - */ -const char *MSG_host_get_name(msg_host_t host) { - return SIMIX_host_get_name(host); -} - /** \ingroup m_host_management * * \brief Return the location on which the current process is executed. diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 479f935c37..959fb1f111 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -365,7 +365,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa host_dest = MSG_host_by_name(host_name_dest); }else{ - XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, SIMIX_host_get_name(host)); + XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, sg_host_get_name(host)); return MSG_TASK_CANCELED; } diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 48b517621a..8944cbaa2d 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -65,7 +65,7 @@ void Host::turn_on() { } void Host::turn_off() { - simgrid::simix::simcall(SIMCALL_HOST_OFF, this); + simgrid::simix::kernel(std::bind(SIMIX_host_off, this, SIMIX_process_self())); } bool Host::is_on() { diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index cb9bc3904d..ec53b815cd 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -14,13 +14,6 @@ */ -static inline sg_host_t simcall_host_off__get__host(smx_simcall_t simcall) { - return (sg_host_t) simcall->args[0].dp; -} -static inline void simcall_host_off__set__host(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} - static inline sg_host_t simcall_vm_suspend__get__ind_vm(smx_simcall_t simcall) { return (sg_host_t) simcall->args[0].dp; } @@ -1456,7 +1449,6 @@ static inline void simcall_mc_compare_snapshots__set__result(smx_simcall_t simca /* The prototype of all simcall handlers, automatically generated for you */ -XBT_PRIVATE void simcall_HANDLER_host_off(smx_simcall_t simcall, sg_host_t host); XBT_PRIVATE void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t ind_vm); XBT_PRIVATE void simcall_HANDLER_vm_resume(smx_simcall_t simcall, sg_host_t ind_vm); XBT_PRIVATE void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 99643d633c..b72a2ad1db 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -18,27 +18,6 @@ #include "xbt/ex.h" #include -inline static void simcall_BODY_host_off(sg_host_t host) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) simcall_HANDLER_host_off(&self->simcall, host); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_HOST_OFF; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) host; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - - } - inline static void simcall_BODY_vm_suspend(sg_host_t ind_vm) { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 1b0676af47..4f71766547 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -18,7 +18,6 @@ */ typedef enum { SIMCALL_NONE, - SIMCALL_HOST_OFF, SIMCALL_VM_SUSPEND, SIMCALL_VM_RESUME, SIMCALL_VM_SHUTDOWN, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index b9f26ada3d..3d42aab6b2 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -23,8 +23,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping); /** @brief Simcalls' names (generated from src/simix/simcalls.in) */ const char* simcall_names[] = { - "SIMCALL_NONE", "SIMCALL_HOST_OFF", - "SIMCALL_VM_SUSPEND", + "SIMCALL_NONE", "SIMCALL_VM_SUSPEND", "SIMCALL_VM_RESUME", "SIMCALL_VM_SHUTDOWN", "SIMCALL_VM_SAVE", @@ -131,11 +130,6 @@ void SIMIX_simcall_handle(smx_simcall_t simcall, int value) { if (simcall->issuer->context->iwannadie && simcall->call != SIMCALL_PROCESS_CLEANUP) return; switch (simcall->call) { -case SIMCALL_HOST_OFF: - simcall_HANDLER_host_off(simcall , (sg_host_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_VM_SUSPEND: simcall_HANDLER_vm_suspend(simcall , (sg_host_t) simcall->args[0].dp); SIMIX_simcall_answer(simcall); @@ -572,7 +566,7 @@ case SIMCALL_MC_COMPARE_SNAPSHOTS: case SIMCALL_NONE: THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s", SIMIX_process_get_name(simcall->issuer), - SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer)) + sg_host_get_name(SIMIX_process_get_host(simcall->issuer)) ); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 469b171782..094b82d9fd 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -46,8 +46,6 @@ # ./include/simgrid/simix.h (otherwise you will get a warning at the # compilation time) -Proc H host_off (void) (host, void*, sg_host_t) - Proc H vm_suspend (void) (ind_vm, void*, sg_host_t) Proc H vm_resume (void) (ind_vm, void*, sg_host_t) Proc H vm_shutdown (void) (ind_vm, void*, sg_host_t) diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index c249a21c08..815bb2f1a1 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -316,7 +316,7 @@ if __name__=='__main__': fd.write(' case SIMCALL_NONE:\n'); fd.write(' THROWF(arg_error,0,"Asked to do the noop syscall on %s@%s",\n'); fd.write(' SIMIX_process_get_name(simcall->issuer),\n'); - fd.write(' SIMIX_host_get_name(SIMIX_process_get_host(simcall->issuer))\n'); + fd.write(' sg_host_get_name(SIMIX_process_get_host(simcall->issuer))\n'); fd.write(' );\n'); fd.write(' break;\n'); fd.write('\n'); diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index ad2f258867..a47fa092ed 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -83,11 +83,6 @@ void SIMIX_host_on(sg_host_t h) } } -void simcall_HANDLER_host_off(smx_simcall_t simcall, sg_host_t h) -{ - SIMIX_host_off(h, simcall->issuer); -} - /** * \brief Stop the host if it is on * @@ -163,7 +158,7 @@ const char* SIMIX_host_self_get_name(void) if (host == NULL || SIMIX_process_self() == simix_global->maestro_process) return ""; - return SIMIX_host_get_name(host); + return sg_host_get_name(host); } void _SIMIX_host_free_process_arg(void *data) diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 1cfc466b48..f613c309a1 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -724,7 +724,7 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro) sg_host_t receiver = synchro->comm.dst_proc->host; XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro, - SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver)); + sg_host_get_name(sender), sg_host_get_name(receiver)); synchro->comm.surf_comm = surf_network_model_communicate(surf_network_model, sender, receiver, @@ -737,7 +737,7 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro) /* If a link is failed, detect it immediately */ if (synchro->comm.surf_comm->getState() == SURF_ACTION_FAILED) { XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", - SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver)); + sg_host_get_name(sender), sg_host_get_name(receiver)); synchro->state = SIMIX_LINK_FAILURE; SIMIX_comm_destroy_internal_actions(synchro); } @@ -750,10 +750,10 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro) if (SIMIX_process_is_suspended(synchro->comm.src_proc)) XBT_DEBUG("The communication is suspended on startup because src (%s:%s) were suspended since it initiated the communication", - SIMIX_host_get_name(synchro->comm.src_proc->host), synchro->comm.src_proc->name); + sg_host_get_name(synchro->comm.src_proc->host), synchro->comm.src_proc->name); else XBT_DEBUG("The communication is suspended on startup because dst (%s:%s) were suspended since it initiated the communication", - SIMIX_host_get_name(synchro->comm.dst_proc->host), synchro->comm.dst_proc->name); + sg_host_get_name(synchro->comm.dst_proc->host), synchro->comm.dst_proc->name); synchro->comm.surf_comm->suspend(); diff --git a/src/simix/smx_vm.cpp b/src/simix/smx_vm.cpp index 6be0a1513b..6b32988c7d 100644 --- a/src/simix/smx_vm.cpp +++ b/src/simix/smx_vm.cpp @@ -97,7 +97,7 @@ void SIMIX_vm_start(sg_host_t ind_vm) ind_vm->extension() )->setState(SURF_VM_STATE_RUNNING); else - THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm)); + THROWF(vm_error, 0, "The VM %s cannot be started", sg_host_get_name(ind_vm)); } @@ -197,7 +197,7 @@ void SIMIX_vm_set_affinity(sg_host_t ind_vm, sg_host_t ind_pm, unsigned long mas */ void SIMIX_vm_suspend(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_RUNNING) THROWF(vm_error, 0, "VM(%s) is not running", name); @@ -237,7 +237,7 @@ void simcall_HANDLER_vm_suspend(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_resume(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_SUSPENDED) THROWF(vm_error, 0, "VM(%s) was not suspended", name); @@ -269,7 +269,7 @@ void simcall_HANDLER_vm_resume(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_save(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_RUNNING) THROWF(vm_error, 0, "VM(%s) is not running", name); @@ -301,7 +301,7 @@ void simcall_HANDLER_vm_save(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_restore(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_SAVED) THROWF(vm_error, 0, "VM(%s) was not saved", name); @@ -333,7 +333,7 @@ void simcall_HANDLER_vm_restore(smx_simcall_t simcall, sg_host_t ind_vm) */ void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_process_t issuer) { - const char *name = SIMIX_host_get_name(ind_vm); + const char *name = sg_host_get_name(ind_vm); if (SIMIX_vm_get_state(ind_vm) != SURF_VM_STATE_RUNNING) THROWF(vm_error, 0, "VM(%s) is not running", name); @@ -368,8 +368,7 @@ void SIMIX_vm_destroy(sg_host_t ind_vm) { /* this code basically performs a similar thing like SIMIX_host_destroy() */ - xbt_assert((ind_vm != NULL), "Invalid parameters"); - const char *hostname = SIMIX_host_get_name(ind_vm); + const char *hostname = sg_host_get_name(ind_vm); XBT_DEBUG("destroy %s", hostname); diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index 0583cfb8c1..08774f1876 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -2410,9 +2410,9 @@ int PMPI_Get_processor_name(char *name, int *resultlen) { int retval = MPI_SUCCESS; - strncpy(name, SIMIX_host_get_name(SIMIX_host_self()), - strlen(SIMIX_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ? - strlen(SIMIX_host_get_name(SIMIX_host_self())) +1 : + strncpy(name, sg_host_get_name(SIMIX_host_self()), + strlen(sg_host_get_name(SIMIX_host_self())) < MPI_MAX_PROCESSOR_NAME - 1 ? + strlen(sg_host_get_name(SIMIX_host_self())) +1 : MPI_MAX_PROCESSOR_NAME - 1 ); *resultlen = strlen(name) >