Skip to content

Commit

Permalink
libmetal/atomic: enable 64-bit atomic by toolchain builtin flags
Browse files Browse the repository at this point in the history
Fix compile error:
arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_read':
metal/io.h:252: undefined reference to `__atomic_load_8'
arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_write':
metal/io.h:290: undefined reference to `__atomic_store_8'

Not all 32-bit architectures support 64bit atomic, gcc/clang
toolchains have built-in properties to indicate whether support atomic64:

| $ arm-none-eabi-gcc -march=armv7e-m  -dM -E - < /dev/null | grep SYNC
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Jun 29, 2024
1 parent 3aee6be commit 105f878
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ extern "C" {
* @{
*/

#ifdef __MICROBLAZE__
#define NO_ATOMIC_64_SUPPORT
#if defined(__MICROBLAZE__) || \
(defined(__GNUC__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))

Check warning on line 34 in lib/io.h

View workflow job for this annotation

GitHub Actions / compliance review

LEADING_SPACE

lib/io.h:34 please, no spaces at the start of a line
# define NO_ATOMIC_64_SUPPORT
#endif

struct metal_io_region;
Expand Down

0 comments on commit 105f878

Please sign in to comment.