diff options
author | Emmanuel Vadot <manu@FreeBSD.org> | 2018-05-28 20:29:03 +0000 |
---|---|---|
committer | Emmanuel Vadot <manu@FreeBSD.org> | 2018-05-28 20:29:03 +0000 |
commit | e39ce4cafb04e2e98bbb1e55e0940e7fdbad3ca9 (patch) | |
tree | 2f58f3787535fd8462c0075b82a3843cb31866e5 /sys/arm64 | |
parent | cfa989aa34f41825212a4c48aee3b4ad8efd2348 (diff) | |
download | src-e39ce4cafb04e2e98bbb1e55e0940e7fdbad3ca9.tar.gz src-e39ce4cafb04e2e98bbb1e55e0940e7fdbad3ca9.zip |
arm64: Add atomic_fcmpset_8 and atomic_fcmpset_16
Reviewed by: cognet
Notes
Notes:
svn path=/head/; revision=334295
Diffstat (limited to 'sys/arm64')
-rw-r--r-- | sys/arm64/include/atomic.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sys/arm64/include/atomic.h b/sys/arm64/include/atomic.h index a870f40a23c7..cee021f31871 100644 --- a/sys/arm64/include/atomic.h +++ b/sys/arm64/include/atomic.h @@ -102,6 +102,54 @@ ATOMIC(subtract, sub) #define ATOMIC_FCMPSET(bar, a, l) \ static __inline int \ +atomic_fcmpset_##bar##8(volatile uint8_t *p, uint8_t *cmpval, \ + uint8_t newval) \ +{ \ + uint8_t tmp; \ + uint8_t _cmpval = *cmpval; \ + int res; \ + \ + __asm __volatile( \ + "1: mov %w1, #1 \n" \ + " ld"#a"xrb %w0, [%2] \n" \ + " cmp %w0, %w3 \n" \ + " b.ne 2f \n" \ + " st"#l"xrb %w1, %w4, [%2]\n" \ + "2:" \ + : "=&r"(tmp), "=&r"(res) \ + : "r" (p), "r" (_cmpval), "r" (newval) \ + : "cc", "memory" \ + ); \ + *cmpval = tmp; \ + \ + return (!res); \ +} \ + \ +static __inline int \ +atomic_fcmpset_##bar##16(volatile uint16_t *p, uint16_t *cmpval, \ + uint8_t newval) \ +{ \ + uint16_t tmp; \ + uint16_t _cmpval = *cmpval; \ + int res; \ + \ + __asm __volatile( \ + "1: mov %w1, #1 \n" \ + " ld"#a"xh %w0, [%2] \n" \ + " cmp %w0, %w3 \n" \ + " b.ne 2f \n" \ + " st"#l"xh %w1, %w4, [%2] \n" \ + "2:" \ + : "=&r"(tmp), "=&r"(res) \ + : "r" (p), "r" (_cmpval), "r" (newval) \ + : "cc", "memory" \ + ); \ + *cmpval = tmp; \ + \ + return (!res); \ +} \ + \ +static __inline int \ atomic_fcmpset_##bar##32(volatile uint32_t *p, uint32_t *cmpval, \ uint32_t newval) \ { \ |