diff options
author | Nathan Froyd <froydnj@mozilla.com> | 2020-08-18 21:21:27 +0000 |
---|---|---|
committer | Nathan Froyd <froydnj@mozilla.com> | 2020-08-18 21:21:27 +0000 |
commit | 146b6cba1af64af4608e1a023f6d2a370d9005da (patch) | |
tree | fd780799b223e4094735935ca123881cb9c3b762 | |
parent | b2e8a6219e77e043484dcda737295cf3b8f0ee90 (diff) | |
download | nspr-hg-146b6cba1af64af4608e1a023f6d2a370d9005da.tar.gz |
Bug 1657124 - specialize atomic functions for aarch64 Darwin; r=glandium
Other Darwin architectures (x86/x86-64/ppc) have assembly versions of these
functions. ARM and AArch64, for whatever reason, lean on OS-specific
functions. These functions are deprecated in macOS 10.12 and later, though,
leading to a flood of warning spam. Implementing them as compiler
intrinsics is a much more reasonable thing to do.
Differential Revision: https://phabricator.services.mozilla.com/D85876
-rw-r--r-- | pr/include/md/_darwin.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pr/include/md/_darwin.h b/pr/include/md/_darwin.h index 1d79d3d8..d7d6f9d7 100644 --- a/pr/include/md/_darwin.h +++ b/pr/include/md/_darwin.h @@ -124,7 +124,16 @@ extern PRInt32 _PR_Darwin_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val); #define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_64_AtomicAdd(ptr, val) #endif /* __x86_64__ */ -#if defined(__arm__) || defined(__aarch64__) +#ifdef __aarch64__ +#define _PR_HAVE_ATOMIC_OPS +#define _MD_INIT_ATOMIC() +#define _MD_ATOMIC_INCREMENT(val) __sync_add_and_fetch(val, 1) +#define _MD_ATOMIC_DECREMENT(val) __sync_sub_and_fetch(val, 1) +#define _MD_ATOMIC_SET(val, newval) __sync_lock_test_and_set(val, newval) +#define _MD_ATOMIC_ADD(ptr, val) __sync_add_and_fetch(ptr, val) +#endif /* __aarch64__ */ + +#if defined(__arm__) #define _PR_HAVE_ATOMIC_OPS #define _MD_INIT_ATOMIC() #define _MD_ATOMIC_INCREMENT(val) OSAtomicIncrement32(val) @@ -138,7 +147,7 @@ static inline PRInt32 _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval) return oldval; } #define _MD_ATOMIC_ADD(ptr, val) OSAtomicAdd32(val, ptr) -#endif /* __arm__ || __aarch64__ */ +#endif /* __arm__ */ #define USE_SETJMP |