[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
This commit is contained in:
Kamil Rytarowski 2020-05-13 14:08:39 +02:00
parent 881c3bb6a7
commit f61f6ffe11
1 changed files with 5 additions and 4 deletions

View File

@ -23,6 +23,7 @@
//
//===----------------------------------------------------------------------===//
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
@ -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