X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ff4d8d0fbe1feb59a8799632af047771a78f1718..eb04a98f8aea129ddb5e0d6437671cf50c0cab91:/src/xbt/mallocator.c diff --git a/src/xbt/mallocator.c b/src/xbt/mallocator.c index f12abcd3a9..9b7bd8e8eb 100644 --- a/src/xbt/mallocator.c +++ b/src/xbt/mallocator.c @@ -13,6 +13,13 @@ #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"); /** Implementation note on the mallocators: @@ -40,13 +47,13 @@ static int initialization_done = 0; static inline void lock_reset(xbt_mallocator_t m) { - atomic_flag_clear(&m->lock); + m->lock = 0; } static inline void lock_acquire(xbt_mallocator_t m) { if (initialization_done > 1) { - while (atomic_flag_test_and_set(&m->lock)) + while (__atomic_test_and_set(&m->lock, __ATOMIC_ACQUIRE)) /* nop */; } } @@ -54,7 +61,7 @@ static inline void lock_acquire(xbt_mallocator_t m) static inline void lock_release(xbt_mallocator_t m) { if (initialization_done > 1) - atomic_flag_clear(&m->lock); + __atomic_clear(&m->lock, __ATOMIC_RELEASE); } /**