if ((remote_peer->interested != 0) && (remote_peer->choked_upload == 0)) {
//add in the active peers set
xbt_dict_set_ext(peer->active_peers, (char *) &remote_peer->id, sizeof(int), remote_peer, NULL);
- } else {
- //remove
- xbt_ex_t e;
- TRY {
- xbt_dict_remove_ext(peer->active_peers, (char *) &remote_peer->id, sizeof(int));
- }
- CATCH(e) {
- xbt_ex_free(e);
- }
+ } else if (xbt_dict_get_or_null_ext(peer->active_peers, (char *) &remote_peer->id, sizeof(int))) {
+ xbt_dict_remove_ext(peer->active_peers, (char *) &remote_peer->id, sizeof(int));
}
}
-foreach(x availability daxload fail typed_tasks io properties throttling scheduling test)
+foreach(x availability daxload fail typed_tasks io properties throttling scheduling)
add_executable (sd_${x} ${x}/sd_${x}.c)
target_link_libraries(sd_${x} simgrid)
set_target_properties(sd_${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/sd_${x}.tesh)
endforeach()
+foreach(x test)
+ add_executable (sd_${x} ${x}/sd_${x}.cpp)
+ target_link_libraries(sd_${x} simgrid)
+ set_target_properties(sd_${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+ set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/sd_${x}.cpp)
+ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/sd_${x}.tesh)
+endforeach()
+
foreach(x dag-dotload ptg-dotload schedule-dotload)
if(HAVE_GRAPHVIZ)
add_executable (sd_${x} ${x}/sd_${x}.c)
foreach(x dag-dotload ptg-dotload schedule-dotload)
ADD_TESH(simdag-${x} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/simdag --cd ${CMAKE_BINARY_DIR}/examples/simdag ${CMAKE_HOME_DIRECTORY}/examples/simdag/${x}/sd_${x}.tesh)
endforeach()
-endif()
\ No newline at end of file
+endif()
static double finish_on_at(SD_task_t task, sg_host_t host)
{
- volatile double result;
+ double result;
unsigned int i;
double data_available = 0.;
double redist_time = 0;
unsigned int ctr;
SD_task_t checkB, checkD;
xbt_dynar_t changed_tasks;
- xbt_ex_t ex;
const int host_count = 2;
sg_host_t host_list[2];
double computation_amount[2];
SD_task_dependency_add(NULL, NULL, taskD, taskC);
SD_task_dependency_add(NULL, NULL, taskB, taskC);
- TRY {
+ try {
SD_task_dependency_add(NULL, NULL, taskA, taskA); /* shouldn't work and must raise an exception */
xbt_die("Hey, I can add a dependency between Task A and Task A!");
}
- CATCH(ex) {
+ catch (xbt_ex& ex) {
if (ex.category != arg_error)
- RETHROW; /* this is a serious error */
- xbt_ex_free(ex);
+ throw; /* this is a serious error */
}
- TRY {
+ try {
SD_task_dependency_add(NULL, NULL, taskB, taskA); /* shouldn't work and must raise an exception */
xbt_die("Oh oh, I can add an already existing dependency!");
}
- CATCH(ex) {
+ catch (xbt_ex& ex) {
if (ex.category != arg_error)
- RETHROW;
- xbt_ex_free(ex);
+ throw;
}
- TRY {
+ try {
SD_task_dependency_remove(taskA, taskC); /* shouldn't work and must raise an exception */
xbt_die("Dude, I can remove an unknown dependency!");
}
- CATCH(ex) {
+ catch (xbt_ex& ex) {
if (ex.category != arg_error)
- RETHROW;
- xbt_ex_free(ex);
+ throw;
}
- TRY {
+ try {
SD_task_dependency_remove(taskC, taskC); /* shouldn't work and must raise an exception */
xbt_die("Wow, I can remove a dependency between Task C and itself!");
}
- CATCH(ex) {
+ catch (xbt_ex& ex) {
if (ex.category != arg_error)
- RETHROW;
- xbt_ex_free(ex);
+ throw;
}
/* if everything is ok, no exception is forwarded or rethrown by main() */
* structure creation (of type void_f_ppvoid_t or void_f_pvoid_t).
*
* \section XBT_dynar_exscal Example with scalar
- * \dontinclude dynar.c
+ * \dontinclude dynar.cpp
*
* \skip Vars_decl
* \skip dyn
#include <stdlib.h>
+#ifdef __cplusplus
+#include <string>
+#include <vector>
+#include <stdexcept>
+#endif
+
+#include "xbt/base.h"
#include "xbt/sysdep.h"
#include "xbt/misc.h"
#include "xbt/virtu.h"
-SG_BEGIN_DECL()
-
/*-*-* Emergency debuging: define this when the exceptions get crazy *-*-*/
#undef __EX_MAYDAY
#ifdef __EX_MAYDAY
# define MAYDAY_CATCH(e)
#endif
/*-*-* end of debugging stuff *-*-*/
-#if defined(__EX_MCTX_MCSC__)
-#include <ucontext.h> /* POSIX.1 ucontext(3) */
-#define __ex_mctx_struct ucontext_t uc;
-#define __ex_mctx_save(mctx) (getcontext(&(mctx)->uc) == 0)
-#define __ex_mctx_restored(mctx) /* noop */
-#define __ex_mctx_restore(mctx) (void)setcontext(&(mctx)->uc)
-#elif defined(__EX_MCTX_SSJLJ__)
-#include <setjmp.h> /* POSIX.1 sigjmp_buf(3) */
-#define __ex_mctx_struct sigjmp_buf jb;
-#define __ex_mctx_save(mctx) (sigsetjmp((mctx)->jb, 1) == 0)
-#define __ex_mctx_restored(mctx) /* noop */
-#define __ex_mctx_restore(mctx) (void)siglongjmp((mctx)->jb, 1)
-#elif defined(__EX_MCTX_SJLJ__) || !defined(__EX_MCTX_CUSTOM__) || defined(__EX_MAYDAY)
-#include <setjmp.h> /* ISO-C jmp_buf(3) */
-#define __ex_mctx_struct jmp_buf jb;
-#define __ex_mctx_save(mctx) ( MAYDAY_SAVE(mctx) setjmp((mctx)->jb) == 0)
-#define __ex_mctx_restored(mctx) /* noop */
-#define __ex_mctx_restore(mctx) ( MAYDAY_RESTORE(mctx) (void)longjmp((mctx)->jb, 1))
-#endif
-/* declare the machine context type */
-typedef struct {
-__ex_mctx_struct} __ex_mctx_t;
-
-/** @addtogroup XBT_ex
- * @brief A set of macros providing exception a la C++ in ANSI C (grounding feature)
- *
- * This module is a small ISO-C++ style exception handling library
- * for use in the ISO-C language. It allows you to use the paradigm
- * of throwing and catching exceptions in order to reduce the amount
- * of error handling code without hindering program robustness.
- *
- * This is achieved by directly transferring exceptional return codes
- * (and the program control flow) from the location where the exception
- * is raised (throw point) to the location where it is handled (catch
- * point) -- usually from a deeply nested sub-routine to a parent
- * routine. All intermediate routines no longer have to make sure that
- * the exceptional return codes from sub-routines are correctly passed
- * back to the parent.
- *
- * These features are brought to you by a modified version of the libex
- * library, one of the numerous masterpiece of Ralf S. Engelschall.
- *
- * \htmlonly <div class="toc">\endhtmlonly
- *
- * @section XBT_ex_toc TABLE OF CONTENTS
- *
- * - \ref XBT_ex_intro
- * - \ref XBT_ex_base
- * - \ref XBT_ex_pitfalls
- *
- * \htmlonly </div> \endhtmlonly
- *
- * @section XBT_ex_intro DESCRIPTION
- *
- * In SimGrid, an exception is a triple <\a msg , \a category , \a value>
- * where \a msg is a human-readable text describing the exceptional
- * condition, \a code an integer describing what went wrong and \a value
- * providing a sort of sub-category. (this is different in the original libex).
- *
- * @section XBT_ex_base BASIC USAGE
- *
- * \em TRY \b TRIED_BLOCK [\em TRY_CLEANUP \b CLEANUP_BLOCK] \em CATCH (variable) \b CATCH_BLOCK
- *
- * This is the primary syntactical construct provided. It is modeled after the
- * ISO-C++ try-catch clause and should sound familiar to most of you.
- *
- * Any exception thrown directly from the TRIED_BLOCK block or from called
- * subroutines is caught. Cleanups which must be done after this block
- * (whenever an exception arose or not) should be placed into the optionnal
- * CLEANUP_BLOCK. The code dealing with the exceptions when they arise should
- * be placed into the (mandatory) CATCH_BLOCK.
- *
- *
- * In absence of exception, the control flow goes into the blocks TRIED_BLOCK
- * and CLEANUP_BLOCK (if present); The CATCH_BLOCK block is then ignored.
- *
- * When an exception is thrown, the control flow goes through the following
- * blocks: TRIED_BLOCK (up to the statement throwing the exception),
- * CLEANUP_BLOCK (if any) and CATCH_BLOCK. The exception is stored in a
- * variable for inspection inside the CATCH_BLOCK. This variable must be
- * declared in the outter scope, but its value is only valid within the
- * CATCH_BLOCK block.
- *
- * Some notes:
- * - TRY, CLEANUP and CATCH cannot be used separately, they work
- * only in combination and form a language clause as a whole.
- * - In contrast to the syntax of other languages (such as C++ or Jave) there
- * is only one CATCH block and not multiple ones (all exceptions are
- * of the same \em xbt_ex_t C type).
- * - the variable of CATCH can naturally be reused in subsequent
- * CATCH clauses.
- * - it is possible to nest TRY clauses.
- *
- * The TRY block is a regular ISO-C language statement block, but
- *
- * <center><b>it is not
- * allowed to jump into it via "goto" or longjmp(3) or out of it via "break",
- * "return", "goto" or longjmp(3)</b>.</center>
- *
- * This is because there is some hidden setup and
- * cleanup that needs to be done regardless of whether an exception is
- * caught. Bypassing these steps will break the exception handling facility.
- * The symptom are likely to be a segfault at the next exception raising point,
- * ie far away from the point where you did the mistake. Finding the problem can
- * reveal challenging, unfortunately.
- *
- * The CLEANUP and CATCH blocks are regular ISO-C language statement
- * blocks without any restrictions. You are even allowed to throw (and, in the
- * CATCH block, to re-throw) exceptions.
- *
- * There is one subtle detail you should remember about TRY blocks:
- * Variables used in the CLEANUP or CATCH clauses must be declared with
- * the storage class "volatile", otherwise they might contain outdated
- * information if an exception is thrown.
- *
- *
- * This is because you usually do not know which commands in the TRY
- * were already successful before the exception was thrown (logically speaking)
- * and because the underlying ISO-C setjmp(3) facility applies those
- * restrictions (technically speaking). As a matter of fact, value changes
- * between the TRY and the THROW may be discarded if you forget the
- * "volatile" keyword.
- *
- * \section XBT_ex_pitfalls PROGRAMMING PITFALLS
- *
- * Exception handling is a very elegant and efficient way of dealing with
- * exceptional situation. Nevertheless it requires additional discipline in
- * programming and there are a few pitfalls one must be aware of. Look the
- * following code which shows some pitfalls and contains many errors (assuming
- * a mallocex() function which throws an exception if malloc(3) fails):
- *
- * \dontinclude ex.c
- * \skip BAD_EXAMPLE
- * \until end_of_bad_example
- *
- * This example raises a few issues:
- * -# \b variable \b scope \n
- * Variables which are used in the CLEANUP or CATCH clauses must be
- * declared before the TRY clause, otherwise they only exist inside the
- * TRY block. In the example above, cp1, cp2 and cp3 only exist in the
- * TRY block and are invisible from the CLEANUP and CATCH
- * blocks.
- * -# \b variable \b initialization \n
- * Variables which are used in the CLEANUP or CATCH clauses must
- * be initialized before the point of the first possible THROW is
- * reached. In the example above, CLEANUP would have trouble using cp3
- * if mallocex() throws a exception when allocating a TOOBIG buffer.
- * -# \b volatile \b variable \n
- * Variables which are used in the CLEANUP or CATCH clauses MUST BE
- * DECLARED AS "volatile", otherwise they might contain outdated
- * information when an exception is thrown.
- * -# \b clean \b before \b catch \n
- * The CLEANUP clause is not only place before the CATCH clause in
- * the source code, it also occures before in the control flow. So,
- * resources being cleaned up cannot be used in the CATCH block. In the
- * example, c3 gets freed before the printf placed in CATCH.
- * -# \b variable \b uninitialization \n
- * If resources are passed out of the scope of the
- * TRY/CLEANUP/CATCH construct, they naturally shouldn't get
- * cleaned up. The example above does free(3) cp1 in CLEANUP although
- * its value was affected to globalcontext->first, invalidating this
- * pointer.
-
- * The following is fixed version of the code (annotated with the pitfall items
- * for reference):
- *
- * \skip GOOD_EXAMPLE
- * \until end_of_good_example
- *
- * @{
- */
/** @brief different kind of errors */
typedef enum {
vm_error /**< vm error */
} xbt_errcat_t;
-XBT_PUBLIC(const char *) xbt_ex_catname(xbt_errcat_t cat);
+#ifdef __cplusplus
+XBT_PUBLIC_CLASS xbt_ex : public std::runtime_error {
+public:
+ xbt_ex() : std::runtime_error("") {}
+ xbt_ex(const char* message) : std::runtime_error(message) {}
+ ~xbt_ex() override;
-/** @brief Structure describing an exception */
-typedef struct {
- char *msg; /**< human readable message */
xbt_errcat_t category; /**< category like HTTP (what went wrong) */
int value; /**< like errno (why did it went wrong) */
/* throw point */
- char *procname; /**< Name of the process who thrown this */
+ std::string procname; /**< Name of the process who thrown this */
int pid; /**< PID of the process who thrown this */
- char *file; /**< Thrown point */
+ const char *file; /**< Thrown point */
int line; /**< Thrown point */
- char *func; /**< Thrown point */
+ const char *func; /**< Thrown point */
/* Backtrace */
- int used;
- char **bt_strings; /* only filed on display (or before the network propagation) */
- void *bt[XBT_BACKTRACE_SIZE];
-} xbt_ex_t;
-
-/* declare the running context type
- * (that's where we get the process name for the logs and the exception storage)
- * -- do not mess with it --
- */
-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 */
-} xbt_running_ctx_t;
-
-/* the static and dynamic initializers for a context structure */
-#define XBT_RUNNING_CTX_INITIALIZER \
- { NULL, 0, { /* content */ NULL, unknown_error, 0, \
- /* throw point*/ NULL, 0, NULL, 0, NULL, \
- /* 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)->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);
-XBT_PUBLIC_DATA(xbt_running_ctx_fetcher_t) __xbt_running_ctx_fetch;
-XBT_PUBLIC( xbt_running_ctx_t *)__xbt_ex_ctx_default(void);
-
-/* the termination handler */
-typedef void (*ex_term_cb_t) (xbt_ex_t *);
-XBT_PUBLIC_DATA(ex_term_cb_t) __xbt_ex_terminate;
-XBT_PUBLIC( void )__xbt_ex_terminate_default(xbt_ex_t * e);
-
-/** @brief Introduce a block where exception may be dealed with
- * @hideinitializer
- */
-#define TRY \
- { \
- xbt_running_ctx_t *__xbt_ex_ctx_ptr = __xbt_running_ctx_fetch(); \
- int __ex_cleanup = 0; \
- __ex_mctx_t __ex_mctx_me; \
- __ex_mctx_t * __ex_mctx_en = __xbt_ex_ctx_ptr->ctx_mctx; \
- __xbt_ex_ctx_ptr->ctx_mctx = &__ex_mctx_me; \
- if (__ex_mctx_save(&__ex_mctx_me)) { \
- if (1)
-
-/** @brief optional(!) block for cleanup
- * @hideinitializer
- */
-#define TRY_CLEANUP \
- else { \
- } \
- __xbt_ex_ctx_ptr->ctx_caught = 0; \
- } else { \
- __ex_mctx_restored(&__ex_mctx_me); \
- __xbt_ex_ctx_ptr->ctx_caught = 1; \
- } \
- __xbt_ex_ctx_ptr->ctx_mctx = __ex_mctx_en; \
- __ex_cleanup = 1; \
- if (1) { \
- if (1)
-
-#ifndef DOXYGEN_SKIP
-# ifdef __cplusplus
-# define XBT_EX_T_CPLUSPLUSCAST (xbt_ex_t&)
-# else
-# define XBT_EX_T_CPLUSPLUSCAST
-# endif
+ std::vector<std::string> bt_strings;
+ std::vector<void*> bt;
+};
#endif
-/** @brief the block for catching (ie, deal with) an exception
- * @hideinitializer
- */
-#define CATCH(e) \
- DO_CATCH((e) = XBT_EX_T_CPLUSPLUSCAST __xbt_running_ctx_fetch()->exception)
-
-/** @brief like CATCH(e) but without argument
- * @hideinitializer
- *
- * Useful if you only want to rethrow the exception caught, and do not want to
- * bother with an unused variable.
- */
-#define CATCH_ANONYMOUS DO_CATCH(0)
-
-#define DO_CATCH(_xbt_do_catch_set_e) \
- else { \
- } \
- if (!(__ex_cleanup)) \
- __xbt_ex_ctx_ptr->ctx_caught = 0; \
- } else { \
- if (!(__ex_cleanup)) { \
- __ex_mctx_restored(&__ex_mctx_me); \
- __xbt_ex_ctx_ptr->ctx_caught = 1; \
- } \
- } \
- __xbt_ex_ctx_ptr->ctx_mctx = __ex_mctx_en; \
- } \
- if ( !(__xbt_running_ctx_fetch()->ctx_caught) \
- || ((void)(_xbt_do_catch_set_e), \
- MAYDAY_CATCH(__xbt_running_ctx_fetch()->exception) 0)) { \
- } \
- else
-
-#define DO_THROW(running_ctx) \
- do { /* deal with the exception */ \
- xbt_running_ctx_t *ctx = (running_ctx); \
- if (ctx->ctx_mctx == NULL) \
- __xbt_ex_terminate((xbt_ex_t*)&(ctx->exception)); /* not catched */ \
- else \
- __ex_mctx_restore(ctx->ctx_mctx); /* catched somewhere */ \
- XBT_UNREACHABLE(); \
- } while(0)
+SG_BEGIN_DECL()
-/** @brief Helper macro for THROW and THROWF
- * @hideinitializer
- *
- * @param _throw_ctx: the throwing context in which we should construct the exception
- * @param c: category code (integer)
- * @param v: value (integer)
- * @param m: message text
- *
- * If called from within a TRY/CATCH construct, this exception
- * is copied into the CATCH relevant variable program control flow
- * is derouted to the CATCH (after the optional sg_cleanup).
- *
- * If no TRY/CATCH construct embeds this call, the program calls
- * abort(3).
- *
- * The THROW can be performed everywhere, including inside TRY,
- * CLEANUP and CATCH blocks.
- */
+XBT_PUBLIC(const char *) xbt_ex_catname(xbt_errcat_t cat);
-#define THROW_PREPARE(_throw_ctx, c, v, m) \
- /* build the exception */ \
- _throw_ctx->exception.msg = (m); \
- _throw_ctx->exception.category = (xbt_errcat_t)(c); \
- _throw_ctx->exception.value = (v); \
- _throw_ctx->exception.procname = (char*)xbt_procname(); \
- _throw_ctx->exception.pid = xbt_getpid(); \
- _throw_ctx->exception.file = (char*)__FILE__; \
- _throw_ctx->exception.line = __LINE__; \
- _throw_ctx->exception.func = (char*)__func__; \
- _throw_ctx->exception.bt_strings = NULL; \
- xbt_backtrace_current((xbt_ex_t *)&(_throw_ctx->exception));
+typedef struct xbt_ex xbt_ex_t;
-#define _XBT_THROW(c, v, m) \
- do { /* change this sequence into one block */ \
- xbt_running_ctx_t *_throw_ctx = __xbt_running_ctx_fetch(); \
- THROW_PREPARE(_throw_ctx, c, v, m); \
- DO_THROW(_throw_ctx); \
- } while (0)
+XBT_PUBLIC(void) xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func) XBT_ATTRIB_NORETURN;
/** @brief Builds and throws an exception
@hideinitializer */
-#define THROW(c, v) _XBT_THROW(c, v, NULL)
+#define THROW(c, v) { xbt_throw(NULL, (xbt_errcat_t) c, v, __FILE__, __LINE__, __func__); }
/** @brief Builds and throws an exception with a printf-like formatted message
@hideinitializer */
-#define THROWF(c, v, ...) _XBT_THROW(c, v, bprintf(__VA_ARGS__))
+#define THROWF(c, v, ...) xbt_throw(bprintf(__VA_ARGS__), (xbt_errcat_t) c, v, __FILE__, __LINE__, __func__)
#define THROW_IMPOSSIBLE \
THROWF(unknown_error, 0, "The Impossible Did Happen (yet again)")
#define DIE_IMPOSSIBLE xbt_die("The Impossible Did Happen (yet again)")
-/** @brief re-throwing of an already caught exception (ie, pass it to the upper catch block)
- * @hideinitializer
- */
-#define RETHROW DO_THROW(__xbt_running_ctx_fetch())
-
-/** @brief like THROWF, but adding some details to the message of an existing exception
- * @hideinitializer
- */
-#define RETHROWF(...) \
- do { \
- char *_xbt_ex_internal_msg = __xbt_running_ctx_fetch()->exception.msg; \
- __xbt_running_ctx_fetch()->exception.msg = bprintf(__VA_ARGS__, \
- _xbt_ex_internal_msg); \
- free(_xbt_ex_internal_msg); \
- RETHROW; \
- } while (0)
-
-/** @brief Exception destructor */
-XBT_PUBLIC(void) xbt_ex_free(xbt_ex_t e);
/** @brief The display made by an exception that is not catched */
XBT_PUBLIC(void) xbt_ex_display(xbt_ex_t * e);
this->begin = xbt_os_sem_init(0);
this->end = xbt_os_sem_init(0);
- TRY {
+ try {
this->thread = xbt_os_thread_create(
nullptr, JavaContext::wrapper, this, nullptr);
}
- CATCH_ANONYMOUS {
- RETHROWF("Failed to create context #%d. You may want to switch to Java coroutines to increase your limits (error: %s)."
- "See the Install section of simgrid-java documentation (in doc/install.html) for more on coroutines.",
- thread_amount);
+ catch (xbt_ex& ex) {
+ char* str = bprintf(
+ "Failed to create context #%d. You may want to switch to Java coroutines to increase your limits (error: %s)."
+ "See the Install section of simgrid-java documentation (in doc/install.html) for more on coroutines.",
+ thread_amount, ex.what());
+ xbt_ex new_exception(str);
+ free(str);
+ new_exception.category = ex.category;
+ new_exception.value = ex.value;
+ new_exception.procname = ex.procname;
+ new_exception.file = ex.file;
+ new_exception.line = ex.line;
+ new_exception.func = ex.func;
+ new_exception.pid = ex.pid;
+ new_exception.bt = ex.bt;
+ new_exception.bt_strings = ex.bt_strings;
+ throw new_exception;
}
} else {
this->thread = nullptr;
return;
}
- TRY {
+ try {
MSG_process_auto_restart_set(process,auto_restart);
}
- CATCH (e) {
- xbt_ex_free(e);
+ catch (xbt_ex& e) {
+ // Nothing to do
}
}
return;
}
- TRY {
+ try {
MSG_process_restart(process);
}
- CATCH (e) {
- xbt_ex_free(e);
+ catch (xbt_ex& e) {
+ // Nothing to do
}
}
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj) {
- xbt_mutex_t mutex;
-
- mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind);
- xbt_ex_t e;
- TRY {
+ xbt_mutex_t mutex = (xbt_mutex_t) (uintptr_t) env->GetLongField(obj, jsyncro_field_Mutex_bind);
+ try {
xbt_mutex_acquire(mutex);
}
- CATCH(e) {
- xbt_ex_free(e);
+ catch(xbt_ex& e) {
+ // Nothing to do
}
}
{
msg_vm_t vm = jvm_get_native(env,jvm);
msg_host_t host = jhost_get_native(env, jhost);
- xbt_ex_t e;
- TRY{
+ try {
MSG_vm_migrate(vm,host);
- } CATCH(e){
- XBT_VERB("CATCH EXCEPTION MIGRATION %s",e.msg);
- xbt_ex_free(e);
+ }
+ catch(xbt_ex& e){
+ XBT_VERB("CATCH EXCEPTION MIGRATION %s",e.what());
jxbt_throw_host_failure(env, (char*)"during migration");
}
}
val_t PJ_value_get_or_new (const char *name, const char *color, type_t father)
{
val_t ret = 0;
- xbt_ex_t e;
- TRY {
+ try {
ret = PJ_value_get(name, father);
}
- CATCH(e) {
- xbt_ex_free(e);
+ catch(xbt_ex& e) {
ret = PJ_value_new(name, color, father);
}
return ret;
*/
msg_error_t MSG_parallel_task_execute(msg_task_t task)
{
- xbt_ex_t e;
simdata_task_t simdata = task->simdata;
simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data();
e_smx_state_t comp_state;
TRACE_msg_task_execute_start(task);
- xbt_assert((!simdata->compute) && (task->simdata->isused == 0),
- "This task is executed somewhere else. Go fix your code! %d", task->simdata->isused!=nullptr);
+ xbt_assert((!simdata->compute) && !task->simdata->isused,
+ "This task is executed somewhere else. Go fix your code!");
XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self()));
return MSG_OK;
}
- TRY {
- if (msg_global->debug_multiple_use)
- MSG_BT(simdata->isused, "Using Backtrace");
- else
- simdata->isused = (void*)1;
+ try {
+ simdata->setUsed();
if (simdata->host_nb > 0) {
simdata->compute = static_cast<simgrid::simix::Exec*>(
comp_state = simcall_execution_wait(simdata->compute);
p_simdata->waiting_action = nullptr;
-
- if (msg_global->debug_multiple_use && simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)simdata->isused);
- simdata->isused = 0;
+ simdata->setNotUsed();
XBT_DEBUG("Execution task '%s' finished in state %d", task->name, (int)comp_state);
}
- CATCH(e) {
+ catch (xbt_ex& e) {
switch (e.category) {
case cancel_error:
status = MSG_TASK_CANCELED;
status = MSG_HOST_FAILURE;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
+
/* action ended, set comm and compute = nullptr, the actions is already destroyed in the main function */
simdata->flops_amount = 0.0;
simdata->comm = nullptr;
*/
msg_error_t MSG_process_sleep(double nb_sec)
{
- xbt_ex_t e;
msg_error_t status = MSG_OK;
/*msg_process_t proc = MSG_process_self();*/
TRACE_msg_process_sleep_in(MSG_process_self());
- TRY {
+ try {
simcall_process_sleep(nb_sec);
}
- CATCH(e) {
+ catch(xbt_ex& e) {
switch (e.category) {
case cancel_error:
XBT_DEBUG("According to the JAVA API, a sleep call should only deal with HostFailureException, WTF here ?");
status = MSG_TASK_CANCELED;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
TRACE_msg_process_sleep_out(MSG_process_self());
*/
msg_error_t MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout, msg_host_t host)
{
- xbt_ex_t e;
msg_error_t ret = MSG_OK;
XBT_DEBUG("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'", alias);
- TRY {
+ try {
ret = MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task, host, timeout);
}
- CATCH(e) {
+ catch(xbt_ex& e) {
switch (e.category) {
case cancel_error: /* may be thrown by MSG_mailbox_get_by_alias */
ret = MSG_HOST_FAILURE;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
return ret;
}
t_simdata = task->simdata;
t_simdata->sender = process;
t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host;
-
- if (t_simdata->isused != 0) {
- if (msg_global->debug_multiple_use){
- XBT_ERROR("This task is already used in there:");
- xbt_backtrace_display((xbt_ex_t*) t_simdata->isused);
- XBT_ERROR("And you try to reuse it from here:");
- xbt_backtrace_display_current();
- } else {
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!"
- "(use --cfg=msg/debug-multiple-use:on to get the backtrace of the other process)");
- }
- }
-
- if (msg_global->debug_multiple_use)
- MSG_BT(t_simdata->isused, "Using Backtrace");
- else
- t_simdata->isused = (void*)1;
+ t_simdata->setUsed();
t_simdata->comm = nullptr;
msg_global->sent_msg++;
*/
int MSG_comm_test(msg_comm_t comm)
{
- xbt_ex_t e;
int finished = 0;
- TRY {
+ try {
finished = simcall_comm_test(comm->s_comm);
-
if (finished && comm->task_received != nullptr) {
/* I am the receiver */
- if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused);
- (*comm->task_received)->simdata->isused = 0;
+ (*comm->task_received)->simdata->setNotUsed();
}
}
- CATCH(e) {
+ catch (xbt_ex& e) {
switch (e.category) {
case network_error:
comm->status = MSG_TRANSFER_FAILURE;
finished = 1;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
return finished;
*/
int MSG_comm_testany(xbt_dynar_t comms)
{
- xbt_ex_t e;
int finished_index = -1;
/* create the equivalent dynar with SIMIX objects */
}
msg_error_t status = MSG_OK;
- TRY {
+ try {
finished_index = simcall_comm_testany(s_comms);
}
- CATCH(e) {
+ catch (xbt_ex& e) {
switch (e.category) {
case network_error:
finished_index = e.value;
status = MSG_TIMEOUT;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
xbt_dynar_free(&s_comms);
if (status == MSG_OK && comm->task_received != nullptr) {
/* I am the receiver */
- if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused);
- (*comm->task_received)->simdata->isused = 0;
+ (*comm->task_received)->simdata->setNotUsed();
}
}
*/
msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout)
{
- xbt_ex_t e;
- TRY {
+ try {
simcall_comm_wait(comm->s_comm, timeout);
if (comm->task_received != nullptr) {
/* I am the receiver */
- if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused);
- (*comm->task_received)->simdata->isused = 0;
+ (*comm->task_received)->simdata->setNotUsed();
}
/* FIXME: these functions are not traceable */
}
- CATCH(e) {
+ catch (xbt_ex& e) {
switch (e.category) {
case network_error:
comm->status = MSG_TRANSFER_FAILURE;
comm->status = MSG_TIMEOUT;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
return comm->status;
*/
int MSG_comm_waitany(xbt_dynar_t comms)
{
- xbt_ex_t e;
int finished_index = -1;
/* create the equivalent dynar with SIMIX objects */
}
msg_error_t status = MSG_OK;
- TRY {
+ try {
finished_index = simcall_comm_waitany(s_comms);
}
- CATCH(e) {
+ catch(xbt_ex& e) {
switch (e.category) {
case network_error:
finished_index = e.value;
status = MSG_TIMEOUT;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
xbt_assert(finished_index != -1, "WaitAny returned -1");
if (comm->task_received != nullptr) {
/* I am the receiver */
- if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused);
- (*comm->task_received)->simdata->isused = 0;
+ (*comm->task_received)->simdata->setNotUsed();
}
return finished_index;
t_simdata->sender = process;
t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data())->m_host;
- if (t_simdata->isused != 0) {
- if (msg_global->debug_multiple_use){
- XBT_ERROR("This task is already used in there:");
- xbt_backtrace_display((xbt_ex_t*) t_simdata->isused);
- XBT_ERROR("And you try to reuse it from here:");
- xbt_backtrace_display_current();
- } else {
- xbt_assert(t_simdata->isused == 0,
- "This task is still being used somewhere else. You cannot send it now. Go fix your code!"
- " (use --cfg=msg/debug-multiple-use:on to get the backtrace of the other process)");
- }
- }
+ t_simdata->setUsed();
- if (msg_global->debug_multiple_use)
- MSG_BT(t_simdata->isused, "Using Backtrace");
- else
- t_simdata->isused = (void*)1;
t_simdata->comm = nullptr;
msg_global->sent_msg++;
p_simdata->waiting_task = task;
- xbt_ex_t e;
/* Try to send it by calling SIMIX network layer */
- TRY {
+ try {
smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simix call */
comm = simcall_comm_isend(SIMIX_process_self(), mailbox,t_simdata->bytes_amount,
t_simdata->rate, task, sizeof(void *), nullptr, nullptr, nullptr, task, 0);
t_simdata->comm = static_cast<simgrid::simix::Comm*>(comm);
simcall_comm_wait(comm, timeout);
}
-
- CATCH(e) {
+ catch (xbt_ex& e) {
switch (e.category) {
case cancel_error:
ret = MSG_HOST_FAILURE;
ret = MSG_TIMEOUT;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
/* If the send failed, it is not used anymore */
- if (msg_global->debug_multiple_use && t_simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)t_simdata->isused);
- t_simdata->isused = 0;
+ t_simdata->setNotUsed();
}
p_simdata->waiting_task = nullptr;
msg_error_t MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host, double timeout,
double rate)
{
- xbt_ex_t e;
msg_error_t ret = MSG_OK;
/* We no longer support getting a task from a specific host */
if (host)
XBT_WARN("Asked to write the received task in a non empty struct -- proceeding.");
/* Try to receive it by calling SIMIX network layer */
- TRY {
+ try {
simcall_comm_recv(MSG_process_self(), mailbox, task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox);
- if (msg_global->debug_multiple_use && (*task)->simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)(*task)->simdata->isused);
- (*task)->simdata->isused = 0;
+ (*task)->simdata->setNotUsed();
}
- CATCH(e) {
+ catch (xbt_ex& e) {
switch (e.category) {
case cancel_error:
ret = MSG_HOST_FAILURE;
ret = MSG_HOST_FAILURE;
break;
default:
- RETHROW;
+ throw;
}
- xbt_ex_free(e);
}
if (ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) {
#ifndef METASIMGRID_PRIVATE_H
#define METASIMGRID_PRIVATE_H
+#include <exception>
#include <functional>
#include "simgrid/msg.h"
/**************** datatypes **********************************/
/********************************* Task **************************************/
-#define MSG_BT(ptr, m) \
- do {xbt_ex_t *_xbt_ex_t = xbt_new0(xbt_ex_t, 1); \
- /* build the exception */ \
- _xbt_ex_t->msg = (bprintf(m)); \
- _xbt_ex_t->category = (xbt_errcat_t)(0); \
- _xbt_ex_t->value = (0); \
- _xbt_ex_t->procname = (char*)xbt_procname(); \
- _xbt_ex_t->pid = xbt_getpid(); \
- _xbt_ex_t->file = (char*)__FILE__; \
- _xbt_ex_t->line = __LINE__; \
- _xbt_ex_t->func = (char*)__func__; \
- _xbt_ex_t->bt_strings = NULL; \
- xbt_backtrace_current(_xbt_ex_t); \
- ptr = _xbt_ex_t; } while(0)
typedef struct simdata_task {
- simgrid::simix::Exec *compute; /* SIMIX modeling of computation */
- simgrid::simix::Comm *comm; /* SIMIX modeling of communication */
- double bytes_amount; /* Data size */
- double flops_amount; /* Computation size */
- msg_process_t sender;
- msg_process_t receiver;
- msg_host_t source;
- double priority;
- double bound; /* Capping for CPU resource */
- double rate; /* Capping for network resource */
+ ~simdata_task()
+ {
+ if (this->compute)
+ this->compute->unref();
+
+ /* parallel tasks only */
+ xbt_free(this->host_list);
+
+ xbt_dict_free(&this->affinity_mask_db);
+ }
+ void setUsed();
+ void setNotUsed()
+ {
+ this->isused = false;
+ }
+
+ simgrid::simix::Exec *compute = nullptr; /* SIMIX modeling of computation */
+ simgrid::simix::Comm *comm = nullptr; /* SIMIX modeling of communication */
+ double bytes_amount = 0.0; /* Data size */
+ double flops_amount = 0.0; /* Computation size */
+ msg_process_t sender = nullptr;
+ msg_process_t receiver = nullptr;
+ msg_host_t source = nullptr;
+ double priority = 0.0;
+ double bound = 0.0; /* Capping for CPU resource */
+ double rate = 0.0; /* Capping for network resource */
/* CPU affinity database of this task */
- xbt_dict_t affinity_mask_db; /* smx_host_t host => unsigned long mask */
+ xbt_dict_t affinity_mask_db = nullptr; /* smx_host_t host => unsigned long mask */
- void *isused; /* Indicates whether the task is used in SIMIX currently */
- int host_nb; /* ==0 if sequential task; parallel task if not */
+ bool isused = false; /* Indicates whether the task is used in SIMIX currently */
+ int host_nb = 0; /* ==0 if sequential task; parallel task if not */
/******* Parallel Tasks Only !!!! *******/
- sg_host_t *host_list;
- double *flops_parallel_amount;
- double *bytes_parallel_amount;
+ sg_host_t *host_list = nullptr;
+ double *flops_parallel_amount = nullptr;
+ double *bytes_parallel_amount = nullptr;
+
+private:
+ void reportMultipleUse() const;
} s_simdata_task_t;
/********************************* File **************************************/
const char *name, std::function<void()> code, void *data,
msg_host_t host, xbt_dict_t properties);
+inline void simdata_task::setUsed()
+{
+ if (this->isused)
+ this->reportMultipleUse();
+ if (msg_global->debug_multiple_use) {
+ // TODO, backtrace
+ }
+ this->isused = true;
+}
+
#endif
/** @brief locks on a semaphore object up until the provided timeout expires */
msg_error_t MSG_sem_acquire_timeout(msg_sem_t sem, double timeout) {
- xbt_ex_t e;
msg_error_t res = MSG_OK;
- TRY {
+ try {
simcall_sem_acquire_timeout(sem,timeout);
- } CATCH(e) {
- if (e.category == timeout_error) {
- res = MSG_TIMEOUT;
- xbt_ex_free(e);
- } else {
- RETHROW;
- }
+ } catch(xbt_ex& e) {
+ if (e.category == timeout_error)
+ return MSG_TIMEOUT;
+ throw;
}
return res;
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)");
+void simdata_task::reportMultipleUse() const
+{
+ if (msg_global->debug_multiple_use){
+ XBT_ERROR("This task is already used in there:");
+ // TODO, backtrace
+ XBT_ERROR("<missing backtrace>");
+ XBT_ERROR("And you try to reuse it from here:");
+ xbt_backtrace_display_current();
+ } else {
+ xbt_die("This task is still being used somewhere else. You cannot send it now. Go fix your code!"
+ "(use --cfg=msg/debug-multiple-use:on to get the backtrace of the other process)");
+ }
+}
+
/********************************* Task **************************************/
/** \ingroup m_task_management
* \brief Creates a new #msg_task_t.
msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data)
{
msg_task_t task = xbt_new(s_msg_task_t, 1);
- simdata_task_t simdata = xbt_new(s_simdata_task_t, 1);
+ simdata_task_t simdata = new s_simdata_task_t();
task->simdata = simdata;
/* Task structure */
xbt_free(task->name);
- if (task->simdata->compute)
- task->simdata->compute->unref();
-
- /* parallel tasks only */
- xbt_free(task->simdata->host_list);
-
- xbt_dict_free(&task->simdata->affinity_mask_db);
-
/* free main structures */
- xbt_free(task->simdata);
+ delete task->simdata;
xbt_free(task);
return MSG_OK;
else if (task->simdata->comm) {
simdata_task_t simdata = task->simdata;
simcall_comm_cancel(simdata->comm);
- if (msg_global->debug_multiple_use && simdata->isused!=0)
- xbt_ex_free(*(xbt_ex_t*)simdata->isused);
- simdata->isused = 0;
+ simdata->setNotUsed();
}
return MSG_OK;
}
if (!skip_stage1) {
double clock_prev_send = MSG_get_clock();
- TRY {
+ try {
/* At stage 1, we do not need timeout. We have to send all the memory pages even though the duration of this
* transfer exceeds the timeout value. */
XBT_VERB("Stage 1: Gonna send %llu", ramsize);
} else if (sent > ramsize)
XBT_CRITICAL("bug");
- } CATCH_ANONYMOUS {
+ }
+ catch (xbt_ex& e) {
//hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
// Stop the dirty page tracking an return (there is no memory space to release)
stop_dirty_page_tracking(ms->vm);
sg_size_t sent = 0;
double clock_prev_send = MSG_get_clock();
- TRY {
+ try {
XBT_DEBUG("Stage 2, gonna send %llu", updated_size);
sent = send_migration_data(ms->vm, ms->src_pm, ms->dst_pm, updated_size, ms->mbox, 2, stage2_round, mig_speed,
mig_timeout);
- } CATCH_ANONYMOUS {
+ }
+ catch (xbt_ex& e) {
//hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
// Stop the dirty page tracking an return (there is no memory space to release)
stop_dirty_page_tracking(ms->vm);
simcall_vm_suspend(ms->vm);
stop_dirty_page_tracking(ms->vm);
- TRY {
+ try {
XBT_DEBUG("Stage 3: Gonna send %f", remaining_size);
send_migration_data(ms->vm, ms->src_pm, ms->dst_pm, (sg_size_t)remaining_size, ms->mbox, 3, 0, mig_speed, -1);
- } CATCH_ANONYMOUS {
+ }
+ catch(xbt_ex& e) {
//hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code)
// Stop the dirty page tracking an return (there is no memory space to release)
simcall_vm_resume(ms->vm);
SIMIX_init_application();
surf_parse_open(file);
- TRY {
+ try {
parse_status = surf_parse();
surf_parse_close();
xbt_assert(!parse_status, "Parse error at %s:%d", file,surf_parse_lineno);
}
- CATCH_ANONYMOUS {
+ catch (xbt_ex& e) {
XBT_ERROR("Unrecoverable error at %s:%d. The full exception stack follows, in case it helps you to diagnose the problem.",
file, surf_parse_lineno);
- RETHROW;
+ throw;
}
}
*/
void SIMIX_create_environment(const char *file)
{
- xbt_ex_t e;
double start = 0, end = 0;
if(XBT_LOG_ISENABLED(simix_environment, xbt_log_priority_debug))
start = xbt_os_time();
- TRY {
+ try {
parse_platform_file(file);
- } CATCH (e) {
- xbt_die("Error while loading %s: %s", file, e.msg);
+ }
+ catch (xbt_ex& e) {
+ xbt_die("Error while loading %s: %s", file, e.what());
}
if(XBT_LOG_ISENABLED(simix_environment, xbt_log_priority_debug))
end = xbt_os_time();
XBT_DEBUG("PARSE TIME: %g", (end - start));
-
}
void SIMIX_post_create_environment(void)
// a context object with the current context mestro):
simgrid::simix::create_maestro(maestro_code);
- /* context exception handlers */
- __xbt_running_ctx_fetch = &SIMIX_process_get_running_context;
- __xbt_ex_terminate = &SIMIX_process_exception_terminate;
-
/* Prepare to display some more info when dying on Ctrl-C pressing */
signal(SIGINT, inthandler);
/* Let's free maestro now */
delete simix_global->maestro_process->context;
simix_global->maestro_process->context = nullptr;
- xbt_free(simix_global->maestro_process->running_ctx);
- simix_global->maestro_process->running_ctx = nullptr;
delete simix_global->maestro_process;
simix_global->maestro_process = nullptr;
- /* Restore the default exception setup */
- __xbt_running_ctx_fetch = &__xbt_ex_ctx_default;
- __xbt_ex_terminate = &__xbt_ex_terminate_default;
-
/* Finish context module and SURF */
SIMIX_context_mod_exit();
}
/* if there is an exception during a waitany or a testany, indicate the position of the failed communication */
- if (simcall->issuer->doexception) {
- if (simcall->call == SIMCALL_COMM_WAITANY) {
- simcall->issuer->running_ctx->exception.value = xbt_dynar_search(simcall_comm_waitany__get__comms(simcall), &synchro);
+ if (simcall->issuer->exception) {
+ // In order to modify the exception we have to rethrow it:
+ try {
+ std::rethrow_exception(simcall->issuer->exception);
}
- else if (simcall->call == SIMCALL_COMM_TESTANY) {
- simcall->issuer->running_ctx->exception.value = xbt_dynar_search(simcall_comm_testany__get__comms(simcall), &synchro);
+ catch(xbt_ex& e) {
+ if (simcall->call == SIMCALL_COMM_WAITANY) {
+ e.value = xbt_dynar_search(simcall_comm_waitany__get__comms(simcall), &synchro);
+ }
+ else if (simcall->call == SIMCALL_COMM_TESTANY) {
+ e.value = xbt_dynar_search(simcall_comm_testany__get__comms(simcall), &synchro);
+ }
+ simcall->issuer->exception = std::make_exception_ptr(e);
+ }
+ catch(...) {
+ // Nothing to do
}
}
/******************************** Exceptions *********************************/
/** @brief Ask to the provided simix process to raise the provided exception */
-#define SMX_EXCEPTION(issuer, cat, val, msg) \
- if (1) { \
- smx_process_t _smx_throw_issuer = (issuer); /* evaluate only once */\
- THROW_PREPARE(_smx_throw_issuer->running_ctx, (cat), (val), xbt_strdup(msg)); \
- _smx_throw_issuer->doexception = 1; \
+#define SMX_EXCEPTION(issuer, cat, val, msg) \
+ if (1) { \
+ smx_process_t _smx_throw_issuer = (issuer); /* evaluate only once */ \
+ xbt_ex e(msg); \
+ e.category = cat; \
+ e.value = val; \
+ e.procname = xbt_procname(); \
+ e.pid = xbt_getpid(); \
+ e.file = __FILE__; \
+ e.line = __LINE__; \
+ e.func = __func__; \
+ _smx_throw_issuer->exception = std::make_exception_ptr(e); \
} else ((void)0)
/* ******************************** File ************************************ */
while ((process = (smx_process_t) xbt_swag_extract(simix_global->process_to_destroy))) {
XBT_DEBUG("Getting rid of %p",process);
-
delete process->context;
-
- /* Free the exception allocated at creation time */
- free(process->running_ctx);
xbt_dict_free(&process->properties);
-
xbt_fifo_free(process->comms);
-
xbt_dynar_free(&process->on_exit);
-
delete process;
}
}
maestro->ppid = -1;
maestro->name = "";
maestro->data = nullptr;
- maestro->running_ctx = (xbt_running_ctx_t*) xbt_malloc0(sizeof(xbt_running_ctx_t));
- XBT_RUNNING_CTX_INITIALIZE(maestro->running_ctx);
if (!code) {
maestro->context = SIMIX_context_new(std::function<void()>(), nullptr, maestro);
std::move(code),
simix_global->cleanup_process_function, process);
- 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()){
- MC_ignore_heap(process->running_ctx, sizeof(*process->running_ctx));
- }
-
/* Add properties */
process->properties = properties;
process->context = simix_global->context_factory->attach(
simix_global->cleanup_process_function, process);
- 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()){
- MC_ignore_heap(process->running_ctx, sizeof(*process->running_ctx));
- }
-
/* Add properties */
process->properties = properties;
process->context->iwannadie = 1;
process->blocked = 0;
process->suspended = 0;
- process->doexception = 0;
+ process->exception = nullptr;
/* destroy the blocking synchro if any */
if (process->waiting_synchro) {
if (self->suspended) {
XBT_DEBUG("Hey! I'm suspended.");
- xbt_assert(!self->doexception, "Gasp! This exception may be lost by subsequent calls.");
+ xbt_assert(self->exception != nullptr, "Gasp! This exception may be lost by subsequent calls.");
self->suspended = 0;
SIMIX_process_suspend(self, self);
}
- if (self->doexception) {
+ if (self->exception != nullptr) {
XBT_DEBUG("Wait, maestro left me an exception");
- self->doexception = 0;
- RETHROW;
+ std::exception_ptr exception = std::move(self->exception);
+ self->exception = nullptr;
+ std::rethrow_exception(std::move(exception));
}
if(SMPI_switch_data_segment && self->segment_index != -1){
}
}
-/* callback: context fetching */
-xbt_running_ctx_t *SIMIX_process_get_running_context(void)
-{
- smx_process_t process = SIMIX_process_self();
- if (process)
- return process->running_ctx;
- else
- return nullptr;
-}
-
/* callback: termination */
void SIMIX_process_exception_terminate(xbt_ex_t * e)
{
simgrid::xbt::string name;
sg_host_t host = nullptr; /* the host on which the process is running */
smx_context_t context = nullptr; /* the context (uctx/raw/thread) that executes the user function */
- xbt_running_ctx_t *running_ctx = nullptr;
// TODO, pack them
- bool doexception = false;
+ std::exception_ptr exception;
bool blocked = false;
bool suspended = false;
bool auto_restart = false;
XBT_PRIVATE void SIMIX_process_cleanup(smx_process_t arg);
XBT_PRIVATE void SIMIX_process_empty_trash(void);
XBT_PRIVATE void SIMIX_process_yield(smx_process_t self);
-XBT_PRIVATE xbt_running_ctx_t *SIMIX_process_get_running_context(void);
XBT_PRIVATE void SIMIX_process_exception_terminate(xbt_ex_t * e);
XBT_PRIVATE void SIMIX_process_change_host(smx_process_t process,
sg_host_t dest);
ret smpi_coll_tuned_ ## cat ## _ ## automatic(COLL_UNPAREN args)\
{\
double time1, time2, time_min=DBL_MAX;\
- volatile int min_coll=-1, global_coll=-1;\
- volatile int i;\
- xbt_ex_t ex;\
+ int min_coll=-1, global_coll=-1;\
+ int i;\
double buf_in, buf_out, max_min=DBL_MAX;\
for (i = 0; mpi_coll_##cat##_description[i].name; i++){\
if(!strcmp(mpi_coll_##cat##_description[i].name, "automatic"))continue;\
smpi_mpi_barrier(comm);\
TRACE_AUTO_COLL(cat)\
time1 = SIMIX_get_clock();\
- TRY{\
+ try {\
((int (*) args)\
mpi_coll_##cat##_description[i].coll) args2 ;\
}\
- CATCH(ex) {\
- xbt_ex_free(ex);\
+ catch (std::exception& ex) {\
continue;\
}\
time2 = SIMIX_get_clock();\
int smpi_shared_known_call(const char* func, const char* input)
{
char* loc = bprintf("%s:%s", func, input);
- xbt_ex_t ex;
int known = 0;
if (calls==nullptr) {
calls = xbt_dict_new_homogeneous(nullptr);
}
- TRY {
+ try {
xbt_dict_get(calls, loc); /* Succeed or throw */
known = 1;
- }
- TRY_CLEANUP {
xbt_free(loc);
}
- CATCH(ex) {
+ catch (xbt_ex& ex) {
+ xbt_free(loc);
if (ex.category != not_found_error)
- RETHROW;
- xbt_ex_free(ex);
+ throw;
+ }
+ catch(...) {
+ xbt_free(loc);
+ throw;
}
return known;
}
if(elem==nullptr)
return MPI_ERR_ARG;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
- void * value;
+ void* value = nullptr;
int flag;
if(smpi_comm_attr_get(comm, keyval, &value, &flag)==MPI_SUCCESS){
int ret = elem->delete_fn(comm, keyval, value, &flag);
static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
if(elem==nullptr)
return MPI_ERR_ARG;
- xbt_ex_t ex;
if(comm->attributes==nullptr){
*flag=0;
return MPI_SUCCESS;
}
- TRY {
+ try {
*static_cast<void**>(attr_value) = xbt_dict_get_ext(comm->attributes,
reinterpret_cast<const char*>(&keyval), sizeof(int));
*flag=1;
- } CATCH(ex) {
+ }
+ catch (xbt_ex& ex) {
*flag=0;
- xbt_ex_free(ex);
}
return MPI_SUCCESS;
}
if(elem==nullptr)
return MPI_ERR_ARG;
int flag;
- void* value;
+ void* value = nullptr;
smpi_comm_attr_get(comm, keyval, &value, &flag);
if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){
int ret = elem->delete_fn(comm, keyval, value, &flag);
if(elem==nullptr)
return MPI_ERR_ARG;
if(elem->delete_fn!=MPI_NULL_DELETE_FN){
- void * value;
+ void * value = nullptr;
int flag;
if(smpi_type_attr_get(type, keyval, &value, &flag)==MPI_SUCCESS){
int ret = elem->delete_fn(type, keyval, value, &flag);
static_cast<smpi_type_key_elem>(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast<const char*>(&keyval), sizeof(int)));
if(elem==nullptr)
return MPI_ERR_ARG;
- xbt_ex_t ex;
if(type->attributes==nullptr){
*flag=0;
return MPI_SUCCESS;
}
- TRY {
+ try {
*static_cast<void**>(attr_value) = xbt_dict_get_ext(type->attributes, reinterpret_cast<const char*>(&keyval), sizeof(int));
*flag=1;
}
- CATCH(ex) {
+ catch (xbt_ex& ex) {
*flag=0;
- xbt_ex_free(ex);
}
return MPI_SUCCESS;
}
if(elem==nullptr)
return MPI_ERR_ARG;
int flag;
- void* value;
+ void* value = nullptr;
smpi_type_attr_get(type, keyval, &value, &flag);
if(flag!=0 && elem->delete_fn!=MPI_NULL_DELETE_FN){
int ret = elem->delete_fn(type, keyval, value, &flag);
}
int PMPI_Info_delete(MPI_Info info, char *key){
- xbt_ex_t e;
if (info == nullptr || key==nullptr)
return MPI_ERR_ARG;
- TRY {
+ try {
xbt_dict_remove(info->info_dict, key);
- }CATCH(e){
- xbt_ex_free(e);
+ }
+ catch(xbt_ex& e){
return MPI_ERR_INFO_NOKEY;
}
return MPI_SUCCESS;
// Update the disk usage
// Update the file size
// For each action of type write
- volatile double current_progress =
+ double current_progress =
delta * lmm_variable_getvalue(action->getVariable());
long int incr = current_progress;
double Model::next_occuring_event_full(double /*now*/) {
THROW_UNIMPLEMENTED;
+ return 0.0;
}
double Model::shareResourcesMaxMin(ActionList *running_actions,
/* backtrace_linux - backtrace displaying on linux platform */
-/* This file is included by ex.c on need (have execinfo.h, popen & addrline)*/
+/* This file is included by ex.cpp on need (have execinfo.h, popen & addrline)*/
/* Copyright (c) 2008-2015. The SimGrid Team.
* All rights reserved. */
#include <execinfo.h>
#include <sys/stat.h>
-/* This file is to be included in ex.c, so the following headers are not mandatory, but it's to make sure that eclipse see them too */
+/* This file is to be included in ex.cpp, so the following headers are not mandatory, but it's to make sure that eclipse see them too */
#include "xbt/ex.h"
#include "xbt/log.h"
#include "xbt/str.h"
static _Unwind_Reason_Code
backtrace_helper (struct _Unwind_Context *ctx, void *a)
{
- struct trace_arg *arg = a;
+ struct trace_arg *arg = (struct trace_arg *) a;
/* We are first called with address in the __backtrace function.
Skip it. */
for(i=0; i < size; i++)
array[i] = NULL;
- struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+ struct trace_arg arg;
+ arg .array = array;
+ arg.size = size;
+ arg.cnt = -1;
if (size >= 1)
_Unwind_Backtrace(backtrace_helper, &arg);
void xbt_backtrace_current(xbt_ex_t * e)
{
- e->used = backtrace((void **) e->bt, XBT_BACKTRACE_SIZE);
- if (e->used == 0) {
+ void* bt[XBT_BACKTRACE_SIZE];
+ std::size_t used = backtrace((void **) bt, XBT_BACKTRACE_SIZE);
+ e->bt.assign(bt, bt + used);
+ if (used == 0) {
fprintf(stderr, "The backtrace() function failed, which probably means that the memory is exhausted. Here is a crude dump of the exception that I was trying to build:");
fprintf(stderr, "%s(%d) [%s:%d] %s",
- e->procname, e->pid, e->file, e->line, e->msg);
+ e->procname.c_str(), e->pid, e->file, e->line, e->what());
fprintf(stderr, "Bailing out now since there is nothing I can do without a decent amount of memory. Please go fix the memleaks\n");
exit(1);
}
void xbt_ex_setup_backtrace(xbt_ex_t * e) //FIXME: This code could be greatly improved/simplifyied with http://cairo.sourcearchive.com/documentation/1.9.4/backtrace-symbols_8c-source.html
{
- int i;
-
/* to get the backtrace from the libc */
char **backtrace_syms;
xbt_assert(e, "Backtrace not setup yet, cannot set it up for display");
- e->bt_strings = NULL;
+ e->bt_strings.clear();
if (xbt_binary_name == NULL) /* no binary name, nothing to do */
return;
- if (e->used <= 1)
+ if (e->bt.empty())
return;
/* ignore first one, which is xbt_backtrace_current() */
- e->used--;
- memmove(e->bt, e->bt + 1, (sizeof *e->bt) * e->used);
+ e->bt.erase(e->bt.begin());
- backtrace_syms = backtrace_symbols(e->bt, e->used);
+ backtrace_syms = backtrace_symbols(e->bt.data(), e->bt.size());
/* build the commandline */
if (stat(xbt_binary_name, &stat_buf)) {
/* Damn. binary not in current dir. We'll have to dig the PATH to find it */
- for (i = 0; environ[i]; i++) {
+ for (std::size_t i = 0; environ[i]; i++) {
if (!strncmp("PATH=", environ[i], 5)) {
xbt_dynar_t path = xbt_str_split(environ[i] + 5, ":");
unsigned int cpt;
xbt_dynar_free(&path);
if (stat(binary_name, &stat_buf)) {
/* not found */
- e->used = 1;
- e->bt_strings = xbt_new(char *, 1);
-
- e->bt_strings[0] = bprintf("(binary '%s' not found in the PATH)", xbt_binary_name);
+ char* str = bprintf("(binary '%s' not found in the PATH)", xbt_binary_name);
+ e->bt_strings = { str };
+ free(str);
free(backtrace_syms);
return;
}
} else {
binary_name = xbt_strdup(xbt_binary_name);
}
- int strsize=strlen(ADDR2LINE) + 25 + strlen(binary_name) + 32 * e->used;
+ int strsize = strlen(ADDR2LINE) + 25 + strlen(binary_name) + 32 * e->bt_strings.size();
cmd = curr = xbt_new(char, strsize);
curr += snprintf(curr,strsize, "%s -f -e %s ", ADDR2LINE, binary_name);
free(binary_name);
- addrs = xbt_new(char *, e->used);
- for (i = 0; i < e->used; i++) {
+ addrs = xbt_new(char *, e->bt.size());
+ for (std::size_t i = 0; i < e->bt.size(); i++) {
char *p;
/* retrieve this address */
- XBT_DEBUG("Retrieving address number %d from '%s'", i, backtrace_syms[i]);
+ XBT_DEBUG("Retrieving address number %zd from '%s'", i, backtrace_syms[i]);
snprintf(buff, 256, "%s", strchr(backtrace_syms[i], '[') + 1);
p = strchr(buff, ']');
*p = '\0';
addrs[i] = xbt_strdup(buff);
else
addrs[i] = xbt_strdup("0x0");
- XBT_DEBUG("Set up a new address: %d, '%s'(%p)", i, addrs[i], addrs[i]);
+ XBT_DEBUG("Set up a new address: %zd, '%s'(%p)", i, addrs[i], addrs[i]);
/* Add it to the command line args */
curr += snprintf(curr,strsize, "%s ", addrs[i]);
addr_len = strlen(addrs[0]);
/* parse the output and build a new backtrace */
- e->bt_strings = xbt_new(char *, e->used);
+ e->bt_strings.resize(e->bt.size());
XBT_VERB("Fire a first command: '%s'", cmd);
pipe = popen(cmd, "r");
xbt_die("Cannot fork addr2line to display the backtrace");
}
- for (i = 0; i < e->used; i++) {
- XBT_DEBUG("Looking for symbol %d, addr = '%s'", i, addrs[i]);
+ for (std::size_t i = 0; i < e->bt.size(); i++) {
+ XBT_DEBUG("Looking for symbol %zd, addr = '%s'", i, addrs[i]);
if (fgets(line_func, 1024, pipe)) {
line_func[strlen(line_func) - 1] = '\0';
} else {
- XBT_VERB("Cannot run fgets to look for symbol %d, addr %s", i, addrs[i]);
+ XBT_VERB("Cannot run fgets to look for symbol %zd, addr %s", i, addrs[i]);
strncpy(line_func, "???",3);
}
if (fgets(line_pos, 1024, pipe)) {
line_pos[strlen(line_pos) - 1] = '\0';
} else {
- XBT_VERB("Cannot run fgets to look for symbol %d, addr %s", i, addrs[i]);
+ XBT_VERB("Cannot run fgets to look for symbol %zd, addr %s", i, addrs[i]);
strncpy(line_pos, backtrace_syms[i],1024);
}
if (strcmp("??", line_func) != 0) {
XBT_DEBUG("Found static symbol %s() at %s", line_func, line_pos);
- e->bt_strings[i] =
- bprintf("** In %s() at %s", line_func, line_pos);
+ char* s = bprintf("** In %s() at %s", line_func, line_pos);
+ e->bt_strings[i] = s;
+ free(s);
} else {
/* Damn. The symbol is in a dynamic library. Let's get wild */
char *maps_name;
if (!found) {
XBT_VERB("Problem while reading the maps file. Following backtrace will be mangled.");
XBT_DEBUG("No dynamic. Static symbol: %s", backtrace_syms[i]);
- e->bt_strings[i] = bprintf("** In ?? (%s)", backtrace_syms[i]);
+ char* s = bprintf("** In ?? (%s)", backtrace_syms[i]);
+ e->bt_strings[i] = s;
+ free(s);
continue;
}
/* check whether the trick worked */
if (strcmp("??", line_func)) {
XBT_DEBUG("Found dynamic symbol %s() at %s", line_func, line_pos);
- e->bt_strings[i] = bprintf("** In %s() at %s", line_func, line_pos);
+ char* s = bprintf("** In %s() at %s", line_func, line_pos);
+ e->bt_strings[i] = s;
+ free(s);
} else {
/* damn, nothing to do here. Let's print the raw address */
XBT_DEBUG("Dynamic symbol not found. Raw address = %s", backtrace_syms[i]);
- e->bt_strings[i] = bprintf("** In ?? at %s", backtrace_syms[i]);
+ char* s = bprintf("** In ?? at %s", backtrace_syms[i]);
+ e->bt_strings[i] = s;
+ free(s);
}
}
free(addrs[i]);
if (!strncmp("main", line_func, strlen("main")) ||
!strncmp("xbt_thread_context_wrapper", line_func, strlen("xbt_thread_context_wrapper"))
|| !strncmp("smx_ctx_sysv_wrapper", line_func, strlen("smx_ctx_sysv_wrapper"))) {
- int j;
- for (j = i + 1; j < e->used; j++)
+ for (std::size_t j = i + 1; j < e->bt.size(); j++)
free(addrs[j]);
- e->used = i + 1;
if (!strncmp
("xbt_thread_context_wrapper", line_func, strlen("xbt_thread_context_wrapper"))) {
- free(e->bt_strings[i]);
- e->bt_strings[i] = xbt_strdup("** (in a separate thread)");
+ e->bt_strings.push_back("** (in a separate thread)");
+ } else {
+ e->bt_strings.push_back("");
}
+
}
}
pclose(pipe);
// Exit from the catch blog (and do the correct exceptio cleaning)
// before attempting to THROWF.
#define TRANSLATE_EXCEPTIONS(...) \
- catch(simgrid::config::missing_key_error& e) { goto on_exception; } \
- catch(...) { goto on_missing_key; } \
- on_missing_key: THROWF(not_found_error, 0, __VA_ARGS__); \
- on_exception: THROWF(not_found_error, 0, __VA_ARGS__);
+ catch(simgrid::config::missing_key_error& e) { THROWF(not_found_error, 0, __VA_ARGS__); abort(); } \
+ catch(...) { THROWF(not_found_error, 0, __VA_ARGS__); abort(); }
/** @brief Set the value of a variable, using the string representation of that value
*
xbt_test_add("Access to a non-existant entry");
{
- xbt_ex_t e;
-
- TRY {
+ try {
xbt_cfg_set_parse("color:blue");
- } CATCH(e) {
+ } catch(xbt_ex& e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(e);
}
}
xbt_cfg_free(&simgrid_config);
void xbt_test_exception(xbt_ex_t e)
{
- _xbt_test_fail(e.file, e.line, "Exception %s raised: %s", xbt_ex_catname(e.category), e.msg);
+ _xbt_test_fail(e.file, e.line, "Exception %s raised: %s", xbt_ex_catname(e.category), e.what());
}
void xbt_test_expect_failure(void)
#include <string.h>
#include <stdio.h>
+#include "xbt/dict.h"
#include "xbt/ex.h"
#include "xbt/log.h"
#include "xbt/mallocator.h"
}
/** Returns the amount of elements in the dict */
-inline unsigned int xbt_dict_size(xbt_dict_t dict)
+unsigned int xbt_dict_size(xbt_dict_t dict)
{
return (dict ? (unsigned int) dict->count : (unsigned int) 0);
}
/* Expend the size of the dict */
static void xbt_dict_rehash(xbt_dict_t dict)
{
- const int oldsize = dict->table_size + 1;
- int newsize = oldsize * 2;
- int i;
+ const unsigned oldsize = dict->table_size + 1;
+ unsigned newsize = oldsize * 2;
xbt_dictelm_t *currcell;
xbt_dictelm_t *twincell;
xbt_dictelm_t bucklet;
dict->table = currcell;
XBT_DEBUG("REHASH (%d->%d)", oldsize, newsize);
- for (i = 0; i < oldsize; i++, currcell++) {
+ for (unsigned i = 0; i < oldsize; i++, currcell++) {
if (!*currcell) /* empty cell */
continue;
twincell = currcell + oldsize;
* Set the \a data in the structure under the \a key, which can be any kind of data, as long as its length is provided
* in \a key_len.
*/
-inline void xbt_dict_set_ext(xbt_dict_t dict, const char *key, int key_len, void *data, void_f_pvoid_t free_ctn)
+void xbt_dict_set_ext(xbt_dict_t dict, const char *key, int key_len, void *data, void_f_pvoid_t free_ctn)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
*
* set the \a data in the structure under the \a key, which is anull terminated string.
*/
-inline void xbt_dict_set(xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t free_ctn)
+void xbt_dict_set(xbt_dict_t dict, const char *key, void *data, void_f_pvoid_t free_ctn)
{
xbt_dict_set_ext(dict, key, strlen(key), data, free_ctn);
}
*
* Search the given \a key. Throws not_found_error when not found.
*/
-inline void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
+void *xbt_dict_get_ext(xbt_dict_t dict, const char *key, int key_len)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
* Search the given \a key. Throws not_found_error when not found.
* Check xbt_dict_get_or_null() for a version returning NULL without exception when not found.
*/
-inline void *xbt_dict_get(xbt_dict_t dict, const char *key)
+void *xbt_dict_get(xbt_dict_t dict, const char *key)
{
return xbt_dict_get_elm(dict, key)->content;
}
* Search the given \a key. Throws not_found_error when not found.
* Check xbt_dict_get_or_null() for a version returning NULL without exception when not found.
*/
-inline xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
+xbt_dictelm_t xbt_dict_get_elm(xbt_dict_t dict, const char *key)
{
xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
/**
* \brief like xbt_dict_get(), but returning NULL when not found
*/
-inline void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
+void *xbt_dict_get_or_null(xbt_dict_t dict, const char *key)
{
xbt_dictelm_t current = xbt_dict_get_elm_or_null(dict, key);
/**
* \brief like xbt_dict_get_elm(), but returning NULL when not found
*/
-inline xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
+xbt_dictelm_t xbt_dict_get_elm_or_null(xbt_dict_t dict, const char *key)
{
unsigned int hash_code = xbt_str_hash(key);
xbt_dictelm_t current = dict->table[hash_code & dict->table_size];
*
* Remove the entry associated with the given \a key (throws not_found)
*/
-inline void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
+void xbt_dict_remove_ext(xbt_dict_t dict, const char *key, int key_len)
{
unsigned int hash_code = xbt_str_hash_ext(key, key_len);
xbt_dictelm_t previous = NULL;
*
* Remove the entry associated with the given \a key
*/
-inline void xbt_dict_remove(xbt_dict_t dict, const char *key)
+void xbt_dict_remove(xbt_dict_t dict, const char *key)
{
xbt_dict_remove_ext(dict, key, strlen(key));
}
* \brief Return the number of elements in the dict.
* \param dict a dictionary
*/
-inline int xbt_dict_length(xbt_dict_t dict)
+int xbt_dict_length(xbt_dict_t dict)
{
return dict->count;
}
/** @brief function to be used in xbt_dict_dump as long as the stored values are strings */
void xbt_dict_dump_output_string(void *s)
{
- fputs(s, stdout);
+ fputs((char*) s, stdout);
}
/**
* \brief test if the dict is empty or not
*/
-inline int xbt_dict_is_empty(xbt_dict_t dict)
+int xbt_dict_is_empty(xbt_dict_t dict)
{
return !dict || (xbt_dict_length(dict) == 0);
}
}
#ifdef SIMGRID_TEST
+#include <time.h>
#include "xbt.h"
#include "xbt/ex.h"
#include "src/internal_config.h"
static void search_ext(xbt_dict_t head, const char *key, const char *data)
{
- char *found;
-
xbt_test_add("Search %s", key);
- found = xbt_dict_get(head, key);
+ char *found = (char*) xbt_dict_get(head, key);
xbt_test_log("Found %s", found);
if (data) {
xbt_test_assert(found, "data do not match expectations: found NULL while searching for %s", data);
static void search_not_found(xbt_dict_t head, const char *data)
{
int ok = 0;
- xbt_ex_t e;
-
xbt_test_add("Search %s (expected not to be found)", data);
- TRY {
- data = xbt_dict_get(head, data);
+ try {
+ data = (const char*) xbt_dict_get(head, data);
THROWF(unknown_error, 0, "Found something which shouldn't be there (%s)", data);
- } CATCH(e) {
+ }
+ catch(xbt_ex& e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(e);
ok = 1;
}
xbt_test_assert(ok, "Exception not raised");
xbt_test_add("Traversal and search the empty dictionary");
head = homogeneous ? xbt_dict_new_homogeneous(&free) : xbt_dict_new();
traverse(head);
- TRY {
+ try {
debuged_remove(head, "12346");
- } CATCH(e) {
+ }
+ catch(xbt_ex& e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(e);
}
xbt_dict_free(&head);
/* RETRIEVE */
xbt_test_add("Search 123");
- data = xbt_dict_get(head, "123");
+ data = (char*) xbt_dict_get(head, "123");
xbt_test_assert(data);
xbt_test_assert(!strcmp("123", data));
fill(&head, homogeneous);
count(head, 7);
xbt_test_add("Remove non existing data");
- TRY {
+ try {
debuged_remove(head, "Does not exist");
- } CATCH(e) {
+ }
+ catch(xbt_ex& e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(e);
}
traverse(head);
debuged_remove(head, "123456");
traverse(head);
count(head, 3);
- TRY {
+ try {
debuged_remove(head, "12346");
- } CATCH(e) {
+ }
+ catch(xbt_ex& e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(e);
traverse(head);
}
debuged_remove(head, "1234");
traverse(head);
debuged_remove(head, "123");
traverse(head);
- TRY {
+ try {
debuged_remove(head, "12346");
- } CATCH(e) {
+ }
+ catch(xbt_ex& e) {
if (e.category != not_found_error)
xbt_test_exception(e);
- xbt_ex_free(e);
}
traverse(head);
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
for (j = 0; j < 1000; j++) {
char *data = NULL;
- key = xbt_malloc(SIZEOFKEY);
+ key = (char*) xbt_malloc(SIZEOFKEY);
do {
for (k = 0; k < SIZEOFKEY - 1; k++)
key[k] = rand() % ('z' - 'a') + 'a';
key[k] = '\0';
/* printf("[%d %s]\n",j,key); */
- data = xbt_dict_get_or_null(head, key);
+ data = (char*) xbt_dict_get_or_null(head, key);
} while (data != NULL);
xbt_dict_set(head, key, key, &free);
- data = xbt_dict_get(head, key);
+ data = (char*) xbt_dict_get(head, key);
xbt_test_assert(!strcmp(key, data), "Retrieved value (%s) != Injected value (%s)", key, data);
count(head, j + 1);
xbt_test_add("Fill %d elements, with keys being the number of element", NB_ELM);
for (j = 0; j < NB_ELM; j++) {
/* if (!(j%1000)) { printf("."); fflush(stdout); } */
- key = xbt_malloc(10);
+ key = (char*) xbt_malloc(10);
snprintf(key,10, "%d", j);
xbt_dict_set(head, key, key, &free);
xbt_test_log("There is %d elements", i);
xbt_test_add("Search my %d elements 20 times", NB_ELM);
- key = xbt_malloc(10);
+ key = (char*) xbt_malloc(10);
for (i = 0; i < 20; i++) {
void *data;
/* if (i%10) printf("."); else printf("%d",i/10); fflush(stdout); */
free(key);
xbt_test_add("Remove my %d elements", NB_ELM);
- key = xbt_malloc(10);
+ key = (char*) xbt_malloc(10);
for (j = 0; j < NB_ELM; j++) {
/* if (!(j%10000)) printf("."); fflush(stdout); */
snprintf(key,10, "%d", j);
int i;
for (i = 0; i < count; ++i)
xbt_dict_set_ext(dict, (char*) &i, sizeof(i), (void*) (intptr_t) i, NULL);
- xbt_test_assert(xbt_dict_size(dict) == count, "Bad number of elements in the dictionnary");
+ xbt_test_assert(xbt_dict_size(dict) == (unsigned) count, "Bad number of elements in the dictionnary");
xbt_test_add("Check elements");
for (i = 0; i < count; ++i) {
int res = (int) (intptr_t) xbt_dict_get_ext(dict, (char*) &i, sizeof(i));
- xbt_test_assert(xbt_dict_size(dict) == count, "Unexpected value at index %i, expected %i but was %i", i, i, res);
+ xbt_test_assert(xbt_dict_size(dict) == (unsigned) count, "Unexpected value at index %i, expected %i but was %i", i, i, res);
}
xbt_test_add("Free the array");
/* dict_elm - elements of generic dictionnaries */
-/* This file is not to be loaded from anywhere but dict.c */
+/* This file is not to be loaded from anywhere but dict.cpp */
/* Copyright (c) 2004-2011, 2013-2014. The SimGrid Team.
* All rights reserved. */
#include "xbt/dict.h"
#include "xbt/mallocator.h"
+SG_BEGIN_DECL()
+
#define MAX_FILL_PERCENT 80
typedef struct s_xbt_het_dictelm {
XBT_PRIVATE void xbt_dictelm_free(xbt_dict_t dict, xbt_dictelm_t element);
XBT_PRIVATE void xbt_dictelm_set_data(xbt_dict_t dict, xbt_dictelm_t element, void *data, void_f_pvoid_t free_ctn);
+SG_END_DECL()
+
#endif /* _XBT_DICT_PRIVATE_H_ */
*
* \param dynar who to squeeze
*/
-inline void xbt_dynar_reset(xbt_dynar_t const dynar)
+void xbt_dynar_reset(xbt_dynar_t const dynar)
{
_sanity_check_dynar(dynar);
*
* kilkil a dynar and its content
*/
-inline void xbt_dynar_free(xbt_dynar_t * dynar)
+void xbt_dynar_free(xbt_dynar_t * dynar)
{
if (dynar && *dynar) {
xbt_dynar_reset(*dynar);
*
* \param dynar the dynar we want to mesure
*/
-inline unsigned long xbt_dynar_length(const xbt_dynar_t dynar)
+unsigned long xbt_dynar_length(const xbt_dynar_t dynar)
{
return (dynar ? (unsigned long) dynar->used : (unsigned long) 0);
}
*\param dynar the dynat we want to check
*/
-inline int xbt_dynar_is_empty(const xbt_dynar_t dynar)
+int xbt_dynar_is_empty(const xbt_dynar_t dynar)
{
return (xbt_dynar_length(dynar) == 0);
}
* \param idx index of the slot we want to retrieve
* \param[out] dst where to put the result to.
*/
-inline void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void *const dst)
+void xbt_dynar_get_cpy(const xbt_dynar_t dynar, const unsigned long idx, void *const dst)
{
_sanity_check_dynar(dynar);
_check_inbound_idx(dynar, idx);
* \warning The returned value is the actual content of the dynar.
* Make a copy before fooling with it.
*/
-inline void *xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+void *xbt_dynar_get_ptr(const xbt_dynar_t dynar, const unsigned long idx)
{
void *res;
_sanity_check_dynar(dynar);
return res;
}
-inline void *xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx)
+void *xbt_dynar_set_at_ptr(const xbt_dynar_t dynar, const unsigned long idx)
{
_sanity_check_dynar(dynar);
*
* If you want to free the previous content, use xbt_dynar_replace().
*/
-inline void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void *const src)
+void xbt_dynar_set(xbt_dynar_t dynar, const int idx, const void *const src)
{
memcpy(xbt_dynar_set_at_ptr(dynar, idx), src, dynar->elmsize);
}
* Set the Nth element of a dynar, expanding the dynar if needed, and moving the previously existing value and all
* subsequent ones to one position right in the dynar.
*/
-inline void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void *const src)
+void xbt_dynar_insert_at(xbt_dynar_t const dynar, const int idx, const void *const src)
{
/* checks done in xbt_dynar_insert_at_ptr */
memcpy(xbt_dynar_insert_at_ptr(dynar, idx), src, dynar->elmsize);
*/
int xbt_dynar_member(xbt_dynar_t const dynar, void *const elem)
{
- xbt_ex_t e;
-
- TRY {
+ try {
xbt_dynar_search(dynar, elem);
- } CATCH(e) {
- if (e.category == not_found_error) {
- xbt_ex_free(e);
+ }
+ catch (xbt_ex& e) {
+ if (e.category == not_found_error)
return 0;
- }
- RETHROW;
+ throw;
}
return 1;
}
* You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
* xbt_dynar_push_as() does.
*/
-inline void *xbt_dynar_push_ptr(xbt_dynar_t const dynar)
+void *xbt_dynar_push_ptr(xbt_dynar_t const dynar)
{
return xbt_dynar_insert_at_ptr(dynar, dynar->used);
}
/** @brief Add an element at the end of the dynar */
-inline void xbt_dynar_push(xbt_dynar_t const dynar, const void *const src)
+void xbt_dynar_push(xbt_dynar_t const dynar, const void *const src)
{
/* checks done in xbt_dynar_insert_at_ptr */
memcpy(xbt_dynar_insert_at_ptr(dynar, dynar->used), src, dynar->elmsize);
* You can then use regular affectation to set its value instead of relying on the slow memcpy. This is what
* xbt_dynar_pop_as() does.
*/
-inline void *xbt_dynar_pop_ptr(xbt_dynar_t const dynar)
+void *xbt_dynar_pop_ptr(xbt_dynar_t const dynar)
{
_check_populated_dynar(dynar);
XBT_CDEBUG(xbt_dyn, "Pop %p", (void *) dynar);
}
/** @brief Get and remove the last element of the dynar */
-inline void xbt_dynar_pop(xbt_dynar_t const dynar, void *const dst)
+void xbt_dynar_pop(xbt_dynar_t const dynar, void *const dst)
{
/* sanity checks done by remove_at */
XBT_CDEBUG(xbt_dyn, "Pop %p", (void *) dynar);
*
* This is less efficient than xbt_dynar_push()
*/
-inline void xbt_dynar_unshift(xbt_dynar_t const dynar, const void *const src)
+void xbt_dynar_unshift(xbt_dynar_t const dynar, const void *const src)
{
/* sanity checks done by insert_at */
xbt_dynar_insert_at(dynar, 0, src);
*
* This is less efficient than xbt_dynar_pop()
*/
-inline void xbt_dynar_shift(xbt_dynar_t const dynar, void *const dst)
+void xbt_dynar_shift(xbt_dynar_t const dynar, void *const dst)
{
/* sanity checks done by remove_at */
xbt_dynar_remove_at(dynar, 0, dst);
*
* The mapped function may change the value of the element itself, but should not mess with the structure of the dynar.
*/
-inline void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op)
+void xbt_dynar_map(const xbt_dynar_t dynar, void_f_pvoid_t const op)
{
char *const data = (char *) dynar->data;
const unsigned long elmsize = dynar->elmsize;
*
* This function can be used while traversing without problem.
*/
-inline void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int *const cursor)
+void xbt_dynar_cursor_rm(xbt_dynar_t dynar, unsigned int *const cursor)
{
xbt_dynar_remove_at(dynar, (*cursor)--, NULL);
}
* \param dynar the dynar to sort
* \param compar_fn comparison function of type (int (compar_fn*) (const void*) (const void*)).
*/
-inline void xbt_dynar_sort(xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
+void xbt_dynar_sort(xbt_dynar_t dynar, int_f_cpvoid_cpvoid_t compar_fn)
{
qsort(dynar->data, dynar->used, dynar->elmsize, compar_fn);
}
*
* Note: The dynar won't be usable afterwards.
*/
-inline void *xbt_dynar_to_array(xbt_dynar_t dynar)
+void *xbt_dynar_to_array(xbt_dynar_t dynar)
{
void *res;
xbt_dynar_shrink(dynar, 1);
/* 2. Traverse manually the dynar */
for (cursor = 0; cursor < NB_ELEM; cursor++) {
- iptr = xbt_dynar_get_ptr(d, cursor);
- xbt_test_assert(cursor == *iptr, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
+ iptr = (int*) xbt_dynar_get_ptr(d, cursor);
+ xbt_test_assert(cursor == (unsigned int) *iptr, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
}
/* 3. Traverse the dynar using the neat macro to that extend */
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert(cursor == cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
+ xbt_test_assert(cursor == (unsigned int) cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
}
/* end_of_traversal */
/* 3. Traverse the dynar */
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert(cursor == cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
+ xbt_test_assert(cursor == (unsigned int) cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
}
/* end_of_traversal */
for (cpt = 0; cpt < NB_ELEM; cpt++)
xbt_dynar_set_as(d, cpt, int, cpt);
xbt_dynar_foreach(d, cursor, cpt)
- xbt_test_assert(cursor == cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
+ xbt_test_assert(cursor == (unsigned int) cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
for (cpt = 0; cpt < NB_ELEM; cpt++) {
int val;
/* 3. Traverse the dynar */
xbt_dynar_foreach(d, cursor, cpt) {
- xbt_test_assert(cursor == cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
+ xbt_test_assert(cursor == (unsigned) cpt, "The retrieved value is not the same than the injected one (%u!=%d)", cursor, cpt);
}
/* end_of_traversal */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ex, xbt, "Exception mechanism");
-XBT_EXPORT_NO_IMPORT(const xbt_running_ctx_t) __xbt_ex_ctx_initializer = XBT_RUNNING_CTX_INITIALIZER;
-
-/* default __ex_ctx callback function */
-xbt_running_ctx_t *__xbt_ex_ctx_default(void)
-{
- /* Don't scream: this is a default which is never used (so, yes,
- there is one setjump container by running entity).
-
- This default gets overriden in xbt/xbt_os_thread.c so that it works in
- real life and in simulation when using threads to implement the simulation
- processes (ie, with pthreads and on windows).
-
- It also gets overriden in xbt/context.c when using ucontexts (as well as
- in Java for now, but after the java overhaul, it will get cleaned out)
- */
- static xbt_running_ctx_t ctx = XBT_RUNNING_CTX_INITIALIZER;
-
- return &ctx;
-}
+xbt_ex::~xbt_ex() {}
/* Change raw libc symbols to file names and line numbers */
void xbt_ex_setup_backtrace(xbt_ex_t * e);
void xbt_backtrace_display(xbt_ex_t * e)
{
+ // TODO, backtrace
+#if 0
xbt_ex_setup_backtrace(e);
#ifdef HAVE_BACKTRACE
- if (e->used == 0) {
+ if (e->bt_strings.empty()) {
fprintf(stderr, "(backtrace not set)\n");
} else {
fprintf(stderr, "Backtrace (displayed in process %s):\n", SIMIX_process_self_get_name());
- for (int i = 1; i < e->used; i++) /* no need to display "xbt_backtrace_display" */
- fprintf(stderr, "---> %s\n", e->bt_strings[i] + 4);
+ for (std::string const& s : e->bt_strings) /* no need to display "xbt_backtrace_display" */
+ fprintf(stderr, "---> %s\n", s.c_str() + 4);
}
-
- /* don't fool xbt_ex_free with uninitialized msg field */
- e->msg = NULL;
xbt_ex_free(*e);
#else
XBT_ERROR("No backtrace on this arch");
#endif
+ #endif
}
/** \brief show the backtrace of the current point (lovely while debuging) */
# include "src/xbt/backtrace_dummy.c"
#endif
+void xbt_throw(
+ char* message, xbt_errcat_t errcat, int value,
+ const char* file, int line, const char* func)
+{
+ xbt_ex e(message);
+ free(message);
+ e.category = errcat;
+ e.value = value;
+ e.file = file;
+ e.line = line;
+ e.func = func;
+ e.procname = xbt_procname();
+ e.pid = xbt_getpid();
+ throw e;
+}
+
/** @brief shows an exception content and the associated stack if available */
void xbt_ex_display(xbt_ex_t * e)
{
fprintf(stderr, "** SimGrid: UNCAUGHT EXCEPTION received on %s(%d): category: %s; value: %d\n"
"** %s\n"
"** Thrown by %s()%s\n",
- xbt_binary_name, xbt_getpid(), xbt_ex_catname(e->category), e->value, e->msg,
- e->procname, thrower ? thrower : " in this process");
- XBT_CRITICAL("%s", e->msg);
+ xbt_binary_name, xbt_getpid(), xbt_ex_catname(e->category), e->value, e->what(),
+ e->procname.c_str(), thrower ? thrower : " in this process");
+ XBT_CRITICAL("%s", e->what());
xbt_free(thrower);
if (xbt_initialized==0 || smx_cleaned) {
return; /* Not started yet or already closing. Trying to generate a backtrace would probably fail */
}
- if (!e->bt_strings)
+ if (e->bt_strings.empty())
xbt_ex_setup_backtrace(e);
#ifdef HAVE_BACKTRACE
- if (e->used && e->bt_strings) {
+ if (!e->bt.empty() && !e->bt_strings.empty()) {
/* We have everything to build neat backtraces */
- int i;
int cutpath = 0;
- TRY { // We don't want to have an exception while checking how to deal with the one we already have, do we?
+ try { // We don't want to have an exception while checking how to deal with the one we already have, do we?
cutpath = xbt_cfg_get_boolean("exception/cutpath");
- } CATCH_ANONYMOUS { }
+ }
+ catch(xbt_ex& e) {
+ // Nothing to do
+ }
fprintf(stderr, "\n");
- for (i = 0; i < e->used; i++) {
-
+ for (std::string const& s : e->bt_strings) {
+
if (cutpath) {
+ // TODO, backtrace
+ /*
char* p = e->bt_strings[i];
xbt_str_rtrim(p, ":0123456789");
char* filename = strrchr(p, '/')+1;
fprintf(stderr, "%s %s\n", dest, filename);
free(dest);
+ */
}
else {
- fprintf(stderr, "%s\n", e->bt_strings[i]);
+ fprintf(stderr, "%s\n", s.c_str());
}
}
} else
"** (no backtrace available)\n", e->func, e->file, e->line);
}
-/* default __ex_terminate callback function */
-void __xbt_ex_terminate_default(xbt_ex_t * e)
-{
- xbt_ex_display(e);
- xbt_abort();
-}
-
-/* the externally visible API */
-XBT_EXPORT_NO_IMPORT(xbt_running_ctx_fetcher_t) __xbt_running_ctx_fetch = &__xbt_ex_ctx_default;
-XBT_EXPORT_NO_IMPORT(ex_term_cb_t) __xbt_ex_terminate = &__xbt_ex_terminate_default;
-
-void xbt_ex_free(xbt_ex_t e)
-{
- free(e.msg);
-
- if (e.bt_strings) {
- for (int i = 0; i < e.used; i++)
- free(e.bt_strings[i]);
- free(e.bt_strings);
- }
-}
-
/** \brief returns a short name for the given exception category */
const char *xbt_ex_catname(xbt_errcat_t cat)
{
XBT_TEST_UNIT("controlflow", test_controlflow, "basic nested control flow")
{
xbt_ex_t ex;
- volatile int n = 1;
+ int n = 1;
xbt_test_add("basic nested control flow");
- TRY {
+ try {
if (n != 1)
xbt_test_fail("M1: n=%d (!= 1)", n);
n++;
- TRY {
+ try {
if (n != 2)
xbt_test_fail("M2: n=%d (!= 2)", n);
n++;
THROWF(unknown_error, 0, "something");
- } CATCH(ex) {
+ }
+ catch (xbt_ex& ex) {
if (n != 3)
xbt_test_fail("M3: n=%d (!= 3)", n);
n++;
- xbt_ex_free(ex);
}
n++;
- TRY {
+ try {
if (n != 5)
xbt_test_fail("M2: n=%d (!= 5)", n);
n++;
THROWF(unknown_error, 0, "something");
- } CATCH_ANONYMOUS {
+ }
+ catch(xbt_ex& ex){
if (n != 6)
xbt_test_fail("M3: n=%d (!= 6)", n);
n++;
- RETHROW;
+ throw;
n++;
}
xbt_test_fail("MX: n=%d (shouldn't reach this point)", n);
- } CATCH(ex) {
+ }
+ catch(xbt_ex& e) {
if (n != 7)
xbt_test_fail("M4: n=%d (!= 7)", n);
n++;
- xbt_ex_free(ex);
}
if (n != 8)
xbt_test_fail("M5: n=%d (!= 8)", n);
XBT_TEST_UNIT("value", test_value, "exception value passing")
{
- xbt_ex_t ex;
-
- TRY {
+ try {
THROWF(unknown_error, 2, "toto");
- } CATCH(ex) {
+ }
+ catch (xbt_ex& ex) {
xbt_test_add("exception value passing");
if (ex.category != unknown_error)
xbt_test_fail("category=%d (!= 1)", (int)ex.category);
if (ex.value != 2)
xbt_test_fail("value=%d (!= 2)", ex.value);
- if (strcmp(ex.msg, "toto"))
- xbt_test_fail("message=%s (!= toto)", ex.msg);
- xbt_ex_free(ex);
+ if (strcmp(ex.what(), "toto"))
+ xbt_test_fail("message=%s (!= toto)", ex.what());
}
}
int r1;
int XBT_ATTRIB_UNUSED r2;
int v1;
- volatile int v2;
+ int v2;
r1 = r2 = v1 = v2 = 1234;
- TRY {
+ try {
r2 = 5678;
v2 = 5678;
THROWF(unknown_error, 0, "toto");
- } CATCH(ex) {
+ }
+ catch(xbt_ex& e) {
xbt_test_add("variable preservation");
if (r1 != 1234)
xbt_test_fail("r1=%d (!= 1234)", r1);
/* r2 is allowed to be destroyed because not volatile */
if (v2 != 5678)
xbt_test_fail("v2=%d (!= 5678)", v2);
- xbt_ex_free(ex);
}
}
XBT_TEST_UNIT("cleanup", test_cleanup, "cleanup handling")
{
- xbt_ex_t ex;
- volatile int v1;
+ int v1;
int c;
xbt_test_add("cleanup handling");
v1 = 1234;
c = 0;
- TRY {
+ try {
v1 = 5678;
THROWF(1, 2, "blah");
}
- TRY_CLEANUP {
+ catch (xbt_ex& ex) {
if (v1 != 5678)
xbt_test_fail("v1 = %d (!= 5678)", v1);
c = 1;
- } CATCH(ex) {
if (v1 != 5678)
xbt_test_fail("v1 = %d (!= 5678)", v1);
- if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.msg, "blah")))
+ if (!(ex.category == 1 && ex.value == 2 && !strcmp(ex.what(), "blah")))
xbt_test_fail("unexpected exception contents");
- xbt_ex_free(ex);
}
if (!c)
xbt_test_fail("xbt_ex_free not executed");
}
-
-/*
- * The following is the example included in the documentation. It's a good
- * idea to check its syntax even if we don't try to run it.
- * And actually, it allows to put comments in the code despite doxygen.
- */
-static char *mallocex(int size)
-{
- return NULL;
-}
-
-#define SMALLAMOUNT 10
-#define TOOBIG 100000000
-
-typedef struct {
- char *first;
-} global_context_t;
-
-static void good_example(void)
-{
- global_context_t *global_context = xbt_malloc(sizeof(global_context_t));
-
- /* GOOD_EXAMPLE */
- { /*01 */
- char *volatile /*03 */ cp1 = NULL /*02 */ ;
- char *volatile /*03 */ cp2 = NULL /*02 */ ;
- char *volatile /*03 */ cp3 = NULL /*02 */ ;
- TRY {
- cp1 = mallocex(SMALLAMOUNT);
- global_context->first = cp1;
- cp1 = NULL /*05 give away */ ;
- cp2 = mallocex(TOOBIG);
- cp3 = mallocex(SMALLAMOUNT);
- strncpy(cp1, "foo",3);
- strncpy(cp2, "bar",3);
- }
- TRY_CLEANUP { /*04 */
- printf("cp3=%s", cp3 == NULL /*02 */ ? "" : cp3);
- free(cp3);
- free(cp2);
- /*05 cp1 was given away */
- }
- CATCH_ANONYMOUS {
- /*05 global context untouched */
- RETHROW;
- }
- }
- /* end_of_good_example */
-}
#endif /* SIMGRID_TEST */
break;
case 'b': /* backtrace; called %throwable in LOG4J */
case 'B': /* short backtrace; called %throwable{short} in LOG4J */
-#if HAVE_BACKTRACE && HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE)
+// TODO, backtrace
+#if 0 && HAVE_BACKTRACE && HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE)
{
- xbt_ex_t e;
+ xbt_ex_t e("");
e.used = backtrace((void **) e.bt, XBT_BACKTRACE_SIZE);
e.bt_strings = NULL;
- e.msg = NULL;
xbt_ex_setup_backtrace(&e);
if (*q == 'B') {
show_string(e.bt_strings[1] + 8);
show_string(buff->data);
xbt_strbuff_free(buff);
}
- xbt_ex_free(e);
}
#else
show_string("(no backtrace on this arch)");
char *name;
void *param;
pvoid_f_pvoid_t start_routine;
- xbt_running_ctx_t *running_ctx;
void *extra_data;
} s_xbt_os_thread_t;
static xbt_os_thread_t main_thread = NULL;
{
if (thread == main_thread) /* just killed main thread */
main_thread = NULL;
-
- free(thread->running_ctx);
free(thread->name);
free(thread);
}
-/* callback: context fetching */
-static xbt_running_ctx_t *_os_thread_get_running_ctx(void)
-{
- return xbt_os_thread_self()->running_ctx;
-}
-
/* callback: termination */
static void _os_thread_ex_terminate(xbt_ex_t * e)
{
main_thread->name = (char *) "main";
main_thread->param = NULL;
main_thread->start_routine = NULL;
- main_thread->running_ctx = xbt_new(xbt_running_ctx_t, 1);
main_thread->extra_data = NULL;
- XBT_RUNNING_CTX_INITIALIZE(main_thread->running_ctx);
if ((errcode = pthread_setspecific(xbt_self_thread_key, main_thread)))
THROWF(system_error, errcode,
"Impossible to set the SimGrid identity descriptor to the main thread (pthread_setspecific failed)");
- __xbt_running_ctx_fetch = _os_thread_get_running_ctx;
- __xbt_ex_terminate = _os_thread_ex_terminate;
-
pthread_attr_init(&thread_attr);
thread_mod_inited = 1;
// if ((errcode=pthread_key_delete(xbt_self_thread_key)))
// THROWF(system_error,errcode,"pthread_key_delete failed for xbt_self_thread_key");
- free(main_thread->running_ctx);
free(main_thread);
main_thread = NULL;
thread_mod_inited = 0;
#if !HAVE_SEM_INIT
xbt_os_mutex_destroy(next_sem_ID_lock);
#endif
-
- /* Restore the default exception setup */
- __xbt_running_ctx_fetch = &__xbt_ex_ctx_default;
- __xbt_ex_terminate = &__xbt_ex_terminate_default;
}
/** Calls pthread_atfork() if present, and raise an exception otherwise.
res_thread->name = xbt_strdup(name);
res_thread->start_routine = start_routine;
res_thread->param = param;
- res_thread->running_ctx = xbt_new(xbt_running_ctx_t, 1);
- XBT_RUNNING_CTX_INITIALIZE(res_thread->running_ctx);
res_thread->extra_data = extra_data;
int errcode = pthread_create(&(res_thread->t), &thread_attr, wrapper_start_routine, res_thread);
xbt_dynar_free(&d);
return xbt_replay_reader_get(reader); /* Get next line */
}
- return xbt_dynar_to_array(d);
+ return (const char**) xbt_dynar_to_array(d);
}
void xbt_replay_reader_free(xbt_replay_reader_t *reader)
void xbt_replay_action_register(const char *action_name, action_fun function)
{
char* lowername = str_tolower (action_name);
- xbt_dict_set(xbt_action_funs, lowername, function, NULL);
+ xbt_dict_set(xbt_action_funs, lowername, (void*) function, NULL);
xbt_free(lowername);
}
int xbt_replay_action_runner(int argc, char *argv[])
{
int i;
- xbt_ex_t e;
if (xbt_action_fp) { // A unique trace file
char **evt;
while ((evt = action_get_action(argv[0]))) {
char* lowername = str_tolower (evt[1]);
action_fun function = (action_fun)xbt_dict_get(xbt_action_funs, lowername);
xbt_free(lowername);
- TRY{
+ try {
function((const char **)evt);
- } CATCH(e) {
- free(evt);
- xbt_die("Replay error :\n %s", e.msg);
+ }
+ catch(xbt_ex& e) {
+ xbt_die("Replay error :\n %s", e.what());
}
for (i=0;evt[i]!= NULL;i++)
free(evt[i]);
char* lowername = str_tolower (evt[1]);
action_fun function = (action_fun)xbt_dict_get(xbt_action_funs, lowername);
xbt_free(lowername);
- TRY{
+ try {
function(evt);
- } CATCH(e) {
+ } catch(xbt_ex& e) {
free(evt);
- xbt_die("Replay error on line %d of file %s :\n %s" , reader->linenum,reader->filename, e.msg);
+ xbt_die("Replay error on line %d of file %s :\n %s" , reader->linenum,reader->filename, e.what());
}
} else {
XBT_WARN("%s:%d: Ignore trace element not for me", reader->filename, reader->linenum);
xbt_dynar_t evt = NULL;
char *evtname = NULL;
- xbt_dynar_t myqueue = xbt_dict_get_or_null(xbt_action_queues, name);
+ xbt_dynar_t myqueue = (xbt_dynar_t) xbt_dict_get_or_null(xbt_action_queues, name);
if (myqueue == NULL || xbt_dynar_is_empty(myqueue)) { // nothing stored for me. Read the file further
if (xbt_action_fp == NULL) { // File closed now. There's nothing more to read. I'm out of here
goto todo_done;
// if it's for me, I'm done
evtname = xbt_dynar_get_as(evt, 0, char *);
if (!strcasecmp(name, evtname)) {
- return xbt_dynar_to_array(evt);
+ return (char**) xbt_dynar_to_array(evt);
} else {
// Else, I have to store it for the relevant colleague
xbt_dynar_t otherqueue =
- xbt_dict_get_or_null(xbt_action_queues, evtname);
+ (xbt_dynar_t) xbt_dict_get_or_null(xbt_action_queues, evtname);
if (otherqueue == NULL) { // Damn. Create the queue of that guy
otherqueue = xbt_dynar_new(sizeof(xbt_dynar_t), xbt_dynar_free_voidp);
xbt_dict_set(xbt_action_queues, evtname, otherqueue, NULL);
} else {
// Get something from my queue and return it
xbt_dynar_shift(myqueue, &evt);
- return xbt_dynar_to_array(evt);
+ return (char**) xbt_dynar_to_array(evt);
}
// I did all my actions for me in the file (either I closed the file, or a colleague did)
-/* xbt_str.c - various helping functions to deal with strings */
+/* xbt_str.cpp - various helping functions to deal with strings */
/* Copyright (c) 2007-2014. The SimGrid Team.
* All rights reserved. */
if (*q == '\0')
done = 1;
- topush = xbt_malloc(q - p + 1);
+ topush = (char*) xbt_malloc(q - p + 1);
memcpy(topush, p, q - p);
topush[q - p] = '\0';
xbt_dynar_push(res, &topush);
//if substring was not found add the entire string
if (NULL == q) {
v = strlen(p);
- to_push = xbt_malloc(v + 1);
+ to_push = (char*) xbt_malloc(v + 1);
memcpy(to_push, p, v);
to_push[v] = '\0';
xbt_dynar_push(res, &to_push);
done = 1;
} else {
//get the appearance
- to_push = xbt_malloc(q - p + 1);
+ to_push = (char*) xbt_malloc(q - p + 1);
memcpy(to_push, p, q - p);
//add string terminator
to_push[q - p] = '\0';
}
len += strlen(sep) * dyn_len;
/* Do the job */
- res = xbt_malloc(len);
+ res = (char*) xbt_malloc(len);
p = res;
xbt_dynar_foreach(dyn, cpt, cursor) {
if ((int) cpt < dyn_len - 1)
len += strlen(sep) * amount_strings;
/* Do the job */
- q = res = xbt_malloc(len);
+ q = res = (char*) xbt_malloc(len);
for (i=0;strs[i];i++) {
if (i!=0) { // not first loop
q += snprintf(q,len, "%s%s", sep, strs[i]);
#define test_parse_error(function, name, variable, str) \
do { \
xbt_test_add(name); \
- TRY { \
+ try { \
variable = function(str, "Parse error"); \
xbt_test_fail("The test '%s' did not detect the problem",name ); \
- } CATCH(e) { \
+ } catch(xbt_ex& e) { \
if (e.category != arg_error) { \
xbt_test_exception(e); \
- } else { \
- xbt_ex_free(e); \
} \
} \
} while (0)
#define test_parse_ok(function, name, variable, str, value) \
do { \
xbt_test_add(name); \
- TRY { \
+ try { \
variable = function(str, "Parse error"); \
- } CATCH(e) { \
+ } catch(xbt_ex& e) { \
xbt_test_exception(e); \
} \
xbt_test_assert(variable == value, "Fail to parse '%s'", str); \
XBT_TEST_UNIT("xbt_str_parse", test_parse, "Test the parsing functions")
{
- xbt_ex_t e;
int rint = -9999;
test_parse_ok(xbt_str_parse_int, "Parse int", rint, "42", 42);
test_parse_ok(xbt_str_parse_int, "Parse 0 as an int", rint, "0", 0);
-foreach(x concurrent_rw get_sender host_on_off host_on_off_processes host_on_off_recv host_on_off_wait listen_async pid
- process process_join storage_client_server task_destroy_cancel trace_integration)
+foreach(x concurrent_rw get_sender host_on_off host_on_off_recv host_on_off_processes host_on_off_wait listen_async pid
+ process process_join storage_client_server trace_integration)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
endforeach()
+foreach(x task_destroy_cancel)
+ add_executable (${x} ${x}/${x}.cpp)
+ target_link_libraries(${x} simgrid)
+ set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+
+ set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
+ set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
+endforeach()
+
set(teshsuite_src ${teshsuite_src} PARENT_SCOPE)
set(tesh_files ${tesh_files} PARENT_SCOPE)
set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1.0-hbp1.0-hbp1.0.xml
static int master(int argc, char *argv[])
{
- xbt_ex_t e;
- TRY {
- msg_host_t jupiter = MSG_host_by_name("Jupiter");
-
- XBT_INFO("Master starting");
- MSG_process_sleep(0.5);
-
- msg_comm_t comm = NULL;
- {
- msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL);
- comm = MSG_task_isend(task, mailbox);
- }
-
- MSG_process_sleep(0.5);
-
- XBT_INFO("Turning off the slave host");
- MSG_host_off(jupiter);
-
- if (comm) {
- MSG_comm_wait(comm, -1);
- MSG_comm_destroy(comm);
- }
- XBT_INFO("Master has finished");
+ msg_host_t jupiter = MSG_host_by_name("Jupiter");
+
+ XBT_INFO("Master starting");
+ MSG_process_sleep(0.5);
+
+ msg_comm_t comm = NULL;
+ {
+ msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL);
+ comm = MSG_task_isend(task, mailbox);
}
- CATCH(e) {
- xbt_die("Exception caught in the master");
- return 1;
+
+ MSG_process_sleep(0.5);
+
+ XBT_INFO("Turning off the slave host");
+ MSG_host_off(jupiter);
+
+ if (comm) {
+ MSG_comm_wait(comm, -1);
+ MSG_comm_destroy(comm);
}
+ XBT_INFO("Master has finished");
+
return 0;
}
static int slave(int argc, char *argv[])
{
- xbt_ex_t e;
- TRY {
- XBT_INFO("Slave receiving");
- msg_task_t task = NULL;
- msg_error_t error = MSG_task_receive(&(task), mailbox);
- if (error) {
- XBT_ERROR("Error while receiving message");
- return 1;
- }
-
- XBT_ERROR("Slave should be off already.");
- return 1;
- }
- CATCH(e) {
- XBT_ERROR("Exception caught in the slave");
+ XBT_INFO("Slave receiving");
+ msg_task_t task = NULL;
+ msg_error_t error = MSG_task_receive(&(task), mailbox);
+ if (error) {
+ XBT_ERROR("Error while receiving message");
return 1;
}
- return 0;
+
+ XBT_ERROR("Slave should be off already.");
+ return 1;
}
int main(int argc, char *argv[])
static int master(int argc, char *argv[])
{
- xbt_ex_t e;
- TRY {
- msg_host_t jupiter = MSG_host_by_name("Jupiter");
- XBT_INFO("Master waiting");
- MSG_process_sleep(1);
+ msg_host_t jupiter = MSG_host_by_name("Jupiter");
+ XBT_INFO("Master waiting");
+ MSG_process_sleep(1);
+
+ XBT_INFO("Turning off the slave host");
+ MSG_host_off(jupiter);
+ XBT_INFO("Master has finished");
- XBT_INFO("Turning off the slave host");
- MSG_host_off(jupiter);
- XBT_INFO("Master has finished");
- }
- CATCH(e) {
- xbt_die("Exception caught in the master");
- return 1;
- }
return 0;
}
static int slave(int argc, char *argv[])
{
- xbt_ex_t e;
- TRY {
- XBT_INFO("Slave waiting");
- // TODO, This should really be MSG_HOST_FAILURE
- MSG_process_sleep(5);
- XBT_ERROR("Slave should be off already.");
- return 1;
- }
- CATCH(e) {
- XBT_ERROR("Exception caught in the slave");
- return 1;
- }
- return 0;
+ XBT_INFO("Slave waiting");
+ // TODO, This should really be MSG_HOST_FAILURE
+ MSG_process_sleep(5);
+ XBT_ERROR("Slave should be off already.");
+ return 1;
}
int main(int argc, char *argv[])
double timeout = 1;
const char * mailbox = "jupi";
- xbt_ex_t ex;
msg_task_t task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL);
XBT_INFO("Sending task: \"%s\"", task->name);
msg_comm_t comm = MSG_task_isend(task, mailbox);
XBT_INFO("Canceling task \"%s\" during comm", task->name);
MSG_task_cancel(task);
- TRY {
+ try {
MSG_comm_wait(comm, -1);
}
- CATCH (ex) {
- xbt_ex_free(ex);
+ catch (xbt_ex& ex) {;
MSG_comm_destroy(comm);
}
MSG_task_destroy(task);
comm = MSG_task_isend(task, mailbox);
XBT_INFO("Destroying task \"%s\" during comm", task->name);
MSG_task_destroy(task);
- TRY {
+ try {
MSG_comm_wait(comm, -1);
}
- CATCH (ex) {
- xbt_ex_free(ex);
+ catch (xbt_ex& ex) {;
MSG_comm_destroy(comm);
}
static int worker_main(int argc, char *argv[])
{
- msg_task_t task = MSG_process_get_data(MSG_process_self());
+ msg_task_t task = (msg_task_t) MSG_process_get_data(MSG_process_self());
msg_error_t res;
XBT_INFO("Start %s", task->name);
res = MSG_task_execute(task);
static void create_environment(xbt_os_timer_t parse_time, const char *platformFile)
{
- xbt_ex_t e;
- TRY {
+ try {
xbt_os_cputimer_start(parse_time);
SD_create_environment(platformFile);
xbt_os_cputimer_stop(parse_time);
}
- CATCH(e) {
- xbt_die("Error while loading %s: %s", platformFile, e.msg);
+ catch (std::exception& e) {
+ xbt_die("Error while loading %s: %s", platformFile, e.what());
}
}
/* Should coordinate with the other processes - take the max? */
}
-volatile double delayCounter = 0;
+double delayCounter = 0;
void Delay( int count )
{
int i;
endforeach()
if(HAVE_MMALLOC)
- add_executable (mmalloc_test ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.c)
+ add_executable (mmalloc_test ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.cpp)
target_link_libraries(mmalloc_test simgrid)
set_target_properties(mmalloc_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mmalloc)
endif()
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/log_usage/log_usage_ndebug.tesh
${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_64.tesh
${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_32.tesh PARENT_SCOPE)
-set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.c PARENT_SCOPE)
+set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.cpp PARENT_SCOPE)
foreach(x heap_bench log_large parallel_log_crashtest parmap_test) #mallocator parmap_bench
ADD_TESH(tesh-xbt-${x} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/xbt/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/xbt/${x} ${x}.tesh)
int main(int argc, char**argv)
{
- void *heapA;
+ xbt_mheap_t heapA = nullptr;
void *pointers[TESTSIZE];
xbt_init(&argc,argv);
}
XBT_INFO("All blocks were correctly allocated. Free every second block");
for (i = 0; i < TESTSIZE; i+=2) {
- mfree(heapA,pointers[i]);
+ mfree(heapA, pointers[i]);
}
XBT_INFO("Memset every second block to zero (yeah, they are not currently allocated :)");
for (i = 0; i < TESTSIZE; i+=2) {
XBT_INFO("free all blocks (each one twice, to check that double free are correctly catched)");
for (i = 0; i < TESTSIZE; i++) {
- xbt_ex_t e;
- int gotit = 1;
-
+ bool gotit = false;
mfree(heapA, pointers[i]);
- TRY {
+ try {
mfree(heapA, pointers[i]);
- gotit = 0;
- } CATCH(e) {
- xbt_ex_free(e);
+ } catch(xbt_ex& e) {
+ gotit = true;
}
if (!gotit)
xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
XBT_INFO("free again all blocks (to really check that double free are correctly catched)");
for (i = 0; i < TESTSIZE; i++) {
- xbt_ex_t e;
- int gotit = 1;
-
- TRY {
+ bool gotit = false;
+ try {
mfree(heapA, pointers[i]);
- gotit = 0;
- } CATCH(e) {
- xbt_ex_free(e);
+ } catch(xbt_ex& e) {
+ gotit = true;
}
if (!gotit)
xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i));
src/smpi/colls/reduce-rab.c
src/smpi/colls/scatter-ompi.c
src/smpi/colls/scatter-mvapich-two-level.c
- src/smpi/colls/smpi_automatic_selector.c
+ src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/colls/smpi_mpich_selector.c
src/smpi/colls/smpi_intel_mpi_selector.c
src/smpi/colls/smpi_openmpi_selector.c
src/xbt/automaton/automaton.c
src/xbt/automaton/automatonparse_promela.c
src/xbt/config.cpp
- src/xbt/cunit.c
- src/xbt/dict.c
+ src/xbt/cunit.cpp
+ src/xbt/dict.cpp
src/xbt/dict_cursor.c
src/xbt/dict_elm.c
- src/xbt/dynar.c
- src/xbt/ex.c
+ src/xbt/dynar.cpp
+ src/xbt/ex.cpp
src/xbt/fifo.c
src/xbt/graph.c
src/xbt/heap.c
src/xbt/xbt_os_file.c
src/xbt/xbt_os_synchro.c
src/xbt/xbt_os_time.c
- src/xbt/xbt_replay.c
- src/xbt/xbt_str.c
+ src/xbt/xbt_replay.cpp
+ src/xbt/xbt_str.cpp
src/xbt/xbt_strbuff.c
src/xbt/xbt_virtu.c
src/xbt_modinter.h
src/xbt/mmalloc/mm.c
src/xbt/log.c src/xbt/xbt_log_appender_file.c
src/xbt/xbt_log_layout_format.c src/xbt/xbt_log_layout_simple.c
- src/xbt/dict.c src/xbt/dict_elm.c src/xbt/dict_cursor.c
- src/xbt/dynar.c src/xbt/fifo.c src/xbt/heap.c src/xbt/swag.c
+ src/xbt/dict.cpp src/xbt/dict_elm.c src/xbt/dict_cursor.c
+ src/xbt/dynar.cpp src/xbt/fifo.c src/xbt/heap.c src/xbt/swag.c
src/xbt/str.c src/xbt/strbuff.c src/xbt/snprintf.c
src/xbt/queue.c
src/xbt/xbt_os_time.c src/xbt/xbt_os_thread.c
# FILES_CONTAINING_UNITTESTS and have a pleasant day.
set(FILES_CONTAINING_UNITTESTS
- src/xbt/cunit.c
- src/xbt/ex.c
- src/xbt/dynar.c
- src/xbt/dict.c
+ src/xbt/cunit.cpp
+ src/xbt/ex.cpp
+ src/xbt/dynar.cpp
+ src/xbt/dict.cpp
src/xbt/swag.c
- src/xbt/xbt_str.c
+ src/xbt/xbt_str.cpp
src/xbt/xbt_strbuff.c
src/xbt/config.cpp
)
void (*fp) (void);
char *cp;
};
-static volatile char *handler_addr = (char *) 0xDEAD;
+static char *handler_addr = (char *) 0xDEAD;
static ucontext_t uc_handler;
static ucontext_t uc_main;
void handler(void)