From ea55b530facfb04b499b016152f739e024445aa4 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Thu, 3 Dec 2015 10:44:01 +0100 Subject: [PATCH] [simix] Switch to .cpp files --- doc/doxygen/inside_extending.doc | 4 +- include/xbt/ex.h | 18 +- include/xbt/swag.h | 18 +- src/simix/{libsmx.c => libsmx.cpp} | 8 +- src/simix/{popping.c => popping.cpp} | 2 +- .../{popping_bodies.c => popping_bodies.cpp} | 138 +++++----- ...ping_generated.c => popping_generated.cpp} | 237 +++++++++--------- src/simix/simcalls.py | 19 +- src/simix/{smx_context.c => smx_context.cpp} | 16 +- ...mx_context_base.c => smx_context_base.cpp} | 4 +- ...{smx_context_raw.c => smx_context_raw.cpp} | 15 +- ...mx_context_sysv.c => smx_context_sysv.cpp} | 7 +- ...ontext_thread.c => smx_context_thread.cpp} | 0 .../{smx_deployment.c => smx_deployment.cpp} | 7 +- ...{smx_environment.c => smx_environment.cpp} | 0 src/simix/{smx_global.c => smx_global.cpp} | 20 +- src/simix/{smx_host.c => smx_host.cpp} | 8 +- src/simix/{smx_io.c => smx_io.cpp} | 11 +- src/simix/{smx_network.c => smx_network.cpp} | 27 +- src/simix/{smx_process.c => smx_process.cpp} | 28 +-- src/simix/{smx_synchro.c => smx_synchro.cpp} | 12 +- src/simix/{smx_vm.c => smx_vm.cpp} | 4 +- tools/cmake/DefinePackages.cmake | 46 ++-- tools/cmake/MaintainerMode.cmake | 10 +- 24 files changed, 346 insertions(+), 313 deletions(-) rename src/simix/{libsmx.c => libsmx.cpp} (99%) rename src/simix/{popping.c => popping.cpp} (97%) rename src/simix/{popping_bodies.c => popping_bodies.cpp} (97%) rename src/simix/{popping_generated.c => popping_generated.cpp} (77%) rename src/simix/{smx_context.c => smx_context.cpp} (95%) rename src/simix/{smx_context_base.c => smx_context_base.cpp} (96%) rename src/simix/{smx_context_raw.c => smx_context_raw.cpp} (97%) rename src/simix/{smx_context_sysv.c => smx_context_sysv.cpp} (98%) rename src/simix/{smx_context_thread.c => smx_context_thread.cpp} (100%) rename src/simix/{smx_deployment.c => smx_deployment.cpp} (96%) rename src/simix/{smx_environment.c => smx_environment.cpp} (100%) rename src/simix/{smx_global.c => smx_global.cpp} (97%) rename src/simix/{smx_host.c => smx_host.cpp} (98%) rename src/simix/{smx_io.c => smx_io.cpp} (96%) rename src/simix/{smx_network.c => smx_network.cpp} (97%) rename src/simix/{smx_process.c => smx_process.cpp} (97%) rename src/simix/{smx_synchro.c => smx_synchro.cpp} (97%) rename src/simix/{smx_vm.c => smx_vm.cpp} (98%) diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index 17748fa3fc..7d00215a3b 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -155,11 +155,11 @@ generates the following files: - smx_popping_accessors.h: Helper functions to get and set simcall arguments and results -- smx_popping_bodies.c: +- smx_popping_bodies.cpp: The BODY function of each simcall - smx_popping_enum.c: Definition of type `enum e_smx_simcall_t` (one value per existing simcall) -- smx_popping_generated.c: +- smx_popping_generated.cpp: Definitions of `simcall_names[]` (debug name of each simcall), and SIMIX_simcall_enter() that deals with the simcall from within the kernel diff --git a/include/xbt/ex.h b/include/xbt/ex.h index 9ae8f84766..59e442ba0e 100644 --- a/include/xbt/ex.h +++ b/include/xbt/ex.h @@ -291,7 +291,7 @@ typedef struct { * (that's where we get the process name for the logs and the exception storage) * -- do not mess with it -- */ -typedef struct { +typedef struct xbt_running_ctx_t { __ex_mctx_t *ctx_mctx; /* permanent machine context of enclosing try/catch */ int ctx_caught; /* temporary flag whether exception was caught */ volatile xbt_ex_t exception; /* temporary exception storage */ @@ -304,7 +304,21 @@ typedef struct { /* backtrace */ 0, NULL, /* bt[] */ } } XBT_PUBLIC_DATA(const xbt_running_ctx_t) __xbt_ex_ctx_initializer; -#define XBT_RUNNING_CTX_INITIALIZE(ctx) (*(ctx) = __xbt_ex_ctx_initializer) + +// #define XBT_RUNNING_CTX_INITIALIZE(ctx) (*(ctx) = __xbt_ex_ctx_initializer) + +#define XBT_RUNNING_CTX_INITIALIZE(ctx) \ + (ctx)->ctx_mctx = NULL; \ + (ctx)->ctx_caught = 0; \ + (ctx)->exception.msg = NULL; \ + (ctx)->exception.category = unknown_error; \ + (ctx)->exception.value = 0; \ + (ctx)->exception.procname = NULL; \ + (ctx)->exception.pid = 0; \ + (ctx)->exception.file = NULL; \ + (ctx)->exception.line = 0; \ + (ctx)->exception.used = 0; \ + (ctx)->exception.bt_strings = NULL; /* the exception context */ typedef xbt_running_ctx_t *(*xbt_running_ctx_fetcher_t) (void); diff --git a/include/xbt/swag.h b/include/xbt/swag.h index 8800b4bcb1..b153921393 100644 --- a/include/xbt/swag.h +++ b/include/xbt/swag.h @@ -171,14 +171,30 @@ static XBT_INLINE void *xbt_swag_getFirst(xbt_swag_t swag) Well, safely... Err. You can remove \a obj without having any trouble at least. */ +#ifndef __cplusplus + #define xbt_swag_foreach_safe(obj,obj_next,swag) \ for((obj)=xbt_swag_getFirst((swag)), \ ((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \ - (obj_next=NULL)); \ + (obj_next=NULL)); \ (obj)!=NULL; \ (obj)=obj_next, \ ((obj)?(obj_next=xbt_swag_getNext((obj),(swag)->offset)): \ (obj_next=NULL)) ) + +#else + +#define xbt_swag_foreach_safe(obj,obj_next,swag) \ + for((obj) = (decltype(obj)) xbt_swag_getFirst((swag)), \ + ((obj)?(obj_next = (decltype(obj)) xbt_swag_getNext((obj),(swag)->offset)): \ + (obj_next=NULL)); \ + (obj) != NULL; \ + (obj) = obj_next, \ + ((obj)?(obj_next = (decltype(obj)) xbt_swag_getNext((obj),(swag)->offset)): \ + (obj_next=NULL)) ) + +#endif + /* @} */ SG_END_DECL() diff --git a/src/simix/libsmx.c b/src/simix/libsmx.cpp similarity index 99% rename from src/simix/libsmx.c rename to src/simix/libsmx.cpp index 4db1dab4a0..6abcebd589 100644 --- a/src/simix/libsmx.c +++ b/src/simix/libsmx.cpp @@ -20,7 +20,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix); -#include "popping_bodies.c" +#include "popping_bodies.cpp" /** * \ingroup simix_host_management @@ -299,7 +299,7 @@ void simcall_process_execution_set_affinity(smx_synchro_t execution, sg_host_t h */ e_smx_state_t simcall_process_execution_wait(smx_synchro_t execution) { - return simcall_BODY_process_execution_wait(execution); + return (e_smx_state_t) simcall_BODY_process_execution_wait(execution); } @@ -766,7 +766,7 @@ XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int aut */ XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process) { - return simcall_BODY_process_restart(process); + return (smx_process_t) simcall_BODY_process_restart(process); } /** * \ingroup simix_process_management @@ -783,7 +783,7 @@ e_smx_state_t simcall_process_sleep(double duration) { /* checking for infinite values */ xbt_assert(isfinite(duration), "duration is not finite!"); - return simcall_BODY_process_sleep(duration); + return (e_smx_state_t) simcall_BODY_process_sleep(duration); } /** diff --git a/src/simix/popping.c b/src/simix/popping.cpp similarity index 97% rename from src/simix/popping.c rename to src/simix/popping.cpp index 1fb39ba1b5..eef1ea8f72 100644 --- a/src/simix/popping.c +++ b/src/simix/popping.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2014. The SimGrid Team. +/* Copyright (c) 2010-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it diff --git a/src/simix/popping_bodies.c b/src/simix/popping_bodies.cpp similarity index 97% rename from src/simix/popping_bodies.c rename to src/simix/popping_bodies.cpp index ef7460eaf6..2d3e86d278 100644 --- a/src/simix/popping_bodies.c +++ b/src/simix/popping_bodies.cpp @@ -77,7 +77,7 @@ inline static xbt_dict_t simcall_BODY_host_get_properties(sg_host_t host) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dict_t) self->simcall.result.dp; } inline static xbt_swag_t simcall_BODY_host_get_process_list(sg_host_t host) { @@ -98,7 +98,7 @@ inline static xbt_swag_t simcall_BODY_host_get_process_list(sg_host_t host) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_swag_t) self->simcall.result.dp; } inline static double simcall_BODY_host_get_current_power_peak(sg_host_t host) { @@ -119,7 +119,7 @@ inline static double simcall_BODY_host_get_current_power_peak(sg_host_t host) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.d; + return (double) self->simcall.result.d; } inline static double simcall_BODY_host_get_power_peak_at(sg_host_t host, int pstate_index) { @@ -141,7 +141,7 @@ inline static double simcall_BODY_host_get_power_peak_at(sg_host_t host, int pst } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.d; + return (double) self->simcall.result.d; } inline static double simcall_BODY_host_get_wattmin_at(sg_host_t host, int pstate_index) { @@ -163,7 +163,7 @@ inline static double simcall_BODY_host_get_wattmin_at(sg_host_t host, int pstate } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.d; + return (double) self->simcall.result.d; } inline static double simcall_BODY_host_get_wattmax_at(sg_host_t host, int pstate_index) { @@ -185,7 +185,7 @@ inline static double simcall_BODY_host_get_wattmax_at(sg_host_t host, int pstate } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.d; + return (double) self->simcall.result.d; } inline static void simcall_BODY_host_set_pstate(sg_host_t host, int pstate_index) { @@ -228,7 +228,7 @@ inline static xbt_dict_t simcall_BODY_host_get_mounted_storage_list(sg_host_t ho } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dict_t) self->simcall.result.dp; } inline static xbt_dynar_t simcall_BODY_host_get_attached_storage_list(sg_host_t host) { @@ -249,7 +249,7 @@ inline static xbt_dynar_t simcall_BODY_host_get_attached_storage_list(sg_host_t } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dynar_t) self->simcall.result.dp; } inline static void simcall_BODY_host_get_params(sg_host_t ind_vm, vm_params_t params) { @@ -315,7 +315,7 @@ inline static sg_host_t simcall_BODY_vm_create(const char* name, sg_host_t ind_p } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (sg_host_t) self->simcall.result.dp; } inline static void simcall_BODY_vm_start(sg_host_t ind_vm) { @@ -357,7 +357,7 @@ inline static int simcall_BODY_vm_get_state(sg_host_t ind_vm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void simcall_BODY_vm_migrate(sg_host_t ind_vm, sg_host_t ind_dst_pm) { @@ -400,7 +400,7 @@ inline static void* simcall_BODY_vm_get_pm(sg_host_t ind_vm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (void*) self->simcall.result.dp; } inline static void simcall_BODY_vm_set_bound(sg_host_t ind_vm, double bound) { @@ -623,7 +623,7 @@ inline static void* simcall_BODY_process_create(const char* name, xbt_main_func_ } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (void*) self->simcall.result.dp; } inline static void simcall_BODY_process_kill(smx_process_t process) { @@ -749,7 +749,7 @@ inline static int simcall_BODY_process_count() { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static int simcall_BODY_process_get_PID(smx_process_t process) { @@ -770,7 +770,7 @@ inline static int simcall_BODY_process_get_PID(smx_process_t process) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static int simcall_BODY_process_get_PPID(smx_process_t process) { @@ -791,7 +791,7 @@ inline static int simcall_BODY_process_get_PPID(smx_process_t process) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void* simcall_BODY_process_get_data(smx_process_t process) { @@ -812,7 +812,7 @@ inline static void* simcall_BODY_process_get_data(smx_process_t process) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (void*) self->simcall.result.dp; } inline static void simcall_BODY_process_set_data(smx_process_t process, void* data) { @@ -877,7 +877,7 @@ inline static sg_host_t simcall_BODY_process_get_host(smx_process_t process) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (sg_host_t) self->simcall.result.dp; } inline static const char* simcall_BODY_process_get_name(smx_process_t process) { @@ -898,7 +898,7 @@ inline static const char* simcall_BODY_process_get_name(smx_process_t process) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.cc; + return (const char*) self->simcall.result.cc; } inline static int simcall_BODY_process_is_suspended(smx_process_t process) { @@ -919,7 +919,7 @@ inline static int simcall_BODY_process_is_suspended(smx_process_t process) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static xbt_dict_t simcall_BODY_process_get_properties(smx_process_t process) { @@ -940,7 +940,7 @@ inline static xbt_dict_t simcall_BODY_process_get_properties(smx_process_t proce } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dict_t) self->simcall.result.dp; } inline static int simcall_BODY_process_join(smx_process_t process, double timeout) { @@ -962,7 +962,7 @@ inline static int simcall_BODY_process_join(smx_process_t process, double timeou } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static int simcall_BODY_process_sleep(double duration) { @@ -983,7 +983,7 @@ inline static int simcall_BODY_process_sleep(double duration) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static smx_synchro_t simcall_BODY_process_execute(const char* name, double flops_amount, double priority, double bound, unsigned long affinity_mask) { @@ -1008,7 +1008,7 @@ inline static smx_synchro_t simcall_BODY_process_execute(const char* name, doubl } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_synchro_t) self->simcall.result.dp; } inline static smx_synchro_t simcall_BODY_process_parallel_execute(const char* name, int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount, double amount, double rate) { @@ -1035,7 +1035,7 @@ inline static smx_synchro_t simcall_BODY_process_parallel_execute(const char* na } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_synchro_t) self->simcall.result.dp; } inline static void simcall_BODY_process_execution_destroy(smx_synchro_t execution) { @@ -1098,7 +1098,7 @@ inline static double simcall_BODY_process_execution_get_remains(smx_synchro_t ex } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.d; + return (double) self->simcall.result.d; } inline static e_smx_state_t simcall_BODY_process_execution_get_state(smx_synchro_t execution) { @@ -1119,7 +1119,7 @@ inline static e_smx_state_t simcall_BODY_process_execution_get_state(smx_synchro } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (e_smx_state_t) self->simcall.result.i; } inline static void simcall_BODY_process_execution_set_priority(smx_synchro_t execution, double priority) { @@ -1207,7 +1207,7 @@ inline static int simcall_BODY_process_execution_wait(smx_synchro_t execution) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void simcall_BODY_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void* data) { @@ -1273,7 +1273,7 @@ inline static smx_process_t simcall_BODY_process_restart(smx_process_t process) } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_process_t) self->simcall.result.dp; } inline static smx_rdv_t simcall_BODY_rdv_create(const char* name) { @@ -1294,7 +1294,7 @@ inline static smx_rdv_t simcall_BODY_rdv_create(const char* name) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_rdv_t) self->simcall.result.dp; } inline static void simcall_BODY_rdv_destroy(smx_rdv_t rdv) { @@ -1337,7 +1337,7 @@ inline static unsigned int simcall_BODY_rdv_comm_count_by_host(smx_rdv_t rdv, sg } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.ui; + return (unsigned int) self->simcall.result.ui; } inline static smx_synchro_t simcall_BODY_rdv_get_head(smx_rdv_t rdv) { @@ -1358,7 +1358,7 @@ inline static smx_synchro_t simcall_BODY_rdv_get_head(smx_rdv_t rdv) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_synchro_t) self->simcall.result.dp; } inline static void simcall_BODY_rdv_set_receiver(smx_rdv_t rdv, smx_process_t receiver) { @@ -1401,7 +1401,7 @@ inline static smx_process_t simcall_BODY_rdv_get_receiver(smx_rdv_t rdv) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_process_t) self->simcall.result.dp; } inline static smx_synchro_t simcall_BODY_comm_iprobe(smx_rdv_t rdv, int type, int src, int tag, simix_match_func_t match_fun, void* data) { @@ -1427,7 +1427,7 @@ inline static smx_synchro_t simcall_BODY_comm_iprobe(smx_rdv_t rdv, int type, in } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_synchro_t) self->simcall.result.dp; } inline static void simcall_BODY_comm_send(smx_process_t sender, smx_rdv_t rdv, double task_size, double rate, void* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) { @@ -1488,7 +1488,7 @@ inline static smx_synchro_t simcall_BODY_comm_isend(smx_process_t sender, smx_rd } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_synchro_t) self->simcall.result.dp; } inline static void simcall_BODY_comm_recv(smx_process_t receiver, smx_rdv_t rdv, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) { @@ -1545,7 +1545,7 @@ inline static smx_synchro_t simcall_BODY_comm_irecv(smx_process_t receiver, smx_ } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_synchro_t) self->simcall.result.dp; } inline static void simcall_BODY_comm_cancel(smx_synchro_t comm) { @@ -1587,7 +1587,7 @@ inline static int simcall_BODY_comm_waitany(xbt_dynar_t comms) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void simcall_BODY_comm_wait(smx_synchro_t comm, double timeout) { @@ -1630,7 +1630,7 @@ inline static int simcall_BODY_comm_test(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static int simcall_BODY_comm_testany(xbt_dynar_t comms) { @@ -1651,7 +1651,7 @@ inline static int simcall_BODY_comm_testany(xbt_dynar_t comms) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static double simcall_BODY_comm_get_remains(smx_synchro_t comm) { @@ -1672,7 +1672,7 @@ inline static double simcall_BODY_comm_get_remains(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.d; + return (double) self->simcall.result.d; } inline static e_smx_state_t simcall_BODY_comm_get_state(smx_synchro_t comm) { @@ -1693,7 +1693,7 @@ inline static e_smx_state_t simcall_BODY_comm_get_state(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (e_smx_state_t) self->simcall.result.i; } inline static void* simcall_BODY_comm_get_src_data(smx_synchro_t comm) { @@ -1714,7 +1714,7 @@ inline static void* simcall_BODY_comm_get_src_data(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (void*) self->simcall.result.dp; } inline static void* simcall_BODY_comm_get_dst_data(smx_synchro_t comm) { @@ -1735,7 +1735,7 @@ inline static void* simcall_BODY_comm_get_dst_data(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (void*) self->simcall.result.dp; } inline static smx_process_t simcall_BODY_comm_get_src_proc(smx_synchro_t comm) { @@ -1756,7 +1756,7 @@ inline static smx_process_t simcall_BODY_comm_get_src_proc(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_process_t) self->simcall.result.dp; } inline static smx_process_t simcall_BODY_comm_get_dst_proc(smx_synchro_t comm) { @@ -1777,7 +1777,7 @@ inline static smx_process_t simcall_BODY_comm_get_dst_proc(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_process_t) self->simcall.result.dp; } inline static smx_mutex_t simcall_BODY_mutex_init() { @@ -1798,7 +1798,7 @@ inline static smx_mutex_t simcall_BODY_mutex_init() { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_mutex_t) self->simcall.result.dp; } inline static void simcall_BODY_mutex_destroy(smx_mutex_t mutex) { @@ -1861,7 +1861,7 @@ inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void simcall_BODY_mutex_unlock(smx_mutex_t mutex) { @@ -1903,7 +1903,7 @@ inline static smx_cond_t simcall_BODY_cond_init() { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_cond_t) self->simcall.result.dp; } inline static void simcall_BODY_cond_destroy(smx_cond_t cond) { @@ -2032,7 +2032,7 @@ inline static smx_sem_t simcall_BODY_sem_init(unsigned int capacity) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_sem_t) self->simcall.result.dp; } inline static void simcall_BODY_sem_destroy(smx_sem_t sem) { @@ -2095,7 +2095,7 @@ inline static int simcall_BODY_sem_would_block(smx_sem_t sem) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void simcall_BODY_sem_acquire(smx_sem_t sem) { @@ -2159,7 +2159,7 @@ inline static int simcall_BODY_sem_get_capacity(smx_sem_t sem) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static sg_size_t simcall_BODY_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) { @@ -2182,7 +2182,7 @@ inline static sg_size_t simcall_BODY_file_read(smx_file_t fd, sg_size_t size, sg } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.sgsz; + return (sg_size_t) self->simcall.result.sgsz; } inline static sg_size_t simcall_BODY_file_write(smx_file_t fd, sg_size_t size, sg_host_t host) { @@ -2205,7 +2205,7 @@ inline static sg_size_t simcall_BODY_file_write(smx_file_t fd, sg_size_t size, s } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.sgsz; + return (sg_size_t) self->simcall.result.sgsz; } inline static smx_file_t simcall_BODY_file_open(const char* fullpath, sg_host_t host) { @@ -2227,7 +2227,7 @@ inline static smx_file_t simcall_BODY_file_open(const char* fullpath, sg_host_t } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (smx_file_t) self->simcall.result.dp; } inline static int simcall_BODY_file_close(smx_file_t fd, sg_host_t host) { @@ -2249,7 +2249,7 @@ inline static int simcall_BODY_file_close(smx_file_t fd, sg_host_t host) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static int simcall_BODY_file_unlink(smx_file_t fd, sg_host_t host) { @@ -2271,7 +2271,7 @@ inline static int simcall_BODY_file_unlink(smx_file_t fd, sg_host_t host) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static sg_size_t simcall_BODY_file_get_size(smx_file_t fd) { @@ -2292,7 +2292,7 @@ inline static sg_size_t simcall_BODY_file_get_size(smx_file_t fd) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.sgsz; + return (sg_size_t) self->simcall.result.sgsz; } inline static sg_size_t simcall_BODY_file_tell(smx_file_t fd) { @@ -2313,7 +2313,7 @@ inline static sg_size_t simcall_BODY_file_tell(smx_file_t fd) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.sgsz; + return (sg_size_t) self->simcall.result.sgsz; } inline static int simcall_BODY_file_seek(smx_file_t fd, sg_offset_t offset, int origin) { @@ -2336,7 +2336,7 @@ inline static int simcall_BODY_file_seek(smx_file_t fd, sg_offset_t offset, int } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static xbt_dynar_t simcall_BODY_file_get_info(smx_file_t fd) { @@ -2357,7 +2357,7 @@ inline static xbt_dynar_t simcall_BODY_file_get_info(smx_file_t fd) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dynar_t) self->simcall.result.dp; } inline static int simcall_BODY_file_move(smx_file_t fd, const char* fullpath) { @@ -2379,7 +2379,7 @@ inline static int simcall_BODY_file_move(smx_file_t fd, const char* fullpath) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static sg_size_t simcall_BODY_storage_get_free_size(smx_storage_t storage) { @@ -2400,7 +2400,7 @@ inline static sg_size_t simcall_BODY_storage_get_free_size(smx_storage_t storage } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.sgsz; + return (sg_size_t) self->simcall.result.sgsz; } inline static sg_size_t simcall_BODY_storage_get_used_size(smx_storage_t name) { @@ -2421,7 +2421,7 @@ inline static sg_size_t simcall_BODY_storage_get_used_size(smx_storage_t name) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.sgsz; + return (sg_size_t) self->simcall.result.sgsz; } inline static xbt_dict_t simcall_BODY_storage_get_properties(smx_storage_t storage) { @@ -2442,7 +2442,7 @@ inline static xbt_dict_t simcall_BODY_storage_get_properties(smx_storage_t stora } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dict_t) self->simcall.result.dp; } inline static xbt_dict_t simcall_BODY_storage_get_content(smx_storage_t storage) { @@ -2463,7 +2463,7 @@ inline static xbt_dict_t simcall_BODY_storage_get_content(smx_storage_t storage) } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dict_t) self->simcall.result.dp; } inline static xbt_dict_t simcall_BODY_asr_get_properties(const char* name) { @@ -2484,7 +2484,7 @@ inline static xbt_dict_t simcall_BODY_asr_get_properties(const char* name) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (xbt_dict_t) self->simcall.result.dp; } inline static int simcall_BODY_mc_random(int min, int max) { @@ -2506,7 +2506,7 @@ inline static int simcall_BODY_mc_random(int min, int max) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } inline static void simcall_BODY_set_category(smx_synchro_t synchro, const char* category) { @@ -2550,7 +2550,7 @@ inline static int simcall_BODY_comm_is_latency_bounded(smx_synchro_t comm) { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } #endif @@ -2574,7 +2574,7 @@ inline static mc_snapshot_t simcall_BODY_mc_snapshot() { } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.dp; + return (mc_snapshot_t) self->simcall.result.dp; } inline static int simcall_BODY_mc_compare_snapshots(mc_snapshot_t s1, mc_snapshot_t s2) { @@ -2596,6 +2596,6 @@ inline static int simcall_BODY_mc_compare_snapshots(mc_snapshot_t s1, mc_snapsho } else { SIMIX_simcall_handle(&self->simcall, 0); } - return self->simcall.result.i; + return (int) self->simcall.result.i; } #endif diff --git a/src/simix/popping_generated.c b/src/simix/popping_generated.cpp similarity index 77% rename from src/simix/popping_generated.c rename to src/simix/popping_generated.cpp index 55d72ff32e..7ff297f825 100644 --- a/src/simix/popping_generated.c +++ b/src/simix/popping_generated.cpp @@ -23,130 +23,129 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping); /** @brief Simcalls' names (generated from src/simix/simcalls.in) */ const char* simcall_names[] = { - [SIMCALL_HOST_ON] = "SIMCALL_HOST_ON", - [SIMCALL_HOST_OFF] = "SIMCALL_HOST_OFF", - [SIMCALL_HOST_GET_PROPERTIES] = "SIMCALL_HOST_GET_PROPERTIES", - [SIMCALL_HOST_GET_PROCESS_LIST] = "SIMCALL_HOST_GET_PROCESS_LIST", - [SIMCALL_HOST_GET_CURRENT_POWER_PEAK] = "SIMCALL_HOST_GET_CURRENT_POWER_PEAK", - [SIMCALL_HOST_GET_POWER_PEAK_AT] = "SIMCALL_HOST_GET_POWER_PEAK_AT", - [SIMCALL_HOST_GET_WATTMIN_AT] = "SIMCALL_HOST_GET_WATTMIN_AT", - [SIMCALL_HOST_GET_WATTMAX_AT] = "SIMCALL_HOST_GET_WATTMAX_AT", - [SIMCALL_HOST_SET_PSTATE] = "SIMCALL_HOST_SET_PSTATE", - [SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST] = "SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST", - [SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST] = "SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST", - [SIMCALL_HOST_GET_PARAMS] = "SIMCALL_HOST_GET_PARAMS", - [SIMCALL_HOST_SET_PARAMS] = "SIMCALL_HOST_SET_PARAMS", - [SIMCALL_VM_CREATE] = "SIMCALL_VM_CREATE", - [SIMCALL_VM_START] = "SIMCALL_VM_START", - [SIMCALL_VM_GET_STATE] = "SIMCALL_VM_GET_STATE", - [SIMCALL_VM_MIGRATE] = "SIMCALL_VM_MIGRATE", - [SIMCALL_VM_GET_PM] = "SIMCALL_VM_GET_PM", - [SIMCALL_VM_SET_BOUND] = "SIMCALL_VM_SET_BOUND", - [SIMCALL_VM_SET_AFFINITY] = "SIMCALL_VM_SET_AFFINITY", - [SIMCALL_VM_DESTROY] = "SIMCALL_VM_DESTROY", - [SIMCALL_VM_SUSPEND] = "SIMCALL_VM_SUSPEND", - [SIMCALL_VM_RESUME] = "SIMCALL_VM_RESUME", - [SIMCALL_VM_SHUTDOWN] = "SIMCALL_VM_SHUTDOWN", - [SIMCALL_VM_SAVE] = "SIMCALL_VM_SAVE", - [SIMCALL_VM_RESTORE] = "SIMCALL_VM_RESTORE", - [SIMCALL_VM_MIGRATEFROM_RESUMETO] = "SIMCALL_VM_MIGRATEFROM_RESUMETO", - [SIMCALL_PROCESS_CREATE] = "SIMCALL_PROCESS_CREATE", - [SIMCALL_PROCESS_KILL] = "SIMCALL_PROCESS_KILL", - [SIMCALL_PROCESS_KILLALL] = "SIMCALL_PROCESS_KILLALL", - [SIMCALL_PROCESS_CLEANUP] = "SIMCALL_PROCESS_CLEANUP", - [SIMCALL_PROCESS_SUSPEND] = "SIMCALL_PROCESS_SUSPEND", - [SIMCALL_PROCESS_RESUME] = "SIMCALL_PROCESS_RESUME", - [SIMCALL_PROCESS_COUNT] = "SIMCALL_PROCESS_COUNT", - [SIMCALL_PROCESS_GET_PID] = "SIMCALL_PROCESS_GET_PID", - [SIMCALL_PROCESS_GET_PPID] = "SIMCALL_PROCESS_GET_PPID", - [SIMCALL_PROCESS_GET_DATA] = "SIMCALL_PROCESS_GET_DATA", - [SIMCALL_PROCESS_SET_DATA] = "SIMCALL_PROCESS_SET_DATA", - [SIMCALL_PROCESS_SET_HOST] = "SIMCALL_PROCESS_SET_HOST", - [SIMCALL_PROCESS_GET_HOST] = "SIMCALL_PROCESS_GET_HOST", - [SIMCALL_PROCESS_GET_NAME] = "SIMCALL_PROCESS_GET_NAME", - [SIMCALL_PROCESS_IS_SUSPENDED] = "SIMCALL_PROCESS_IS_SUSPENDED", - [SIMCALL_PROCESS_GET_PROPERTIES] = "SIMCALL_PROCESS_GET_PROPERTIES", - [SIMCALL_PROCESS_JOIN] = "SIMCALL_PROCESS_JOIN", - [SIMCALL_PROCESS_SLEEP] = "SIMCALL_PROCESS_SLEEP", - [SIMCALL_PROCESS_EXECUTE] = "SIMCALL_PROCESS_EXECUTE", - [SIMCALL_PROCESS_PARALLEL_EXECUTE] = "SIMCALL_PROCESS_PARALLEL_EXECUTE", - [SIMCALL_PROCESS_EXECUTION_DESTROY] = "SIMCALL_PROCESS_EXECUTION_DESTROY", - [SIMCALL_PROCESS_EXECUTION_CANCEL] = "SIMCALL_PROCESS_EXECUTION_CANCEL", - [SIMCALL_PROCESS_EXECUTION_GET_REMAINS] = "SIMCALL_PROCESS_EXECUTION_GET_REMAINS", - [SIMCALL_PROCESS_EXECUTION_GET_STATE] = "SIMCALL_PROCESS_EXECUTION_GET_STATE", - [SIMCALL_PROCESS_EXECUTION_SET_PRIORITY] = "SIMCALL_PROCESS_EXECUTION_SET_PRIORITY", - [SIMCALL_PROCESS_EXECUTION_SET_BOUND] = "SIMCALL_PROCESS_EXECUTION_SET_BOUND", - [SIMCALL_PROCESS_EXECUTION_SET_AFFINITY] = "SIMCALL_PROCESS_EXECUTION_SET_AFFINITY", - [SIMCALL_PROCESS_EXECUTION_WAIT] = "SIMCALL_PROCESS_EXECUTION_WAIT", - [SIMCALL_PROCESS_ON_EXIT] = "SIMCALL_PROCESS_ON_EXIT", - [SIMCALL_PROCESS_AUTO_RESTART_SET] = "SIMCALL_PROCESS_AUTO_RESTART_SET", - [SIMCALL_PROCESS_RESTART] = "SIMCALL_PROCESS_RESTART", - [SIMCALL_RDV_CREATE] = "SIMCALL_RDV_CREATE", - [SIMCALL_RDV_DESTROY] = "SIMCALL_RDV_DESTROY", - [SIMCALL_RDV_COMM_COUNT_BY_HOST] = "SIMCALL_RDV_COMM_COUNT_BY_HOST", - [SIMCALL_RDV_GET_HEAD] = "SIMCALL_RDV_GET_HEAD", - [SIMCALL_RDV_SET_RECEIVER] = "SIMCALL_RDV_SET_RECEIVER", - [SIMCALL_RDV_GET_RECEIVER] = "SIMCALL_RDV_GET_RECEIVER", - [SIMCALL_COMM_IPROBE] = "SIMCALL_COMM_IPROBE", - [SIMCALL_COMM_SEND] = "SIMCALL_COMM_SEND", - [SIMCALL_COMM_ISEND] = "SIMCALL_COMM_ISEND", - [SIMCALL_COMM_RECV] = "SIMCALL_COMM_RECV", - [SIMCALL_COMM_IRECV] = "SIMCALL_COMM_IRECV", - [SIMCALL_COMM_CANCEL] = "SIMCALL_COMM_CANCEL", - [SIMCALL_COMM_WAITANY] = "SIMCALL_COMM_WAITANY", - [SIMCALL_COMM_WAIT] = "SIMCALL_COMM_WAIT", - [SIMCALL_COMM_TEST] = "SIMCALL_COMM_TEST", - [SIMCALL_COMM_TESTANY] = "SIMCALL_COMM_TESTANY", - [SIMCALL_COMM_GET_REMAINS] = "SIMCALL_COMM_GET_REMAINS", - [SIMCALL_COMM_GET_STATE] = "SIMCALL_COMM_GET_STATE", - [SIMCALL_COMM_GET_SRC_DATA] = "SIMCALL_COMM_GET_SRC_DATA", - [SIMCALL_COMM_GET_DST_DATA] = "SIMCALL_COMM_GET_DST_DATA", - [SIMCALL_COMM_GET_SRC_PROC] = "SIMCALL_COMM_GET_SRC_PROC", - [SIMCALL_COMM_GET_DST_PROC] = "SIMCALL_COMM_GET_DST_PROC", - [SIMCALL_MUTEX_INIT] = "SIMCALL_MUTEX_INIT", - [SIMCALL_MUTEX_DESTROY] = "SIMCALL_MUTEX_DESTROY", - [SIMCALL_MUTEX_LOCK] = "SIMCALL_MUTEX_LOCK", - [SIMCALL_MUTEX_TRYLOCK] = "SIMCALL_MUTEX_TRYLOCK", - [SIMCALL_MUTEX_UNLOCK] = "SIMCALL_MUTEX_UNLOCK", - [SIMCALL_COND_INIT] = "SIMCALL_COND_INIT", - [SIMCALL_COND_DESTROY] = "SIMCALL_COND_DESTROY", - [SIMCALL_COND_SIGNAL] = "SIMCALL_COND_SIGNAL", - [SIMCALL_COND_WAIT] = "SIMCALL_COND_WAIT", - [SIMCALL_COND_WAIT_TIMEOUT] = "SIMCALL_COND_WAIT_TIMEOUT", - [SIMCALL_COND_BROADCAST] = "SIMCALL_COND_BROADCAST", - [SIMCALL_SEM_INIT] = "SIMCALL_SEM_INIT", - [SIMCALL_SEM_DESTROY] = "SIMCALL_SEM_DESTROY", - [SIMCALL_SEM_RELEASE] = "SIMCALL_SEM_RELEASE", - [SIMCALL_SEM_WOULD_BLOCK] = "SIMCALL_SEM_WOULD_BLOCK", - [SIMCALL_SEM_ACQUIRE] = "SIMCALL_SEM_ACQUIRE", - [SIMCALL_SEM_ACQUIRE_TIMEOUT] = "SIMCALL_SEM_ACQUIRE_TIMEOUT", - [SIMCALL_SEM_GET_CAPACITY] = "SIMCALL_SEM_GET_CAPACITY", - [SIMCALL_FILE_READ] = "SIMCALL_FILE_READ", - [SIMCALL_FILE_WRITE] = "SIMCALL_FILE_WRITE", - [SIMCALL_FILE_OPEN] = "SIMCALL_FILE_OPEN", - [SIMCALL_FILE_CLOSE] = "SIMCALL_FILE_CLOSE", - [SIMCALL_FILE_UNLINK] = "SIMCALL_FILE_UNLINK", - [SIMCALL_FILE_GET_SIZE] = "SIMCALL_FILE_GET_SIZE", - [SIMCALL_FILE_TELL] = "SIMCALL_FILE_TELL", - [SIMCALL_FILE_SEEK] = "SIMCALL_FILE_SEEK", - [SIMCALL_FILE_GET_INFO] = "SIMCALL_FILE_GET_INFO", - [SIMCALL_FILE_MOVE] = "SIMCALL_FILE_MOVE", - [SIMCALL_STORAGE_GET_FREE_SIZE] = "SIMCALL_STORAGE_GET_FREE_SIZE", - [SIMCALL_STORAGE_GET_USED_SIZE] = "SIMCALL_STORAGE_GET_USED_SIZE", - [SIMCALL_STORAGE_GET_PROPERTIES] = "SIMCALL_STORAGE_GET_PROPERTIES", - [SIMCALL_STORAGE_GET_CONTENT] = "SIMCALL_STORAGE_GET_CONTENT", - [SIMCALL_ASR_GET_PROPERTIES] = "SIMCALL_ASR_GET_PROPERTIES", - [SIMCALL_MC_RANDOM] = "SIMCALL_MC_RANDOM", - [SIMCALL_SET_CATEGORY] = "SIMCALL_SET_CATEGORY", + "SIMCALL_NONE", "SIMCALL_HOST_ON", + "SIMCALL_HOST_OFF", + "SIMCALL_HOST_GET_PROPERTIES", + "SIMCALL_HOST_GET_PROCESS_LIST", + "SIMCALL_HOST_GET_CURRENT_POWER_PEAK", + "SIMCALL_HOST_GET_POWER_PEAK_AT", + "SIMCALL_HOST_GET_WATTMIN_AT", + "SIMCALL_HOST_GET_WATTMAX_AT", + "SIMCALL_HOST_SET_PSTATE", + "SIMCALL_HOST_GET_MOUNTED_STORAGE_LIST", + "SIMCALL_HOST_GET_ATTACHED_STORAGE_LIST", + "SIMCALL_HOST_GET_PARAMS", + "SIMCALL_HOST_SET_PARAMS", + "SIMCALL_VM_CREATE", + "SIMCALL_VM_START", + "SIMCALL_VM_GET_STATE", + "SIMCALL_VM_MIGRATE", + "SIMCALL_VM_GET_PM", + "SIMCALL_VM_SET_BOUND", + "SIMCALL_VM_SET_AFFINITY", + "SIMCALL_VM_DESTROY", + "SIMCALL_VM_SUSPEND", + "SIMCALL_VM_RESUME", + "SIMCALL_VM_SHUTDOWN", + "SIMCALL_VM_SAVE", + "SIMCALL_VM_RESTORE", + "SIMCALL_VM_MIGRATEFROM_RESUMETO", + "SIMCALL_PROCESS_CREATE", + "SIMCALL_PROCESS_KILL", + "SIMCALL_PROCESS_KILLALL", + "SIMCALL_PROCESS_CLEANUP", + "SIMCALL_PROCESS_SUSPEND", + "SIMCALL_PROCESS_RESUME", + "SIMCALL_PROCESS_COUNT", + "SIMCALL_PROCESS_GET_PID", + "SIMCALL_PROCESS_GET_PPID", + "SIMCALL_PROCESS_GET_DATA", + "SIMCALL_PROCESS_SET_DATA", + "SIMCALL_PROCESS_SET_HOST", + "SIMCALL_PROCESS_GET_HOST", + "SIMCALL_PROCESS_GET_NAME", + "SIMCALL_PROCESS_IS_SUSPENDED", + "SIMCALL_PROCESS_GET_PROPERTIES", + "SIMCALL_PROCESS_JOIN", + "SIMCALL_PROCESS_SLEEP", + "SIMCALL_PROCESS_EXECUTE", + "SIMCALL_PROCESS_PARALLEL_EXECUTE", + "SIMCALL_PROCESS_EXECUTION_DESTROY", + "SIMCALL_PROCESS_EXECUTION_CANCEL", + "SIMCALL_PROCESS_EXECUTION_GET_REMAINS", + "SIMCALL_PROCESS_EXECUTION_GET_STATE", + "SIMCALL_PROCESS_EXECUTION_SET_PRIORITY", + "SIMCALL_PROCESS_EXECUTION_SET_BOUND", + "SIMCALL_PROCESS_EXECUTION_SET_AFFINITY", + "SIMCALL_PROCESS_EXECUTION_WAIT", + "SIMCALL_PROCESS_ON_EXIT", + "SIMCALL_PROCESS_AUTO_RESTART_SET", + "SIMCALL_PROCESS_RESTART", + "SIMCALL_RDV_CREATE", + "SIMCALL_RDV_DESTROY", + "SIMCALL_RDV_COMM_COUNT_BY_HOST", + "SIMCALL_RDV_GET_HEAD", + "SIMCALL_RDV_SET_RECEIVER", + "SIMCALL_RDV_GET_RECEIVER", + "SIMCALL_COMM_IPROBE", + "SIMCALL_COMM_SEND", + "SIMCALL_COMM_ISEND", + "SIMCALL_COMM_RECV", + "SIMCALL_COMM_IRECV", + "SIMCALL_COMM_CANCEL", + "SIMCALL_COMM_WAITANY", + "SIMCALL_COMM_WAIT", + "SIMCALL_COMM_TEST", + "SIMCALL_COMM_TESTANY", + "SIMCALL_COMM_GET_REMAINS", + "SIMCALL_COMM_GET_STATE", + "SIMCALL_COMM_GET_SRC_DATA", + "SIMCALL_COMM_GET_DST_DATA", + "SIMCALL_COMM_GET_SRC_PROC", + "SIMCALL_COMM_GET_DST_PROC", + "SIMCALL_MUTEX_INIT", + "SIMCALL_MUTEX_DESTROY", + "SIMCALL_MUTEX_LOCK", + "SIMCALL_MUTEX_TRYLOCK", + "SIMCALL_MUTEX_UNLOCK", + "SIMCALL_COND_INIT", + "SIMCALL_COND_DESTROY", + "SIMCALL_COND_SIGNAL", + "SIMCALL_COND_WAIT", + "SIMCALL_COND_WAIT_TIMEOUT", + "SIMCALL_COND_BROADCAST", + "SIMCALL_SEM_INIT", + "SIMCALL_SEM_DESTROY", + "SIMCALL_SEM_RELEASE", + "SIMCALL_SEM_WOULD_BLOCK", + "SIMCALL_SEM_ACQUIRE", + "SIMCALL_SEM_ACQUIRE_TIMEOUT", + "SIMCALL_SEM_GET_CAPACITY", + "SIMCALL_FILE_READ", + "SIMCALL_FILE_WRITE", + "SIMCALL_FILE_OPEN", + "SIMCALL_FILE_CLOSE", + "SIMCALL_FILE_UNLINK", + "SIMCALL_FILE_GET_SIZE", + "SIMCALL_FILE_TELL", + "SIMCALL_FILE_SEEK", + "SIMCALL_FILE_GET_INFO", + "SIMCALL_FILE_MOVE", + "SIMCALL_STORAGE_GET_FREE_SIZE", + "SIMCALL_STORAGE_GET_USED_SIZE", + "SIMCALL_STORAGE_GET_PROPERTIES", + "SIMCALL_STORAGE_GET_CONTENT", + "SIMCALL_ASR_GET_PROPERTIES", + "SIMCALL_MC_RANDOM", + "SIMCALL_SET_CATEGORY", #ifdef HAVE_LATENCY_BOUND_TRACKING - [SIMCALL_COMM_IS_LATENCY_BOUNDED] = "SIMCALL_COMM_IS_LATENCY_BOUNDED", + "SIMCALL_COMM_IS_LATENCY_BOUNDED", #endif #ifdef HAVE_MC - [SIMCALL_MC_SNAPSHOT] = "SIMCALL_MC_SNAPSHOT", - [SIMCALL_MC_COMPARE_SNAPSHOTS] = "SIMCALL_MC_COMPARE_SNAPSHOTS", + "SIMCALL_MC_SNAPSHOT", + "SIMCALL_MC_COMPARE_SNAPSHOTS", #endif -[SIMCALL_NONE] = "NONE" }; /** diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index e65b78a757..e1c55e4958 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2014. The SimGrid Team. All rights reserved. +# Copyright (c) 2014-2015. The SimGrid Team. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. @@ -58,7 +58,7 @@ class Simcall(object): def check(self): # libsmx.c simcall_BODY_ if self.simcalls_BODY is None: - f = open('libsmx.c') + f = open('libsmx.cpp') self.simcalls_BODY = set(re.findall('simcall_BODY_(.*?)\(', f.read())) f.close() if self.name not in self.simcalls_BODY: @@ -98,7 +98,7 @@ class Simcall(object): return ' SIMCALL_%s,'%(self.name.upper()) def string(self): - return ' [SIMCALL_%s] = "SIMCALL_%s",'%(self.name.upper(), self.name.upper()) + return ' "SIMCALL_%s",'% self.name.upper() def accessors(self): res = [] @@ -168,7 +168,8 @@ class Simcall(object): res.append(' SIMIX_simcall_handle(&self->simcall, 0);') res.append(' } ') if self.res.type != 'void': - res.append(' return self->simcall.result.%s;'%self.res.field()) + res.append(' return (%s) self->simcall.result.%s;' % + (self.res.rettype(), self.res.field())) else: res.append(' ') res.append(' }') @@ -274,10 +275,10 @@ if __name__=='__main__': fd.close() ### - ### smx_popping_generated.c + ### smx_popping_generated.cpp ### - fd = header("popping_generated.c") + fd = header("popping_generated.cpp") fd.write('#include \n'); fd.write('#include "smx_private.h"\n'); @@ -290,9 +291,9 @@ if __name__=='__main__': fd.write('/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n') fd.write('const char* simcall_names[] = {\n') + fd.write(' "SIMCALL_NONE",'); handle(fd, Simcall.string, simcalls, simcalls_dict) - fd.write('[SIMCALL_NONE] = "NONE"\n') fd.write('};\n\n') @@ -325,9 +326,9 @@ if __name__=='__main__': fd.close() ### - ### smx_popping_bodies.c + ### smx_popping_bodies.cpp ### - fd = header('popping_bodies.c') + fd = header('popping_bodies.cpp') fd.write('#include "smx_private.h"\n') fd.write('#include "src/mc/mc_forward.h"\n') fd.write('#include "xbt/ex.h"\n') diff --git a/src/simix/smx_context.c b/src/simix/smx_context.cpp similarity index 95% rename from src/simix/smx_context.c rename to src/simix/smx_context.cpp index a801c0451b..ace2095439 100644 --- a/src/simix/smx_context.c +++ b/src/simix/smx_context.cpp @@ -220,7 +220,7 @@ void SIMIX_context_stack_delete(void *stack) * for the user contexts. * \return 1 if parallelism is used */ -XBT_INLINE int SIMIX_context_is_parallel(void) { +int SIMIX_context_is_parallel(void) { return smx_parallel_contexts > 1; } @@ -229,7 +229,7 @@ XBT_INLINE int SIMIX_context_is_parallel(void) { * for the user contexts. * \return the number of threads (1 means no parallelism) */ -XBT_INLINE int SIMIX_context_get_nthreads(void) { +int SIMIX_context_get_nthreads(void) { return smx_parallel_contexts; } @@ -266,7 +266,7 @@ void SIMIX_context_set_nthreads(int nb_threads) { * \return when the number of user processes ready to run is above * this threshold, they are run in parallel */ -XBT_INLINE int SIMIX_context_get_parallel_threshold(void) { +int SIMIX_context_get_parallel_threshold(void) { return smx_parallel_threshold; } @@ -279,7 +279,7 @@ XBT_INLINE int SIMIX_context_get_parallel_threshold(void) { * \param threshold when the number of user processes ready to run is above * this threshold, they are run in parallel */ -XBT_INLINE void SIMIX_context_set_parallel_threshold(int threshold) { +void SIMIX_context_set_parallel_threshold(int threshold) { smx_parallel_threshold = threshold; } @@ -288,7 +288,7 @@ XBT_INLINE void SIMIX_context_set_parallel_threshold(int threshold) { * parallel. * \return how threads are synchronized if processes are run in parallel */ -XBT_INLINE e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode(void) { +e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode(void) { return smx_parallel_synchronization_mode; } @@ -297,7 +297,7 @@ XBT_INLINE e_xbt_parmap_mode_t SIMIX_context_get_parallel_mode(void) { * parallel. * \param mode how to synchronize threads if processes are run in parallel */ -XBT_INLINE void SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode) { +void SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode) { smx_parallel_synchronization_mode = mode; } @@ -305,7 +305,7 @@ XBT_INLINE void SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode) { * \brief Returns the current context of this thread. * \return the current context of this thread */ -XBT_INLINE smx_context_t SIMIX_context_get_current(void) +smx_context_t SIMIX_context_get_current(void) { if (SIMIX_context_is_parallel()) { #ifdef HAVE_THREAD_LOCAL_STORAGE @@ -323,7 +323,7 @@ XBT_INLINE smx_context_t SIMIX_context_get_current(void) * \brief Sets the current context of this thread. * \param context the context to set */ -XBT_INLINE void SIMIX_context_set_current(smx_context_t context) +void SIMIX_context_set_current(smx_context_t context) { if (SIMIX_context_is_parallel()) { #ifdef HAVE_THREAD_LOCAL_STORAGE diff --git a/src/simix/smx_context_base.c b/src/simix/smx_context_base.cpp similarity index 96% rename from src/simix/smx_context_base.c rename to src/simix/smx_context_base.cpp index 5dc3a74c76..8b8231aa66 100644 --- a/src/simix/smx_context_base.c +++ b/src/simix/smx_context_base.cpp @@ -1,6 +1,6 @@ /* context_base - Code factorization across context switching implementations */ -/* Copyright (c) 2010-2014. The SimGrid Team. +/* Copyright (c) 2010-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code, void_pfn_smxprocess_t cleanup_func, smx_process_t process) { - smx_context_t context = xbt_malloc0(size); + smx_context_t context = (smx_context_t) xbt_malloc0(size); /* Store the address of the stack in heap to compare it apart of heap comparison */ if(MC_is_active()) diff --git a/src/simix/smx_context_raw.c b/src/simix/smx_context_raw.cpp similarity index 97% rename from src/simix/smx_context_raw.c rename to src/simix/smx_context_raw.cpp index 60fad1596b..5ce86a91e0 100644 --- a/src/simix/smx_context_raw.c +++ b/src/simix/smx_context_raw.cpp @@ -1,6 +1,6 @@ /* context_raw - fast context switching inspired from System V ucontexts */ -/* Copyright (c) 2009-2014. The SimGrid Team. +/* Copyright (c) 2009-2015. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -50,9 +50,9 @@ long long par_window=(long long)HUGE_VAL,seq_window=0; static unsigned long raw_process_index = 0; /* index of the next process to run in the * list of runnable processes */ static smx_ctx_raw_t raw_maestro_context; -extern raw_stack_t raw_makecontext(char* malloced_stack, int stack_size, +extern "C" raw_stack_t raw_makecontext(char* malloced_stack, int stack_size, rawctx_entry_point_t entry_point, void* arg); -extern void raw_swapcontext(raw_stack_t* old, raw_stack_t new); +extern "C" void raw_swapcontext(raw_stack_t* old, raw_stack_t new_context); #if PROCESSOR_x86_64 __asm__ ( @@ -198,7 +198,7 @@ raw_stack_t raw_makecontext(char* malloced_stack, int stack_size, THROW_UNIMPLEMENTED; } -void raw_swapcontext(raw_stack_t* old, raw_stack_t new) { +void raw_swapcontext(raw_stack_t* old, raw_stack_t new_context) { THROW_UNIMPLEMENTED; } @@ -350,7 +350,7 @@ smx_ctx_raw_create_context(xbt_main_func_t code, int argc, char **argv, /* if the user provided a function for the process then use it, otherwise it is the context for maestro */ if (code) { - context->malloced_stack = SIMIX_context_stack_new(); + context->malloced_stack = (char*) SIMIX_context_stack_new(); context->stack_top = raw_makecontext(context->malloced_stack, smx_context_usable_stack_size, @@ -537,7 +537,7 @@ static void smx_ctx_raw_suspend_parallel(smx_context_t context) { #ifdef CONTEXT_THREADS /* determine the next context */ - smx_process_t next_work = xbt_parmap_next(raw_parmap); + smx_process_t next_work = (smx_process_t) xbt_parmap_next(raw_parmap); smx_context_t next_context; raw_stack_t next_stack; @@ -691,7 +691,8 @@ static void smx_ctx_raw_runall(void) double elapsed = 0; #endif unsigned long nb_processes = xbt_dynar_length(simix_global->process_to_run); - if (SIMIX_context_is_parallel() && SIMIX_context_get_parallel_threshold()context_factory->suspend = smx_ctx_raw_suspend_parallel; diff --git a/src/simix/smx_context_sysv.c b/src/simix/smx_context_sysv.cpp similarity index 98% rename from src/simix/smx_context_sysv.c rename to src/simix/smx_context_sysv.cpp index 050249923d..e89857d666 100644 --- a/src/simix/smx_context_sysv.c +++ b/src/simix/smx_context_sysv.cpp @@ -122,7 +122,7 @@ smx_ctx_sysv_create_context(xbt_main_func_t code, int argc, char **argv, otherwise it is the context for maestro */ if (code) { - context->stack = SIMIX_context_stack_new(); + context->stack = (char*) SIMIX_context_stack_new(); getcontext(&(context->uc)); context->uc.uc_link = NULL; @@ -179,9 +179,8 @@ static void smx_ctx_sysv_wrapper(int first, ...) ctx_addr[0] = first; if (CTX_ADDR_LEN > 1) { va_list ap; - int i; va_start(ap, first); - for (i = 1; i < CTX_ADDR_LEN; i++) + for (unsigned i = 1; i < CTX_ADDR_LEN; i++) ctx_addr[i] = va_arg(ap, int); va_end(ap); } @@ -287,7 +286,7 @@ static void smx_ctx_sysv_resume_parallel(smx_process_t simulated_process_to_run) static void smx_ctx_sysv_suspend_parallel(smx_context_t context) { #ifdef CONTEXT_THREADS /* determine the next context */ - smx_process_t next_work = xbt_parmap_next(sysv_parmap); // get the next soul to embody now + smx_process_t next_work = (smx_process_t) xbt_parmap_next(sysv_parmap); // get the next soul to embody now smx_context_t next_context; ucontext_t* next_stack; // will contain the next soul to run, either simulated or initial minion's one diff --git a/src/simix/smx_context_thread.c b/src/simix/smx_context_thread.cpp similarity index 100% rename from src/simix/smx_context_thread.c rename to src/simix/smx_context_thread.cpp diff --git a/src/simix/smx_deployment.c b/src/simix/smx_deployment.cpp similarity index 96% rename from src/simix/smx_deployment.c rename to src/simix/smx_deployment.cpp index 97f4bb4d1c..1b7be72fb5 100644 --- a/src/simix/smx_deployment.c +++ b/src/simix/smx_deployment.cpp @@ -63,13 +63,12 @@ void SIMIX_launch_application(const char *file) * \param name the reference name of the function. * \param code the function */ -XBT_INLINE void SIMIX_function_register(const char *name, +void SIMIX_function_register(const char *name, xbt_main_func_t code) { xbt_assert(simix_global, - "SIMIX_global_init has to be called before SIMIX_function_register."); - - xbt_dict_set(simix_global->registered_functions, name, code, NULL); + "SIMIX_global_init has to be called before SIMIX_function_register."); + xbt_dict_set(simix_global->registered_functions, name, (void*) code, NULL); } static xbt_main_func_t default_function = NULL; diff --git a/src/simix/smx_environment.c b/src/simix/smx_environment.cpp similarity index 100% rename from src/simix/smx_environment.c rename to src/simix/smx_environment.cpp diff --git a/src/simix/smx_global.c b/src/simix/smx_global.cpp similarity index 97% rename from src/simix/smx_global.c rename to src/simix/smx_global.cpp index b37a920044..0f00476f6e 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.cpp @@ -149,7 +149,7 @@ static void install_segvhandler(void) #endif /********************************* SIMIX **************************************/ -XBT_INLINE double SIMIX_timer_next(void) +double SIMIX_timer_next(void) { return xbt_heap_size(simix_timers) > 0 ? xbt_heap_maxkey(simix_timers) : -1.0; } @@ -329,7 +329,7 @@ void SIMIX_clean(void) * * \return Return the clock. */ -XBT_INLINE double SIMIX_get_clock(void) +double SIMIX_get_clock(void) { if(MC_is_active() || MC_record_replay_is_active()){ return MC_process_clock_get(SIMIX_process_self()); @@ -486,7 +486,7 @@ void SIMIX_run(void) while (xbt_heap_size(simix_timers) > 0 && SIMIX_get_clock() >= SIMIX_timer_next()) { //FIXME: make the timers being real callbacks // (i.e. provide dispatchers that read and expand the args) - timer = xbt_heap_pop(simix_timers); + timer = (smx_timer_t) xbt_heap_pop(simix_timers); if (timer->func) timer->func(timer->args); xbt_free(timer); @@ -546,7 +546,7 @@ void SIMIX_run(void) * \param arg Parameters of the function * */ -XBT_INLINE smx_timer_t SIMIX_timer_set(double date, void (*function)(void*), void *arg) +smx_timer_t SIMIX_timer_set(double date, void (*function)(void*), void *arg) { smx_timer_t timer = xbt_new0(s_smx_timer_t, 1); @@ -557,12 +557,12 @@ XBT_INLINE smx_timer_t SIMIX_timer_set(double date, void (*function)(void*), voi return timer; } /** @brief cancels a timer that was added earlier */ -XBT_INLINE void SIMIX_timer_remove(smx_timer_t timer) { +void SIMIX_timer_remove(smx_timer_t timer) { xbt_heap_rm_elm(simix_timers, timer, timer->date); } /** @brief Returns the date at which the timer will trigger (or 0 if NULL timer) */ -XBT_INLINE double SIMIX_timer_get_date(smx_timer_t timer) { +double SIMIX_timer_get_date(smx_timer_t timer) { return timer?timer->date:0; } @@ -574,7 +574,7 @@ XBT_INLINE double SIMIX_timer_get_date(smx_timer_t timer) { * to call SIMIX_process_create(). * \param function create process function */ -XBT_INLINE void SIMIX_function_register_process_create(smx_creation_func_t +void SIMIX_function_register_process_create(smx_creation_func_t function) { simix_global->create_process_function = function; @@ -588,7 +588,7 @@ XBT_INLINE void SIMIX_function_register_process_create(smx_creation_func_t * * \param function Kill process function */ -XBT_INLINE void SIMIX_function_register_process_kill(void_pfn_smxprocess_t +void SIMIX_function_register_process_kill(void_pfn_smxprocess_t function) { simix_global->kill_process_function = function; @@ -602,7 +602,7 @@ XBT_INLINE void SIMIX_function_register_process_kill(void_pfn_smxprocess_t * * \param function cleanup process function */ -XBT_INLINE void SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t +void SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function) { simix_global->cleanup_process_function = function; @@ -693,5 +693,5 @@ xbt_dict_t simcall_HANDLER_asr_get_properties(smx_simcall_t simcall, const char } xbt_dict_t SIMIX_asr_get_properties(const char *name) { - return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL); + return (xbt_dict_t) xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL); } diff --git a/src/simix/smx_host.c b/src/simix/smx_host.cpp similarity index 98% rename from src/simix/smx_host.c rename to src/simix/smx_host.cpp index 982545b254..363423b5f6 100644 --- a/src/simix/smx_host.c +++ b/src/simix/smx_host.cpp @@ -193,7 +193,7 @@ double SIMIX_host_get_wattmax_at(sg_host_t host,int pstate) { void _SIMIX_host_free_process_arg(void *data) { - smx_process_arg_t arg = *(void**)data; + smx_process_arg_t arg = *(smx_process_arg_t*)data; int i; for (i = 0; i < arg->argc; i++) xbt_free(arg->argv[i]); @@ -274,7 +274,7 @@ void SIMIX_host_restart_processes(sg_host_t host) NULL); } else { simcall_process_create(arg->argv[0], - arg->code, + (xbt_main_func_t) arg->code, NULL, arg->hostname, arg->kill_time, @@ -308,7 +308,7 @@ smx_synchro_t SIMIX_process_execute(smx_process_t issuer, const char *name, double flops_amount, double priority, double bound, unsigned long affinity_mask){ /* alloc structures and initialize */ - smx_synchro_t synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + smx_synchro_t synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_EXECUTE; synchro->name = xbt_strdup(name); synchro->state = SIMIX_RUNNING; @@ -351,7 +351,7 @@ smx_synchro_t SIMIX_process_parallel_execute(const char *name, int i; /* alloc structures and initialize */ - smx_synchro_t synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + smx_synchro_t synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_PARALLEL_EXECUTE; synchro->name = xbt_strdup(name); synchro->state = SIMIX_RUNNING; diff --git a/src/simix/smx_io.c b/src/simix/smx_io.cpp similarity index 96% rename from src/simix/smx_io.c rename to src/simix/smx_io.cpp index 241e56954f..3866492b03 100644 --- a/src/simix/smx_io.c +++ b/src/simix/smx_io.cpp @@ -66,7 +66,7 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host) sg_host_get_name(host)); } - synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_IO; synchro->name = NULL; synchro->category = NULL; @@ -98,7 +98,7 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host) sg_host_get_name(host)); } - synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_IO; synchro->name = NULL; synchro->category = NULL; @@ -130,7 +130,7 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, sg_host_t host) sg_host_get_name(host)); } - synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_IO; synchro->name = NULL; synchro->category = NULL; @@ -162,7 +162,7 @@ smx_synchro_t SIMIX_file_close(smx_file_t fd, sg_host_t host) sg_host_get_name(host)); } - synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_IO; synchro->name = NULL; synchro->category = NULL; @@ -274,7 +274,8 @@ sg_size_t SIMIX_storage_get_used_size(smx_process_t process, smx_storage_t stora xbt_dict_t SIMIX_storage_get_properties(smx_storage_t storage){ xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)"); - return surf_resource_get_properties(surf_storage_resource_priv(storage)); + return (xbt_dict_t) surf_resource_get_properties((surf_cpp_resource_t) + surf_storage_resource_priv(storage)); } const char* SIMIX_storage_get_name(smx_storage_t storage){ diff --git a/src/simix/smx_network.c b/src/simix/smx_network.cpp similarity index 97% rename from src/simix/smx_network.c rename to src/simix/smx_network.cpp index 0b057045c9..d808503b73 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.cpp @@ -19,7 +19,7 @@ XBT_EXPORT_NO_IMPORT(unsigned long int) smx_total_comms = 0; static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall); static void SIMIX_comm_copy_data(smx_synchro_t comm); static smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type); -static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_synchro_t comm); +static inline void SIMIX_rdv_push(smx_rdv_t rdv, smx_synchro_t comm); static smx_synchro_t SIMIX_fifo_probe_comm(xbt_fifo_t fifo, e_smx_comm_type_t type, int (*match_fun)(void *, void *,smx_synchro_t), void *user_data, smx_synchro_t my_synchro); @@ -46,7 +46,7 @@ void SIMIX_network_exit(void) smx_rdv_t SIMIX_rdv_create(const char *name) { /* two processes may have pushed the same rdv_create simcall at the same time */ - smx_rdv_t rdv = name ? xbt_dict_get_or_null(rdv_points, name) : NULL; + smx_rdv_t rdv = name ? (smx_rdv_t) xbt_dict_get_or_null(rdv_points, name) : NULL; if (!rdv) { rdv = xbt_new0(s_smx_rvpoint_t, 1); @@ -87,7 +87,7 @@ xbt_dict_t SIMIX_get_rdv_points() smx_rdv_t SIMIX_rdv_get_by_name(const char *name) { - return xbt_dict_get_or_null(rdv_points, name); + return (smx_rdv_t) xbt_dict_get_or_null(rdv_points, name); } int SIMIX_rdv_comm_count_by_host(smx_rdv_t rdv, sg_host_t host) @@ -106,7 +106,8 @@ int SIMIX_rdv_comm_count_by_host(smx_rdv_t rdv, sg_host_t host) smx_synchro_t SIMIX_rdv_get_head(smx_rdv_t rdv) { - return xbt_fifo_get_item_content(xbt_fifo_get_first_item(rdv->comm_fifo)); + return (smx_synchro_t) xbt_fifo_get_item_content( + xbt_fifo_get_first_item(rdv->comm_fifo)); } /** @@ -134,7 +135,7 @@ void SIMIX_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process) * \param rdv The rendez-vous point * \param comm The communication synchro */ -static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_synchro_t comm) +static inline void SIMIX_rdv_push(smx_rdv_t rdv, smx_synchro_t comm) { xbt_fifo_push(rdv->comm_fifo, comm); comm->comm.rdv = rdv; @@ -145,7 +146,7 @@ static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_synchro_t comm) * \param rdv The rendez-vous point * \param comm The communication synchro */ -XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_synchro_t comm) +void SIMIX_rdv_remove(smx_rdv_t rdv, smx_synchro_t comm) { xbt_fifo_remove(rdv->comm_fifo, comm); comm->comm.rdv = NULL; @@ -240,7 +241,7 @@ smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type) smx_synchro_t synchro; /* alloc structures */ - synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_COMMUNICATE; synchro->state = SIMIX_WAITING; @@ -552,12 +553,16 @@ smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_rdv_t rdv, int type, //find a match in the already received fifo XBT_DEBUG("first try in the perm recv mailbox"); - other_synchro = SIMIX_fifo_probe_comm(rdv->done_comm_fifo, smx_type, match_fun, data, this_synchro); + other_synchro = SIMIX_fifo_probe_comm( + rdv->done_comm_fifo, (e_smx_comm_type_t) smx_type, + match_fun, data, this_synchro); } // }else{ if(!other_synchro){ XBT_DEBUG("try in the normal mailbox"); - other_synchro = SIMIX_fifo_probe_comm(rdv->comm_fifo, smx_type, match_fun, data, this_synchro); + other_synchro = SIMIX_fifo_probe_comm( + rdv->comm_fifo, (e_smx_comm_type_t) smx_type, + match_fun, data, this_synchro); } // } if(other_synchro)other_synchro->comm.refcount--; @@ -709,7 +714,7 @@ void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall) * \brief Starts the simulation of a communication synchro. * \param synchro the communication synchro */ -static XBT_INLINE void SIMIX_comm_start(smx_synchro_t synchro) +static inline void SIMIX_comm_start(smx_synchro_t synchro) { /* If both the sender and the receiver are already there, start the communication */ if (synchro->state == SIMIX_READY) { @@ -764,7 +769,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro) unsigned int destroy_count = 0; smx_simcall_t simcall; - while ((simcall = xbt_fifo_shift(synchro->simcalls))) { + while ((simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls))) { /* If a waitany simcall is waiting for this synchro to finish, then remove it from the other synchros in the waitany list. Afterwards, get the diff --git a/src/simix/smx_process.c b/src/simix/smx_process.cpp similarity index 97% rename from src/simix/smx_process.c rename to src/simix/smx_process.cpp index 0fe5c6fdbe..493977bdc7 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.cpp @@ -24,7 +24,7 @@ unsigned long simix_process_maxpid = 0; * * \return The SIMIX process */ -XBT_INLINE smx_process_t SIMIX_process_self(void) +smx_process_t SIMIX_process_self(void) { smx_context_t self_context = SIMIX_context_self(); @@ -58,7 +58,7 @@ void SIMIX_process_cleanup(smx_process_t process) /* cancel non-blocking communications */ smx_synchro_t synchro; - while ((synchro = xbt_fifo_pop(process->comms))) { + while ((synchro = (smx_synchro_t) xbt_fifo_pop(process->comms))) { /* make sure no one will finish the comm after this process is destroyed, * because src_proc or dst_proc would be an invalid pointer */ @@ -113,7 +113,7 @@ void SIMIX_process_empty_trash(void) { smx_process_t process = NULL; - while ((process = xbt_swag_extract(simix_global->process_to_destroy))) { + while ((process = (smx_process_t) xbt_swag_extract(simix_global->process_to_destroy))) { XBT_DEBUG("Getting rid of %p",process); SIMIX_context_free(process->context); @@ -143,7 +143,7 @@ void SIMIX_create_maestro_process() maestro->pid = simix_process_maxpid++; maestro->ppid = -1; maestro->name = (char *) ""; - maestro->running_ctx = xbt_new(xbt_running_ctx_t, 1); + maestro->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t)); XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx); maestro->context = SIMIX_context_new(NULL, 0, NULL, NULL, maestro); maestro->simcall.issuer = maestro; @@ -214,7 +214,7 @@ void* simcall_HANDLER_process_create(smx_simcall_t simcall, static void kill_process(void* process) { - return simix_global->kill_process_function(process); + simix_global->kill_process_function((smx_process_t) process); } /** @@ -278,7 +278,7 @@ smx_process_t SIMIX_process_create( XBT_VERB("Create context %s", process->name); process->context = SIMIX_context_new(code, argc, argv, simix_global->cleanup_process_function, process); - process->running_ctx = xbt_new(xbt_running_ctx_t, 1); + process->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t)); XBT_RUNNING_CTX_INITIALIZE(process->running_ctx); if(MC_is_active()){ @@ -453,7 +453,7 @@ void SIMIX_process_killall(smx_process_t issuer, int reset_pid) { smx_process_t p = NULL; - while ((p = xbt_swag_extract(simix_global->process_list))) { + while ((p = (smx_process_t) xbt_swag_extract(simix_global->process_list))) { if (p != issuer) { SIMIX_process_kill(p,issuer); } @@ -704,7 +704,7 @@ static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_synch surf_action_cancel(sync->sleep.surf_sleep); smx_simcall_t simcall; - while ((simcall = xbt_fifo_shift(sync->simcalls))) { + while ((simcall = (smx_simcall_t) xbt_fifo_shift(sync->simcalls))) { simcall_process_sleep__set__result(simcall, SIMIX_DONE); simcall->issuer->waiting_synchro = NULL; if (simcall->issuer->suspended) { @@ -745,7 +745,6 @@ void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration) smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration) { - smx_synchro_t synchro; sg_host_t host = process->host; /* check if the host is active */ @@ -754,7 +753,7 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration) sg_host_get_name(host)); } - synchro = xbt_mallocator_get(simix_global->synchro_mallocator); + smx_synchro_t synchro = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); synchro->type = SIMIX_SYNC_SLEEP; synchro->name = NULL; synchro->category = NULL; @@ -774,7 +773,7 @@ void SIMIX_post_process_sleep(smx_synchro_t synchro) e_smx_state_t state; xbt_assert(synchro->type == SIMIX_SYNC_SLEEP || synchro->type == SIMIX_SYNC_JOIN); - while ((simcall = xbt_fifo_shift(synchro->simcalls))) { + while ((simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls))) { switch(surf_action_get_state(synchro->sleep.surf_sleep)){ case SURF_ACTION_FAILED: @@ -912,10 +911,9 @@ xbt_dynar_t SIMIX_process_get_runnable(void) smx_process_t SIMIX_process_from_PID(int PID) { smx_process_t proc; - xbt_swag_foreach(proc, simix_global->process_list) - { - if(proc->pid == PID) - return proc; + xbt_swag_foreach(proc, simix_global->process_list) { + if (proc->pid == (unsigned long) PID) + return proc; } return NULL; } diff --git a/src/simix/smx_synchro.c b/src/simix/smx_synchro.cpp similarity index 97% rename from src/simix/smx_synchro.c rename to src/simix/smx_synchro.cpp index 59ea411d37..090c872fa9 100644 --- a/src/simix/smx_synchro.c +++ b/src/simix/smx_synchro.cpp @@ -25,7 +25,7 @@ static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout) XBT_IN("(%p, %f)",smx_host,timeout); smx_synchro_t sync; - sync = xbt_mallocator_get(simix_global->synchro_mallocator); + sync = (smx_synchro_t) xbt_mallocator_get(simix_global->synchro_mallocator); sync->type = SIMIX_SYNC_SYNCHRO; sync->name = xbt_strdup("synchro"); sync->synchro.sleep = surf_host_sleep(smx_host, timeout); @@ -93,7 +93,7 @@ void SIMIX_post_synchro(smx_synchro_t synchro) static void SIMIX_synchro_finish(smx_synchro_t synchro) { XBT_IN("(%p)",synchro); - smx_simcall_t simcall = xbt_fifo_shift(synchro->simcalls); + smx_simcall_t simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls); switch (synchro->state) { @@ -208,7 +208,6 @@ void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex){ void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer) { XBT_IN("(%p, %p)",mutex,issuer); - smx_process_t p; /*process to wake up */ /* If the mutex is not owned by the issuer, that's not good */ if (issuer != mutex->owner) @@ -216,7 +215,8 @@ void SIMIX_mutex_unlock(smx_mutex_t mutex, smx_process_t issuer) SIMIX_process_get_name(mutex->owner),SIMIX_process_get_PID(mutex->owner)); if (xbt_swag_size(mutex->sleeping) > 0) { - p = xbt_swag_extract(mutex->sleeping); + /*process to wake up */ + smx_process_t p = (smx_process_t) xbt_swag_extract(mutex->sleeping); SIMIX_synchro_destroy(p->waiting_synchro); p->waiting_synchro = NULL; mutex->owner = p; @@ -333,7 +333,7 @@ void SIMIX_cond_signal(smx_cond_t cond) /* If there are processes waiting for the condition choose one and try to make it acquire the mutex */ - if ((proc = xbt_swag_extract(cond->sleeping))) { + if ((proc = (smx_process_t) xbt_swag_extract(cond->sleeping))) { /* Destroy waiter's synchronization */ SIMIX_synchro_destroy(proc->waiting_synchro); @@ -435,7 +435,7 @@ void SIMIX_sem_release(smx_sem_t sem) smx_process_t proc; XBT_DEBUG("Sem release semaphore %p", sem); - if ((proc = xbt_swag_extract(sem->sleeping))) { + if ((proc = (smx_process_t) xbt_swag_extract(sem->sleeping))) { SIMIX_synchro_destroy(proc->waiting_synchro); proc->waiting_synchro = NULL; SIMIX_simcall_answer(&proc->simcall); diff --git a/src/simix/smx_vm.c b/src/simix/smx_vm.cpp similarity index 98% rename from src/simix/smx_vm.c rename to src/simix/smx_vm.cpp index d430a960fb..dae28e7b8f 100644 --- a/src/simix/smx_vm.c +++ b/src/simix/smx_vm.cpp @@ -91,7 +91,7 @@ void SIMIX_vm_start(sg_host_t ind_vm) { if (__can_be_started(ind_vm)) surf_host_set_state(surf_host_resource_priv(ind_vm), - (int)SURF_VM_STATE_RUNNING); + (e_surf_resource_state_t) SURF_VM_STATE_RUNNING); else THROWF(vm_error, 0, "The VM %s cannot be started", SIMIX_host_get_name(ind_vm)); } @@ -343,7 +343,7 @@ void SIMIX_vm_shutdown(sg_host_t ind_vm, smx_process_t issuer) /* FIXME: we may have to do something at the surf layer, e.g., vcpu action */ surf_host_set_state(surf_host_resource_priv(ind_vm), - (int)SURF_VM_STATE_CREATED); + (e_surf_resource_state_t) SURF_VM_STATE_CREATED); } void simcall_HANDLER_vm_shutdown(smx_simcall_t simcall, sg_host_t ind_vm) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 68a711f187..f33ebcbe54 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -30,8 +30,8 @@ set(EXTRA_DIST src/simix/simcalls.in src/simix/simcalls.py src/simix/popping_private.h - src/simix/popping_bodies.c - src/simix/popping_generated.c + src/simix/popping_bodies.cpp + src/simix/popping_generated.cpp src/simix/popping_enum.h src/simix/popping_accessors.h src/simix/smx_host_private.h @@ -352,22 +352,22 @@ set(SURF_SRC ) set(SIMIX_GENERATED_SRC - src/simix/popping_generated.c + src/simix/popping_generated.cpp ) set(SIMIX_SRC - src/simix/libsmx.c - src/simix/smx_context.c - src/simix/smx_context_base.c - src/simix/smx_deployment.c - src/simix/smx_environment.c - src/simix/smx_global.c - src/simix/smx_host.c - src/simix/smx_io.c - src/simix/smx_network.c - src/simix/smx_process.c - src/simix/smx_synchro.c - src/simix/smx_vm.c - src/simix/popping.c + src/simix/libsmx.cpp + src/simix/smx_context.cpp + src/simix/smx_context_base.cpp + src/simix/smx_deployment.cpp + src/simix/smx_environment.cpp + src/simix/smx_global.cpp + src/simix/smx_host.cpp + src/simix/smx_io.cpp + src/simix/smx_network.cpp + src/simix/smx_process.cpp + src/simix/smx_synchro.cpp + src/simix/smx_vm.cpp + src/simix/popping.cpp ${SIMIX_GENERATED_SRC} ) @@ -376,11 +376,11 @@ set(SIMIX_SRC if (MSVC) set(EXTRA_DIST ${EXTRA_DIST} - src/simix/smx_context_raw.c) + src/simix/smx_context_raw.cpp) else() set(SIMIX_SRC ${SIMIX_SRC} - src/simix/smx_context_raw.c) + src/simix/smx_context_raw.cpp) endif() # Boost context may not be available @@ -777,13 +777,13 @@ set(source_of_generated_headers if(${CONTEXT_THREADS}) #pthread set(SURF_SRC ${SURF_SRC} - src/simix/smx_context_thread.c + src/simix/smx_context_thread.cpp src/xbt/xbt_os_thread.c ) else() # NOT pthread set(EXTRA_DIST ${EXTRA_DIST} - src/simix/smx_context_thread.c + src/simix/smx_context_thread.cpp src/xbt/xbt_os_thread.c ) endif() @@ -791,12 +791,12 @@ endif() if(${CONTEXT_UCONTEXT}) #ucontext set(SURF_SRC ${SURF_SRC} - src/simix/smx_context_sysv.c + src/simix/smx_context_sysv.cpp ) else() # NOT ucontext set(EXTRA_DIST ${EXTRA_DIST} - src/simix/smx_context_sysv.c + src/simix/smx_context_sysv.cpp ) endif() @@ -859,7 +859,7 @@ endif() if(WIN32) set(simgrid_sources ${simgrid_sources} - src/simix/smx_context_thread.c + src/simix/smx_context_thread.cpp src/xbt/win32_ucontext.c src/xbt/xbt_os_thread.c ) diff --git a/tools/cmake/MaintainerMode.cmake b/tools/cmake/MaintainerMode.cmake index 6e1c009ba3..fbedec0268 100644 --- a/tools/cmake/MaintainerMode.cmake +++ b/tools/cmake/MaintainerMode.cmake @@ -15,8 +15,8 @@ if(enable_maintainer_mode AND NOT WIN32) if (PYTHON_EXE) add_custom_command( OUTPUT - ${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.c - ${CMAKE_HOME_DIRECTORY}/src/simix/popping_bodies.c + ${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.cpp + ${CMAKE_HOME_DIRECTORY}/src/simix/popping_bodies.cpp ${CMAKE_HOME_DIRECTORY}/src/simix/popping_enum.h ${CMAKE_HOME_DIRECTORY}/src/simix/popping_accessors.h @@ -31,14 +31,14 @@ if(enable_maintainer_mode AND NOT WIN32) add_custom_target(simcalls_generated_src DEPENDS - ${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.c - ${CMAKE_HOME_DIRECTORY}/src/simix/popping_bodies.c + ${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.cpp + ${CMAKE_HOME_DIRECTORY}/src/simix/popping_bodies.cpp ${CMAKE_HOME_DIRECTORY}/src/simix/popping_enum.h ${CMAKE_HOME_DIRECTORY}/src/simix/popping_accessors.h ) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES - "${CMAKE_HOME_DIRECTORY}/src/simix/popping_enum.h;${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.c;${CMAKE_HOME_DIRECTORY}/src/simix/popping_bodies.c;${CMAKE_HOME_DIRECTORY}/src/simix/popping_accessors.h" + "${CMAKE_HOME_DIRECTORY}/src/simix/popping_enum.h;${CMAKE_HOME_DIRECTORY}/src/simix/popping_generated.cpp;${CMAKE_HOME_DIRECTORY}/src/simix/popping_bodies.cpp;${CMAKE_HOME_DIRECTORY}/src/simix/popping_accessors.h" ) endif() endif() -- 2.20.1