Skip to content

Commit f61f6ff

Browse files
committed
[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
1 parent 881c3bb commit f61f6ff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler-rt/lib/builtins/atomic.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//
2424
//===----------------------------------------------------------------------===//
2525

26+
#include <stdbool.h>
2627
#include <stdint.h>
2728
#include <string.h>
2829

@@ -293,8 +294,8 @@ OPTIMISED_CASES
293294
#undef OPTIMISED_CASE
294295

295296
#define OPTIMISED_CASE(n, lockfree, type) \
296-
int __atomic_compare_exchange_##n(type *ptr, type *expected, type desired, \
297-
int success, int failure) { \
297+
bool __atomic_compare_exchange_##n(type *ptr, type *expected, type desired, \
298+
int success, int failure) { \
298299
if (lockfree) \
299300
return __c11_atomic_compare_exchange_strong( \
300301
(_Atomic(type) *)ptr, expected, desired, success, failure); \
@@ -303,11 +304,11 @@ OPTIMISED_CASES
303304
if (*ptr == *expected) { \
304305
*ptr = desired; \
305306
unlock(l); \
306-
return 1; \
307+
return true; \
307308
} \
308309
*expected = *ptr; \
309310
unlock(l); \
310-
return 0; \
311+
return false; \
311312
}
312313
OPTIMISED_CASES
313314
#undef OPTIMISED_CASE

0 commit comments

Comments
 (0)