From f61f6ffe1126869b05a6f0b8fdee7b24c02d24f3 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Wed, 13 May 2020 14:08:39 +0200 Subject: [PATCH] [compiler-rt] [builtin] Switch the return type of __atomic_compare_exchange_##n to bool Summary: Synchronize the function definition with the LLVM documentation. https://llvm.org/docs/Atomics.html#libcalls-atomic GCC also returns bool for the same atomic builtin. Reviewers: theraven Reviewed By: theraven Subscribers: theraven, dberris, jfb, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D79845 --- compiler-rt/lib/builtins/atomic.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/builtins/atomic.c b/compiler-rt/lib/builtins/atomic.c index 32b3a0f..8634a72 100644 --- a/compiler-rt/lib/builtins/atomic.c +++ b/compiler-rt/lib/builtins/atomic.c @@ -23,6 +23,7 @@ // //===----------------------------------------------------------------------===// +#include #include #include @@ -293,8 +294,8 @@ OPTIMISED_CASES #undef OPTIMISED_CASE #define OPTIMISED_CASE(n, lockfree, type) \ - int __atomic_compare_exchange_##n(type *ptr, type *expected, type desired, \ - int success, int failure) { \ + bool __atomic_compare_exchange_##n(type *ptr, type *expected, type desired, \ + int success, int failure) { \ if (lockfree) \ return __c11_atomic_compare_exchange_strong( \ (_Atomic(type) *)ptr, expected, desired, success, failure); \ @@ -303,11 +304,11 @@ OPTIMISED_CASES if (*ptr == *expected) { \ *ptr = desired; \ unlock(l); \ - return 1; \ + return true; \ } \ *expected = *ptr; \ unlock(l); \ - return 0; \ + return false; \ } OPTIMISED_CASES #undef OPTIMISED_CASE -- 2.7.4