- 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
* (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 */
/* 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);
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()
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
-#include "popping_bodies.c"
+#include "popping_bodies.cpp"
/**
* \ingroup simix_host_management
*/
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);
}
*/
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
{
/* 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);
}
/**
-/* 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
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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() {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} 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) {
} else {
SIMIX_simcall_handle(&self->simcall, 0);
}
- return self->simcall.result.i;
+ return (int) self->simcall.result.i;
}
#endif
} 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) {
} else {
SIMIX_simcall_handle(&self->simcall, 0);
}
- return self->simcall.result.i;
+ return (int) self->simcall.result.i;
}
#endif
/** @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"
};
/**
#!/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.
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:
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 = []
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(' }')
fd.close()
###
- ### smx_popping_generated.c
+ ### smx_popping_generated.cpp
###
- fd = header("popping_generated.c")
+ fd = header("popping_generated.cpp")
fd.write('#include <xbt/base.h>\n');
fd.write('#include "smx_private.h"\n');
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')
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')
* 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;
}
* 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;
}
* \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;
}
* \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;
}
* 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;
}
* 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;
}
* \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
* \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
/* 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
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())
/* 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
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__ (
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;
}
/* 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,
{
#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;
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()<nb_processes) {
+ if (SIMIX_context_is_parallel()
+ && (unsigned long) SIMIX_context_get_parallel_threshold() < nb_processes) {
XBT_DEBUG("Runall // %lu", nb_processes);
simix_global->context_factory->suspend = smx_ctx_raw_suspend_parallel;
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;
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);
}
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
* \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;
#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;
}
*
* \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());
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);
* \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);
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;
}
* 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;
*
* \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;
*
* \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;
}
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);
}
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]);
NULL);
} else {
simcall_process_create(arg->argv[0],
- arg->code,
+ (xbt_main_func_t) arg->code,
NULL,
arg->hostname,
arg->kill_time,
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;
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;
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;
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;
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;
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;
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){
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);
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);
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)
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));
}
/**
* \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;
* \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;
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;
//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--;
* \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) {
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
*
* \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();
/* 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 */
{
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);
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;
static void kill_process(void* process)
{
- return simix_global->kill_process_function(process);
+ simix_global->kill_process_function((smx_process_t) process);
}
/**
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()){
{
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);
}
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) {
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 */
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;
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:
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;
}
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);
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) {
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)
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;
/* 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);
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);
{
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));
}
/* 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)
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
)
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}
)
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
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()
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()
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
)
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
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()