-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable CAS for byte and short on RISC-V
Issue #31 (libatomic_ops). At least for gcc-7.2.0 does not define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 and __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 macros but, nonetheless, all the provided CAS operations are lock-free (except for double-word). * src/Makefile.am (nobase_private_HEADERS): Add gcc/riscv.h entry. * src/atomic_ops.h [__GNUC__ && !AO_USE_PTHREAD_DEFS && !__INTEL_COMPILER && __riscv]: Include gcc/riscv.h file. * src/atomic_ops/sysdeps/gcc/riscv.h: New file (include generic.h). * src/atomic_ops/sysdeps/gcc/riscv.h (AO_GCC_FORCE_HAVE_CAS): Define before include generic.h (and undefined at the end of file); add comment about double-word operations.
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED | ||
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK. | ||
* | ||
* Permission is hereby granted to use or copy this program | ||
* for any purpose, provided the above notices are retained on all copies. | ||
* Permission to modify the code and to distribute modified code is granted, | ||
* provided the above notices are retained, and a notice that the code was | ||
* modified is included with the above copyright notice. | ||
*/ | ||
|
||
/* As of gcc-7.2.0, some __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n are missing. */ | ||
/* The operations are lock-free (even for the types smaller than word). */ | ||
#define AO_GCC_FORCE_HAVE_CAS | ||
|
||
/* While double-word atomic operations are provided by the compiler */ | ||
/* (which requires -latomic currently), they are not lock-free as */ | ||
/* riscv itself does not have the double-word atomic operations. */ | ||
|
||
#include "generic.h" | ||
|
||
#undef AO_GCC_FORCE_HAVE_CAS |