From 0d827ad8ca8662047131c7e327a5d0914c38d88f Mon Sep 17 00:00:00 2001 From: emaste Date: Sat, 17 Aug 2013 19:34:41 +0000 Subject: [PATCH] Correct implementation of atomic_flag_test_and_set The function sets the flag and returns the previous value (7.17.8.1). --- sys/sys/stdatomic.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sys/sys/stdatomic.h b/sys/sys/stdatomic.h index 054ded6d817e..37c3a06840f4 100644 --- a/sys/sys/stdatomic.h +++ b/sys/sys/stdatomic.h @@ -381,11 +381,7 @@ static __inline _Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, memory_order __order) { - _Bool __expected; - - __expected = 0; - return (atomic_compare_exchange_strong_explicit(&__object->__flag, - &__expected, 1, __order, __order)); + return (atomic_exchange_explicit(&__object->__flag, 1, __order)); } static __inline void