From: Martin Quinson Date: Tue, 17 Apr 2018 19:05:41 +0000 (+0200) Subject: properly protect our definitions of MIN/MAX (w/o using undef to please sonar) X-Git-Tag: v3.20~406 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/9b3780913f771e32ac6686a7f97b1a8248f11b27 properly protect our definitions of MIN/MAX (w/o using undef to please sonar) --- diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index 9f7d0cd3ff..abacb70ff9 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -16,15 +16,12 @@ #include #include -#ifdef MIN -#undef MIN -#endif +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#ifdef MAX -#undef MAX #endif +#ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif #ifdef __cplusplus #include diff --git a/include/simgrid/simdag.h b/include/simgrid/simdag.h index 766fe1e3df..48fbd18e47 100644 --- a/include/simgrid/simdag.h +++ b/include/simgrid/simdag.h @@ -15,15 +15,12 @@ #include #endif -#ifdef MIN -#undef MIN -#endif +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) - -#ifdef MAX -#undef MAX #endif +#ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif SG_BEGIN_DECL() diff --git a/src/xbt/log.c b/src/xbt/log.c index eee33f2c74..7853627699 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -24,8 +24,12 @@ #include "xbt/sysdep.h" #include "xbt/xbt_os_thread.h" +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif int xbt_log_no_loc = 0; /* if set to true (with --log=no_loc), file localization will be omitted (for tesh tests) */ static xbt_os_mutex_t log_cat_init_mutex = NULL; diff --git a/src/xbt/mallocator.c b/src/xbt/mallocator.c index 77a6915640..9b7bd8e8eb 100644 --- a/src/xbt/mallocator.c +++ b/src/xbt/mallocator.c @@ -13,8 +13,12 @@ #include "xbt/asserts.h" #include "xbt/sysdep.h" +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_mallocator, xbt, "Mallocators"); diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index d545fccc92..95d52c1784 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -26,14 +26,12 @@ #include #include -#ifdef MIN -#undef MIN -#endif +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) -#ifdef MAX -#undef MAX #endif +#ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif #ifdef HAVE_LIMITS_H # include diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 7aa607199f..b8c3a53035 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -11,8 +11,12 @@ #include "xbt/sysdep.h" #include +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif extern const char *xbt_log_priority_names[8];