riscv: use __riscv_atomic to check support A extension

GCC pre-defined some macros for detecting ISA extensions.
We should use these macros to detect ISA features.

Change-Id: I5782cdd1bf64b0161c58d789f46389dccfe44475
Signed-off-by: XiangWang <wxjstz@126.com>
Reviewed-on: https://review.coreboot.org/27300
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
This commit is contained in:
Xiang Wang 2018-07-04 15:57:52 +08:00 committed by Patrick Georgi
parent 12f0b4c80e
commit 8889e0106d
1 changed files with 1 additions and 1 deletions

View File

@ -39,7 +39,7 @@ typedef struct { int lock; } spinlock_t;
#define atomic_set(ptr, val) (*(volatile typeof(*(ptr)) *)(ptr) = val) #define atomic_set(ptr, val) (*(volatile typeof(*(ptr)) *)(ptr) = val)
#define atomic_read(ptr) (*(volatile typeof(*(ptr)) *)(ptr)) #define atomic_read(ptr) (*(volatile typeof(*(ptr)) *)(ptr))
#ifdef PK_ENABLE_ATOMICS #ifdef __riscv_atomic
# define atomic_add(ptr, inc) __sync_fetch_and_add(ptr, inc) # define atomic_add(ptr, inc) __sync_fetch_and_add(ptr, inc)
# define atomic_swap(ptr, swp) __sync_lock_test_and_set(ptr, swp) # define atomic_swap(ptr, swp) __sync_lock_test_and_set(ptr, swp)
# define atomic_cas(ptr, cmp, swp) __sync_val_compare_and_swap(ptr, cmp, swp) # define atomic_cas(ptr, cmp, swp) __sync_val_compare_and_swap(ptr, cmp, swp)