#define MSG_init(argc, argv) \
do { \
sg_version_check(SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH); \
- MSG_init_nocheck(argc, argv); \
+ MSG_init_nocheck((argc), (argv)); \
} while (0)
XBT_PUBLIC void MSG_init_nocheck(int* argc, char** argv);
XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
XBT_PUBLIC msg_error_t MSG_task_receive(msg_task_t* task, const char* alias);
-#define MSG_task_recv(t,a) MSG_task_receive(t,a)
+#define MSG_task_recv(t, a) MSG_task_receive((t), (a))
XBT_PUBLIC msg_error_t MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, double timeout,
msg_host_t host, double rate);
XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* alias, double timeout,
double rate);
XBT_PUBLIC msg_error_t MSG_task_receive_bounded(msg_task_t* task, const char* alias, double rate);
-#define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
+#define MSG_task_recv_bounded(t, a, r) MSG_task_receive_bounded((t), (a), (r))
XBT_PUBLIC msg_comm_t MSG_task_isend(msg_task_t task, const char* alias);
XBT_PUBLIC msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char* alias, double maxrate);
#define MSG_host_energy_plugin_init() sg_host_energy_plugin_init()
#define MSG_host_get_consumed_energy(host) sg_host_get_consumed_energy(host)
-#define MSG_host_get_wattmin_at(host,pstate) sg_host_get_wattmin_at(host,pstate)
-#define MSG_host_get_wattmax_at(host,pstate) sg_host_get_wattmax_at(host,pstate)
+#define MSG_host_get_wattmin_at(host, pstate) sg_host_get_wattmin_at((host), (pstate))
+#define MSG_host_get_wattmax_at(host, pstate) sg_host_get_wattmax_at((host), (pstate))
#define MSG_host_get_current_consumption(host) sg_host_get_current_consumption(host)
SG_END_DECL()
XBT_PUBLIC xbt_dict_t sg_host_get_storage_content(sg_host_t host);
-#define MSG_file_open(fullpath, data) sg_file_open(fullpath, data)
-#define MSG_file_read(fd, size) sg_file_read(fd, size)
-#define MSG_file_write(fd, size) sg_file_write(fd, size)
+#define MSG_file_open(fullpath, data) sg_file_open((fullpath), (data))
+#define MSG_file_read(fd, size) sg_file_read((fd), (size))
+#define MSG_file_write(fd, size) sg_file_write((fd), (size))
#define MSG_file_close(fd) sg_file_close(fd)
#define MSG_file_get_name(fd) sg_file_get_name(fd)
#define MSG_file_get_size(fd) sg_file_get_size(fd)
#define MSG_file_dump(fd) sg_file_dump(fd)
#define MSG_file_get_data(fd) sg_file_get_data(fd)
-#define MSG_file_set_data(fd, data) sg_file_set_data(fd, data)
-#define MSG_file_seek(fd, offset, origin) sg_file_seek(fd, offset, origin)
+#define MSG_file_set_data(fd, data) sg_file_set_data((fd), (data))
+#define MSG_file_seek(fd, offset, origin) sg_file_seek((fd), (offset), (origin))
#define MSG_file_tell(fd) sg_file_tell(fd)
-#define MSG_file_move(fd, fullpath) sg_file_get_size(fd, fullpath)
+#define MSG_file_move(fd, fullpath) sg_file_get_size((fd), (fullpath))
#define MSG_file_unlink(fd) sg_file_unlink(fd)
-#define MSG_file_rcopy(file, host, fullpath) sg_file_rcopy(file, host, fullpath)
-#define MSG_file_rmove(file, host, fullpath) sg_file_rmove(file, host, fullpath)
+#define MSG_file_rcopy(file, host, fullpath) sg_file_rcopy((file), (host), (fullpath))
+#define MSG_file_rmove(file, host, fullpath) sg_file_rmove((file), (host), (fullpath))
#define MSG_storage_file_system_init() sg_storage_file_system_init()
#define MSG_storage_get_free_size(st) sg_storage_get_size_free(st)
#define MSG_vm_live_migration_plugin_init() sg_vm_live_migration_plugin_init()
#define MSG_vm_create_migratable(pm, name, coreAmount, ramsize, mig_netspeed, dp_intensity) \
- sg_vm_create_migratable(pm, name, coreAmount, ramsize, mig_netspeed, dp_intensity)
+ sg_vm_create_migratable((pm), (name), (coreAmount), (ramsize), (mig_netspeed), (dp_intensity))
#define MSG_vm_is_migrating(vm) sg_vm_is_migrating(vm)
-#define MSG_vm_migrate(vm, dst_pm) sg_vm_migrate(vm, dst_pm)
+#define MSG_vm_migrate(vm, dst_pm) sg_vm_migrate((vm), (dst_pm))
SG_END_DECL()
#define SD_init(argc, argv) \
do { \
sg_version_check(SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH); \
- SD_init_nocheck(argc, argv); \
+ SD_init_nocheck((argc), (argv)); \
} while (0)
XBT_PUBLIC void SD_init_nocheck(int* argc, char** argv);
#define CHECK_ACTION_PARAMS(action, mandatory, optional) \
{ \
- if (action.size() < static_cast<unsigned long>(mandatory + 2)) { \
+ if ((action).size() < static_cast<unsigned long>((mandatory) + 2)) { \
std::stringstream ss; \
ss << __func__ << " replay failed.\n" \
- << action.size() << " items were given on the line. First two should be process_id and action. " \
- << "This action needs after them " << mandatory << " mandatory arguments, and accepts " << optional \
+ << (action).size() << " items were given on the line. First two should be process_id and action. " \
+ << "This action needs after them " << (mandatory) << " mandatory arguments, and accepts " << (optional) \
<< " optional ones. \n" \
<< "The full line that was given is:\n "; \
- for (const auto& elem : action) { \
+ for (const auto& elem : (action)) { \
ss << elem << " "; \
} \
ss << "\nPlease contact the Simgrid team if support is needed"; \
#ifndef HAVE_SMPI
// Internally disable these overrides (HAVE_SMPI is only defined when building the library)
#define malloc(nbytes) _sampi_malloc(nbytes)
-#define calloc(n_elm,elm_size) _sampi_calloc(n_elm,elm_size)
-#define realloc(ptr,nbytes) _sampi_realloc(ptr,nbytes)
+#define calloc(n_elm, elm_size) _sampi_calloc((n_elm), (elm_size))
+#define realloc(ptr, nbytes) _sampi_realloc((ptr), (nbytes))
#define free(ptr) _sampi_free(ptr)
#endif
#define SMPI_ITER_NAME1(line) _XBT_CONCAT(iter_count, line)
#define SMPI_ITER_NAME(line) SMPI_ITER_NAME1(line)
-#define SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, global, iters, thres)\
- int SMPI_ITER_NAME(__LINE__)=0;\
- {loop_init;\
- while(loop_end){\
- SMPI_ITER_NAME(__LINE__)++;\
- loop_iter;\
- }} \
- for(loop_init; \
- loop_end ? (smpi_sample_1(global, __FILE__, __LINE__, iters, thres), (smpi_sample_2(global, __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__)))) :\
- smpi_sample_exit(global, __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__));\
- smpi_sample_3(global, __FILE__, __LINE__),loop_iter)
-#define SMPI_SAMPLE_LOCAL(loop_init, loop_end, loop_iter, iters, thres) SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, 0, iters, thres)
-#define SMPI_SAMPLE_GLOBAL(loop_init, loop_end, loop_iter,iters, thres) SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, 1, iters, thres)
+#define SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, global, iters, thres) \
+ int SMPI_ITER_NAME(__LINE__) = 0; \
+ { \
+ loop_init; \
+ while (loop_end) { \
+ SMPI_ITER_NAME(__LINE__)++; \
+ (loop_iter); \
+ } \
+ } \
+ for (loop_init; (loop_end) ? (smpi_sample_1((global), __FILE__, __LINE__, (iters), (thres)), \
+ (smpi_sample_2((global), __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__)))) \
+ : smpi_sample_exit((global), __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__)); \
+ smpi_sample_3((global), __FILE__, __LINE__), (loop_iter))
+#define SMPI_SAMPLE_LOCAL(loop_init, loop_end, loop_iter, iters, thres) \
+ SMPI_SAMPLE_LOOP(loop_init, (loop_end), (loop_iter), 0, (iters), (thres))
+#define SMPI_SAMPLE_GLOBAL(loop_init, loop_end, loop_iter, iters, thres) \
+ SMPI_SAMPLE_LOOP(loop_init, (loop_end), (loop_iter), 1, (iters), (thres))
#define SMPI_SAMPLE_DELAY(duration) for(smpi_execute(duration); 0; )
#define SMPI_SAMPLE_FLOPS(flops) for(smpi_execute_flops(flops); 0; )
XBT_PUBLIC void* smpi_shared_malloc(size_t size, const char* file, int line);
-#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
+#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc((size), __FILE__, __LINE__)
XBT_PUBLIC void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int nb_shared_blocks);
#define SMPI_PARTIAL_SHARED_MALLOC(size, shared_block_offsets, nb_shared_blocks) \
- smpi_shared_malloc_partial(size, shared_block_offsets, nb_shared_blocks)
+ smpi_shared_malloc_partial((size), (shared_block_offsets), (nb_shared_blocks))
XBT_PUBLIC void smpi_shared_free(void* data);
#define SMPI_SHARED_FREE(data) smpi_shared_free(data)
XBT_PUBLIC void* smpi_shared_get_call(const char* func, const char* input);
XBT_PUBLIC void* smpi_shared_set_call(const char* func, const char* input, void* data);
#define SMPI_SHARED_CALL(func, input, ...) \
- (smpi_shared_known_call(_XBT_STRINGIFY(func), input) \
- ? smpi_shared_get_call(_XBT_STRINGIFY(func), input) \
- : smpi_shared_set_call(_XBT_STRINGIFY(func), input, (func(__VA_ARGS__))))
+ (smpi_shared_known_call(_XBT_STRINGIFY(func), (input)) \
+ ? smpi_shared_get_call(_XBT_STRINGIFY(func), (input)) \
+ : smpi_shared_set_call(_XBT_STRINGIFY(func), (input), ((func)(__VA_ARGS__))))
/* Fortran specific stuff */
#define sleep(x) smpi_sleep(x)
#define usleep(x) smpi_usleep(x)
-#define gettimeofday(x, y) smpi_gettimeofday(x, 0)
+#define gettimeofday(x, y) smpi_gettimeofday((x), 0)
#if _POSIX_TIMERS > 0
-#define nanosleep(x, y) smpi_nanosleep(x, y)
-#define clock_gettime(x, y) smpi_clock_gettime(x, y)
+#define nanosleep(x, y) smpi_nanosleep((x), (y))
+#define clock_gettime(x, y) smpi_clock_gettime((x), (y))
#endif
-#define getopt(x,y,z) smpi_getopt(x,y,z)
-#define getopt_long(x,y,z,a,b) smpi_getopt_long(x,y,z,a,b)
-#define getopt_long_only(x,y,z,a,b) smpi_getopt_long_only(x,y,z,a,b)
+#define getopt(x, y, z) smpi_getopt((x), (y), (z))
+#define getopt_long(x, y, z, a, b) smpi_getopt_long((x), (y), (z), (a), (b))
+#define getopt_long_only(x, y, z, a, b) smpi_getopt_long_only((x), (y), (z), (a), (b))
#endif
@hideinitializer */
#define xbt_assert(...) \
_XBT_IF_ONE_ARG(_xbt_assert_ARG1, _xbt_assert_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _xbt_assert_ARG1(cond) \
- _xbt_assert_ARGN(cond, "Assertion %s failed", #cond)
+#define _xbt_assert_ARG1(cond) _xbt_assert_ARGN((cond), "Assertion %s failed", #cond)
#define _xbt_assert_ARGN(cond, ...) \
do { \
if (!(cond)) { \
#ifdef __MINGW32__
# include <stdio.h>
-# define XBT_ATTRIB_PRINTF( format_idx, arg_idx ) \
- __attribute__((__format__ (__MINGW_PRINTF_FORMAT, format_idx, arg_idx)))
-# define XBT_ATTRIB_SCANF( format_idx, arg_idx ) \
- __attribute__((__MINGW_SCANF_FORMAT (__scanf__, format_idx, arg_idx)))
+#define XBT_ATTRIB_PRINTF(format_idx, arg_idx) \
+ __attribute__((__format__(__MINGW_PRINTF_FORMAT, (format_idx), (arg_idx))))
+#define XBT_ATTRIB_SCANF(format_idx, arg_idx) __attribute__((__MINGW_SCANF_FORMAT(__scanf__, (format_idx), (arg_idx))))
#else
-# define XBT_ATTRIB_PRINTF( format_idx, arg_idx ) \
- __attribute__((__format__ (__printf__, format_idx, arg_idx)))
-# define XBT_ATTRIB_SCANF( format_idx, arg_idx ) \
- __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
+#define XBT_ATTRIB_PRINTF(format_idx, arg_idx) __attribute__((__format__(__printf__, (format_idx), (arg_idx))))
+#define XBT_ATTRIB_SCANF(format_idx, arg_idx) __attribute__((__format__(__scanf__, (format_idx), (arg_idx))))
#endif
#if defined(__cplusplus)
}
@endcode
*/
-# define xbt_dict_foreach(dict,cursor,key,data) \
- for (cursor=NULL, xbt_dict_cursor_first((dict),&(cursor)) ; \
- xbt_dict_cursor_get_or_free(&(cursor),(char**)&(key),(void**)(&data));\
- xbt_dict_cursor_step(cursor) )
+#define xbt_dict_foreach(dict, cursor, key, data) \
+ for ((cursor) = NULL, xbt_dict_cursor_first((dict), &(cursor)); \
+ xbt_dict_cursor_get_or_free(&(cursor), (char**)&(key), (void**)&(data)); xbt_dict_cursor_step(cursor))
/** @} */
(*(type*)xbt_dynar_get_ptr((dynar),(idx)))
/** @brief Quick setting of scalar content
* @hideinitializer */
-# define xbt_dynar_set_as(dynar,idx,type,val) \
- (*(type*)xbt_dynar_set_at_ptr((dynar),(idx))) = val
- /** @brief Quick retrieval of scalar content
- * @hideinitializer */
+#define xbt_dynar_set_as(dynar, idx, type, val) (*(type*)xbt_dynar_set_at_ptr((dynar), (idx))) = (val)
+/** @brief Quick retrieval of scalar content
+ * @hideinitializer */
# define xbt_dynar_getlast_as(dynar,type) \
(*(type*)xbt_dynar_get_ptr((dynar),xbt_dynar_length(dynar)-1))
- /** @brief Quick retrieval of scalar content
- * @hideinitializer */
+/** @brief Quick retrieval of scalar content
+ * @hideinitializer */
# define xbt_dynar_getfirst_as(dynar,type) \
(*(type*)xbt_dynar_get_ptr((dynar),0))
- /** @brief Quick insertion of scalar content
- * @hideinitializer */
-# define xbt_dynar_insert_at_as(dynar,idx,type,value) \
- *(type*)xbt_dynar_insert_at_ptr(dynar,idx)=value
- /** @brief Quick insertion of scalar content
- * @hideinitializer */
-# define xbt_dynar_push_as(dynar,type,value) \
- *(type*)xbt_dynar_push_ptr(dynar)=value
- /** @brief Quick removal of scalar content
- * @hideinitializer */
+/** @brief Quick insertion of scalar content
+ * @hideinitializer */
+#define xbt_dynar_insert_at_as(dynar, idx, type, value) *(type*)xbt_dynar_insert_at_ptr((dynar), (idx)) = (value)
+/** @brief Quick insertion of scalar content
+ * @hideinitializer */
+#define xbt_dynar_push_as(dynar, type, value) *(type*)xbt_dynar_push_ptr(dynar) = (value)
+/** @brief Quick removal of scalar content
+ * @hideinitializer */
# define xbt_dynar_pop_as(dynar,type) \
(*(type*)xbt_dynar_pop_ptr(dynar))
* Note that underneath, that's a simple for loop with no real black magic involved. It's perfectly safe to interrupt
* a foreach with a break or a return statement.
*/
-#define xbt_dynar_foreach(_dynar,_cursor,_data) \
- for ( (_cursor) = 0 ; \
- _xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \
- (_cursor)++ )
+#define xbt_dynar_foreach(_dynar, _cursor, _data) \
+ for ((_cursor) = 0; _xbt_dynar_cursor_get((_dynar), (_cursor), &(_data)); (_cursor)++)
#ifndef __cplusplus
-#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
- for ((_cursor) = 0 ; \
- (_ptr = _cursor < _dynar->used ? xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
- (_cursor)++ )
+#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr) \
+ for ((_cursor) = 0; ((_ptr) = (_cursor) < (_dynar)->used ? xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL); \
+ (_cursor)++)
#else
-#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
- for ((_cursor) = 0 ; \
- (_ptr = _cursor < _dynar->used ? (decltype(_ptr)) xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
- (_cursor)++ )
+#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr) \
+ for ((_cursor) = 0; \
+ ((_ptr) = (_cursor) < (_dynar)->used ? (decltype(_ptr))xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL); \
+ (_cursor)++)
#endif
/** @} */
SG_END_DECL()
* @ingroup XBT_ex_c
* @hideinitializer
*/
-#define THROW(v) _xbt_throw(NULL, v, __FILE__, __LINE__, __func__)
+#define THROW(v) _xbt_throw(NULL, (v), __FILE__, __LINE__, __func__)
/** Builds and throws an exception with a printf-like formatted message
* @ingroup XBT_ex_c
* @hideinitializer
*/
-#define THROWF(v, ...) _xbt_throw(bprintf(__VA_ARGS__), v, __FILE__, __LINE__, __func__)
+#define THROWF(v, ...) _xbt_throw(bprintf(__VA_ARGS__), (v), __FILE__, __LINE__, __func__)
XBT_ATTRIB_NORETURN void xbt_throw_impossible(const char* file, int line, const char* func);
/** Throw an exception because something impossible happened
NULL /* firstChild */, \
NULL /* nextSibling */, \
_XBT_STRINGIFY(catName), \
- desc, \
+ (desc), \
0 /*initialized */, \
xbt_log_priority_uninitialized /* threshold */, \
1 /* isThreshInherited */, \
*
* Defines a new subcategory of the parent.
*/
-#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
- XBT_LOG_EXTERNAL_CATEGORY(parent); \
- XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc)
+#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \
+ XBT_LOG_EXTERNAL_CATEGORY(parent); \
+ XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, (desc))
/**
* @ingroup XBT_log
*
* Creates a new subcategory of the root category.
*/
-# define XBT_LOG_NEW_CATEGORY(catName,desc) \
- XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc)
+#define XBT_LOG_NEW_CATEGORY(catName, desc) XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, (desc))
/**
* @ingroup XBT_log
* Creates a new subcategory of the root category and makes it the default (used by macros that don't explicitly
* specify a category).
*/
-# define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc) \
- XBT_LOG_NEW_CATEGORY(cname,desc); \
- XBT_LOG_DEFAULT_CATEGORY(cname)
+#define XBT_LOG_NEW_DEFAULT_CATEGORY(cname, desc) \
+ XBT_LOG_NEW_CATEGORY(cname, (desc)); \
+ XBT_LOG_DEFAULT_CATEGORY(cname)
/**
* @ingroup XBT_log
* Creates a new subcategory of the parent category and makes it the default
* (used by macros that don't explicitly specify a category).
*/
-#define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
- XBT_LOG_NEW_SUBCATEGORY(cname, parent, desc); \
- XBT_LOG_DEFAULT_CATEGORY(cname)
+#define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
+ XBT_LOG_NEW_SUBCATEGORY(cname, parent, (desc)); \
+ XBT_LOG_DEFAULT_CATEGORY(cname)
/**
* @ingroup XBT_log
* If you have expensive expressions that are computed outside of the log command and used only within it, you should
* make its evaluation conditional using this macro.
*/
-#define XBT_LOG_ISENABLED(catName, priority) \
- _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), priority)
+#define XBT_LOG_ISENABLED(catName, priority) _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), (priority))
/*
* Helper function that implements XBT_LOG_ISENABLED.
* First part is a compile-time constant.
* Call to xbt_log_cat_init only happens once.
*/
-#define _XBT_LOG_ISENABLEDV(catv, priority) \
- (priority >= XBT_LOG_STATIC_THRESHOLD \
- && ((catv).initialized || _xbt_log_cat_init(&(catv), priority)) \
- && priority >= (catv).threshold)
+#define _XBT_LOG_ISENABLEDV(catv, priority) \
+ ((priority) >= XBT_LOG_STATIC_THRESHOLD && ((catv).initialized || _xbt_log_cat_init(&(catv), (priority))) && \
+ (priority) >= (catv).threshold)
/*
* Internal Macros
#define XBT_CLOG(category, prio, ...) \
do { \
- if (_XBT_LOG_ISENABLEDV((category), prio)) { \
+ if (_XBT_LOG_ISENABLEDV((category), (prio))) { \
s_xbt_log_event_t _log_ev; \
_log_ev.cat = &(category); \
_log_ev.priority = (prio); \
} \
} while (0)
-#define XBT_LOG(prio, ...) XBT_CLOG(*_simgrid_log_category__default, prio, __VA_ARGS__)
+#define XBT_LOG(prio, ...) XBT_CLOG(*_simgrid_log_category__default, (prio), __VA_ARGS__)
#endif
#define _XBT_IN_OUT(...) \
_XBT_IF_ONE_ARG(_XBT_IN_OUT_ARG1, _XBT_IN_OUT_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _XBT_IN_OUT_ARG1(fmt) \
- XBT_LOG(xbt_log_priority_trace, fmt, __func__)
-#define _XBT_IN_OUT_ARGN(fmt, ...) \
- XBT_LOG(xbt_log_priority_trace, fmt, __func__, __VA_ARGS__)
+#define _XBT_IN_OUT_ARG1(fmt) XBT_LOG(xbt_log_priority_trace, (fmt), __func__)
+#define _XBT_IN_OUT_ARGN(fmt, ...) XBT_LOG(xbt_log_priority_trace, (fmt), __func__, __VA_ARGS__)
/** @ingroup XBT_log
* @hideinitializer
#define jxbt_check_res(fun, res, allowed_exceptions, detail) \
do { \
- if (res != MSG_OK && (res | allowed_exceptions)) { \
- xbt_die("%s failed with error code %d, which is not an allowed exception. Please fix me.", fun, res); \
- } else if (res == MSG_HOST_FAILURE) { \
- jxbt_throw_host_failure(env, detail); \
- } else if (res == MSG_TRANSFER_FAILURE) { \
- jxbt_throw_transfer_failure(env, detail); \
- } else if (res == MSG_TIMEOUT) { \
- jxbt_throw_time_out_failure(env, detail); \
- } else if (res == MSG_TASK_CANCELED) { \
- jxbt_throw_task_cancelled(env, detail); \
+ if ((res) != MSG_OK && ((res) | (allowed_exceptions))) { \
+ xbt_die("%s failed with error code %d, which is not an allowed exception. Please fix me.", (fun), (res)); \
+ } else if ((res) == MSG_HOST_FAILURE) { \
+ jxbt_throw_host_failure(env, (detail)); \
+ } else if ((res) == MSG_TRANSFER_FAILURE) { \
+ jxbt_throw_transfer_failure(env, (detail)); \
+ } else if ((res) == MSG_TIMEOUT) { \
+ jxbt_throw_time_out_failure(env, (detail)); \
+ } else if ((res) == MSG_TASK_CANCELED) { \
+ jxbt_throw_task_cancelled(env, (detail)); \
} \
} while (0)
void sglua_register_platf_functions(lua_State* L);
#define lua_ensure(...) _XBT_IF_ONE_ARG(_lua_ensure_ARG1, _lua_ensure_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _lua_ensure_ARG1(cond) _lua_ensure_ARGN(cond, "Assertion " _XBT_STRINGIFY(cond) " failed")
+#define _lua_ensure_ARG1(cond) _lua_ensure_ARGN((cond), "Assertion " _XBT_STRINGIFY(cond) " failed")
#define _lua_ensure_ARGN(cond, ...) \
do { \
if (!(cond)) { \
char error_string[MPI_MAX_ERROR_STRING]; \
int error_size; \
PMPI_Error_string(ret, error_string, &error_size); \
- if(errhan==nullptr || errhan->errhandler()==MPI_ERRORS_RETURN) \
+ if ((errhan) == nullptr || (errhan)->errhandler() == MPI_ERRORS_RETURN) \
XBT_WARN("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string); \
- else if(errhan->errhandler()==MPI_ERRORS_ARE_FATAL) \
+ else if ((errhan)->errhandler() == MPI_ERRORS_ARE_FATAL) \
xbt_die("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string); \
else \
- errhan->errhandler()->call(errhan, ret); \
+ (errhan)->errhandler()->call((errhan), ret); \
MC_assert(not MC_is_active()); /* Only fail in MC mode */ \
} \
XBT_VERB("SMPI - Leaving %s", __func__); \
#define CHECK_ARGS(test, errcode, ...) \
if (test) { \
XBT_WARN(__VA_ARGS__); \
- return errcode; \
+ return (errcode); \
}
/* PMPI User level calls */
smpi_bench_begin();
return ret;
}
-#define CHECK_FILE(fh) if(fh==MPI_FILE_NULL) return MPI_ERR_FILE;
-#define CHECK_BUFFER(buf, count) if (buf==nullptr && count > 0) return MPI_ERR_BUFFER;
-#define CHECK_COUNT(count) if (count < 0) return MPI_ERR_COUNT;
-#define CHECK_OFFSET(offset) if (offset < 0) return MPI_ERR_DISP;
-#define CHECK_DATATYPE(datatype, count) if (datatype == MPI_DATATYPE_NULL && count > 0) return MPI_ERR_TYPE;
-#define CHECK_STATUS(status) if (status == nullptr) return MPI_ERR_ARG;
-#define CHECK_FLAGS(fh) if (fh->flags() & MPI_MODE_SEQUENTIAL) return MPI_ERR_AMODE;
-#define CHECK_RDONLY(fh) if (fh->flags() & MPI_MODE_RDONLY ) return MPI_ERR_AMODE;
-
-#define PASS_ZEROCOUNT(count) if (count == 0) {\
-status->count=0;\
-return MPI_SUCCESS;\
-}
+#define CHECK_FILE(fh) \
+ if ((fh) == MPI_FILE_NULL) \
+ return MPI_ERR_FILE;
+#define CHECK_BUFFER(buf, count) \
+ if ((buf) == nullptr && (count) > 0) \
+ return MPI_ERR_BUFFER;
+#define CHECK_COUNT(count) \
+ if ((count) < 0) \
+ return MPI_ERR_COUNT;
+#define CHECK_OFFSET(offset) \
+ if ((offset) < 0) \
+ return MPI_ERR_DISP;
+#define CHECK_DATATYPE(datatype, count) \
+ if ((datatype) == MPI_DATATYPE_NULL && (count) > 0) \
+ return MPI_ERR_TYPE;
+#define CHECK_STATUS(status) \
+ if ((status) == nullptr) \
+ return MPI_ERR_ARG;
+#define CHECK_FLAGS(fh) \
+ if ((fh)->flags() & MPI_MODE_SEQUENTIAL) \
+ return MPI_ERR_AMODE;
+#define CHECK_RDONLY(fh) \
+ if ((fh)->flags() & MPI_MODE_RDONLY) \
+ return MPI_ERR_AMODE;
+
+#define PASS_ZEROCOUNT(count) \
+ if ((count) == 0) { \
+ status->count = 0; \
+ return MPI_SUCCESS; \
+ }
int PMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence){
CHECK_FILE(fh);
#define FORT_ADDR(addr, val, val2) \
(((void *)(addr) == (void*) &(val2)) \
? (val) : (void *)(addr))
-#define FORT_BOTTOM(addr) FORT_ADDR(addr, MPI_BOTTOM, mpi_bottom_)
-#define FORT_IN_PLACE(addr) FORT_ADDR(addr, MPI_IN_PLACE, mpi_in_place_)
-#define FORT_STATUS_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUS_IGNORE, mpi_status_ignore_))
-#define FORT_STATUSES_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUSES_IGNORE, mpi_statuses_ignore_))
+#define FORT_BOTTOM(addr) FORT_ADDR((addr), MPI_BOTTOM, mpi_bottom_)
+#define FORT_IN_PLACE(addr) FORT_ADDR((addr), MPI_IN_PLACE, mpi_in_place_)
+#define FORT_STATUS_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR((addr), MPI_STATUS_IGNORE, mpi_status_ignore_))
+#define FORT_STATUSES_IGNORE(addr) \
+ static_cast<MPI_Status*>(FORT_ADDR((addr), MPI_STATUSES_IGNORE, mpi_statuses_ignore_))
extern XBT_PRIVATE MPI_Comm MPI_COMM_UNINITIALIZED;
return dest;
}
#else
-#define asan_safe_memcpy(dest, src, n) memcpy(dest, src, n)
+#define asan_safe_memcpy(dest, src, n) memcpy((dest), (src), (n))
#endif
/** Map a given SMPI privatization segment (make a SMPI process active)
static std::unordered_map<std::string, simgrid::smpi::Datatype*> id2type_lookup;
#define CREATE_MPI_DATATYPE(name, id, type) \
- static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), id, sizeof(type), /* size */ \
- 0, /* lb */ \
+ static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), (id), sizeof(type), /* size */ \
+ 0, /* lb */ \
sizeof(type), /* ub = lb + size */ \
DT_FLAG_BASIC /* flags */ \
); \
const MPI_Datatype name = &_XBT_CONCAT(mpi_, name);
#define CREATE_MPI_DATATYPE_NULL(name, id) \
- static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), id, 0, /* size */ \
- 0, /* lb */ \
- 0, /* ub = lb + size */ \
- DT_FLAG_BASIC /* flags */ \
+ static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), (id), 0, /* size */ \
+ 0, /* lb */ \
+ 0, /* ub = lb + size */ \
+ DT_FLAG_BASIC /* flags */ \
); \
const MPI_Datatype name = &_XBT_CONCAT(mpi_, name);
#define MAX_OP(a, b) (b) = (a) < (b) ? (b) : (a)
#define MIN_OP(a, b) (b) = (a) < (b) ? (a) : (b)
#define SUM_OP(a, b) (b) += (a)
-#define SUM_OP_COMPLEX(a, b) {(b.value) += (a.value);(b.index) += (a.index);}
+#define SUM_OP_COMPLEX(a, b) \
+ { \
+ ((b).value) += ((a).value); \
+ ((b).index) += ((a).index); \
+ }
#define PROD_OP(a, b) (b) *= (a)
-#define PROD_OP_COMPLEX(a, b) {(b.value) *= (a.value);(b.index) *= (a.index);}
+#define PROD_OP_COMPLEX(a, b) \
+ { \
+ ((b).value) *= ((a).value); \
+ ((b).index) *= ((a).index); \
+ }
#define LAND_OP(a, b) (b) = (a) && (b)
#define LOR_OP(a, b) (b) = (a) || (b)
#define LXOR_OP(a, b) (b) = (not(a) && (b)) || ((a) && not(b))
#define BAND_OP(a, b) (b) &= (a)
#define BOR_OP(a, b) (b) |= (a)
#define BXOR_OP(a, b) (b) ^= (a)
-#define MAXLOC_OP(a, b) (b) = (a.value) < (b.value) ? (b) : ((a.value) == (b.value) ? ((a.index) < (b.index) ? (a) : (b)) : (a))
-#define MINLOC_OP(a, b) (b) = (a.value) < (b.value) ? (a) : ((a.value) == (b.value) ? ((a.index) < (b.index) ? (a) : (b)) : (b))
+#define MAXLOC_OP(a, b) \
+ (b) = ((a).value) < ((b).value) ? (b) : (((a).value) == ((b).value) ? (((a).index) < ((b).index) ? (a) : (b)) : (a))
+#define MINLOC_OP(a, b) \
+ (b) = ((a).value) < ((b).value) ? (a) : (((a).value) == ((b).value) ? (((a).index) < ((b).index) ? (a) : (b)) : (b))
#define APPLY_FUNC(a, b, length, type, func) \
{ \
} \
}
-#define APPLY_OP_LOOP(dtype, type, op) \
- if (*datatype == dtype) {\
- APPLY_FUNC(a, b, length, type, op)\
- } else \
-
+#define APPLY_OP_LOOP(dtype, type, op) \
+ if (*datatype == (dtype)) { \
+ APPLY_FUNC(a, b, length, type, op) \
+ } else
#define APPLY_BASIC_OP_LOOP(op)\
APPLY_OP_LOOP(MPI_CHAR, char,op)\
#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _plugin_register)() \
{ \
- simgrid_add_plugin_description(_XBT_STRINGIFY(id), desc, init); \
+ simgrid_add_plugin_description(_XBT_STRINGIFY(id), (desc), (init)); \
}
XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun);
* in a model-checking enabled tree. Without this protection, our malloc
* implementation will not like multi-threading AT ALL.
*/
-#define LOCK(mdp) pthread_mutex_lock(&mdp->mutex)
-#define UNLOCK(mdp) pthread_mutex_unlock(&mdp->mutex)
+#define LOCK(mdp) pthread_mutex_lock(&(mdp)->mutex)
+#define UNLOCK(mdp) pthread_mutex_unlock(&(mdp)->mutex)
XBT_PRIVATE int malloc_use_mmalloc(void);
} \
} else (void)0
-#define show_it(data, letter) \
- if (1) { \
- int len; \
- int wd; \
- if (length == -1) { \
- wd = 0; \
- } else { \
- wd = length; \
- length = -1; \
- } \
- if (precision == -1) { \
- len = snprintf(p, rem_size, "%*" letter, wd, data); \
- } else { \
- len = snprintf(p, rem_size, "%*.*" letter, wd, precision, data); \
- precision = -1; \
- } \
- check_overflow(len); \
- } else (void)0
+#define show_it(data, letter) \
+ if (1) { \
+ int len; \
+ int wd; \
+ if (length == -1) { \
+ wd = 0; \
+ } else { \
+ wd = length; \
+ length = -1; \
+ } \
+ if (precision == -1) { \
+ len = snprintf(p, rem_size, "%*" letter, wd, (data)); \
+ } else { \
+ len = snprintf(p, rem_size, "%*.*" letter, wd, precision, (data)); \
+ precision = -1; \
+ } \
+ check_overflow(len); \
+ } else \
+ (void)0
#define show_string(data) \
if (1) { \
const char *show_string_data = (data); \
show_it(show_string_data ? show_string_data : "(null)", "s"); \
} else (void)0
-#define show_int(data) show_it(data, "d")
-#define show_double(data) show_it(data, "f")
+#define show_int(data) show_it((data), "d")
+#define show_double(data) show_it((data), "f")
static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, const char* msg_fmt)
{
namespace lmm = simgrid::kernel::lmm;
#define PRINT_VAR(var) XBT_DEBUG(_XBT_STRINGIFY(var) " = %g", (var)->get_value())
-#define SHOW_EXPR(expr) XBT_DEBUG(_XBT_STRINGIFY(expr) " = %g", expr)
+#define SHOW_EXPR(expr) XBT_DEBUG(_XBT_STRINGIFY(expr) " = %g", (expr))
/* ______ */
/* ==l1== L2 ==L3== */
constexpr int BUFFSIZE = 204800;
constexpr int TESTSIZE = 100;
-#define size_of_block(i) (((i % 50)+1)* 100)
+#define size_of_block(i) ((((i) % 50) + 1) * 100)
static void check_block(const unsigned char* p, unsigned char b, int n)
{