Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace legacy __sync* builtins by __atomic*.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 31 Oct 2017 22:28:14 +0000 (23:28 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 31 Oct 2017 22:28:23 +0000 (23:28 +0100)
src/xbt/mallocator.c
src/xbt/mallocator_private.h

index e3a0319..ec32f17 100644 (file)
@@ -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) {
 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 */;
   }
 }
       /* 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)
 static inline void lock_release(xbt_mallocator_t m)
 {
   if (initialization_done > 1)
-    __sync_lock_release(&m->lock);
+    __atomic_clear(&m->lock, __ATOMIC_RELEASE);
 }
 
 /**
 }
 
 /**
index a69e26d..ccd5b52 100644 (file)
@@ -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 */
   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
 } s_xbt_mallocator_t;
 
 #endif