From: Arnaud Giersch Date: Tue, 31 Oct 2017 22:28:14 +0000 (+0100) Subject: Replace legacy __sync* builtins by __atomic*. X-Git-Tag: v3.18~330 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7377fcd26c41f42160b385faf84135857928bda0 Replace legacy __sync* builtins by __atomic*. --- diff --git a/src/xbt/mallocator.c b/src/xbt/mallocator.c index e3a0319599..ec32f179c5 100644 --- a/src/xbt/mallocator.c +++ b/src/xbt/mallocator.c @@ -46,8 +46,7 @@ static inline void lock_reset(xbt_mallocator_t m) static inline void lock_acquire(xbt_mallocator_t m) { if (initialization_done > 1) { - int *lock = &m->lock; - while (__sync_lock_test_and_set(lock, 1)) + while (__atomic_test_and_set(&m->lock, __ATOMIC_ACQUIRE)) /* nop */; } } @@ -55,7 +54,7 @@ static inline void lock_acquire(xbt_mallocator_t m) static inline void lock_release(xbt_mallocator_t m) { if (initialization_done > 1) - __sync_lock_release(&m->lock); + __atomic_clear(&m->lock, __ATOMIC_RELEASE); } /** diff --git a/src/xbt/mallocator_private.h b/src/xbt/mallocator_private.h index a69e26ddb6..ccd5b5237d 100644 --- a/src/xbt/mallocator_private.h +++ b/src/xbt/mallocator_private.h @@ -17,7 +17,7 @@ typedef struct s_xbt_mallocator { pvoid_f_void_t new_f; /* function to call when we are running out of objects */ void_f_pvoid_t free_f; /* function to call when we have got too many objects */ void_f_pvoid_t reset_f; /* function to call when an object is released by the user */ - int lock; /* lock to ensure the mallocator is thread-safe */ + char lock; /* lock to ensure the mallocator is thread-safe */ } s_xbt_mallocator_t; #endif