From f3a7be8a83ef66f846254955a4c5a0af0abd25a4 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 17 Apr 2018 17:07:39 +0200 Subject: [PATCH] do not define MIN() and MAX() in xbt/base.h to not polute our mpi.h --- include/simgrid/msg.h | 10 ++++++++++ include/simgrid/simdag.h | 10 ++++++++++ include/xbt/base.h | 11 ----------- src/simdag/simdag_private.hpp | 3 +-- src/xbt/log.c | 3 +++ src/xbt/mallocator.c | 3 +++ src/xbt/mmalloc/mmprivate.h | 3 +++ src/xbt/xbt_log_layout_format.c | 3 +++ 8 files changed, 33 insertions(+), 13 deletions(-) diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index 74d1edb8c8..9f7d0cd3ff 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -16,6 +16,16 @@ #include #include +#ifdef MIN +#undef MIN +#endif +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +#ifdef MAX +#undef MAX +#endif +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + #ifdef __cplusplus #include #include diff --git a/include/simgrid/simdag.h b/include/simgrid/simdag.h index cb54bd9b71..766fe1e3df 100644 --- a/include/simgrid/simdag.h +++ b/include/simgrid/simdag.h @@ -15,6 +15,16 @@ #include #endif +#ifdef MIN +#undef MIN +#endif +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +#ifdef MAX +#undef MAX +#endif +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + SG_BEGIN_DECL() /** @brief Link opaque datatype diff --git a/include/xbt/base.h b/include/xbt/base.h index e8537c0f33..f4de224de4 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -91,17 +91,6 @@ # define XBT_THREAD_LOCAL No thread local on this architecture #endif -/* improvable on gcc (by evaluating arguments only once), but wouldn't be portable */ -#ifdef MIN -# undef MIN -#endif -#define MIN(a,b) ((a)<(b)?(a):(b)) - -#ifdef MAX -# undef MAX -#endif -#define MAX(a,b) ((a)>(b)?(a):(b)) - /* * Expands to `one' if there is only one argument for the variadic part. * Otherwise, expands to `more'. diff --git a/src/simdag/simdag_private.hpp b/src/simdag/simdag_private.hpp index fc9403fedf..66810f7e16 100644 --- a/src/simdag/simdag_private.hpp +++ b/src/simdag/simdag_private.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2006-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ diff --git a/src/xbt/log.c b/src/xbt/log.c index 7365993adf..eee33f2c74 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -24,6 +24,9 @@ #include "xbt/sysdep.h" #include "xbt/xbt_os_thread.h" +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + 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 ee6a2536de..77a6915640 100644 --- a/src/xbt/mallocator.c +++ b/src/xbt/mallocator.c @@ -13,6 +13,9 @@ #include "xbt/asserts.h" #include "xbt/sysdep.h" +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_mallocator, xbt, "Mallocators"); /** Implementation note on the mallocators: diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index 4854410fe6..dcf8c4ecd3 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -26,6 +26,9 @@ #include #include +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + #ifdef HAVE_LIMITS_H # include #else diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 3e711bb7bd..7aa607199f 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -11,6 +11,9 @@ #include "xbt/sysdep.h" #include +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + extern const char *xbt_log_priority_names[8]; #define ERRMSG \ -- 2.20.1