Skip to content

Commit

Permalink
kernel: prioritize C atomic functions if selected
Browse files Browse the repository at this point in the history
Usually, GCC builtin or arch-specific atomic functions are being
used. The corresponding kconfigs are "selected" by architecture
or SoC kconfigs. CONFIG_ATOMIC_OPERATIONS_C is usually used to
override the GCC built-in or arch-specific atomic functions when
these two are not supported. So change the priority of #include
so that C version is included first if selected, and skips
the inline versions of the other two variants. Or else there
will be two compiled versions of atomic functions: inline version
and the compiled C version. Note that the arch-specific version
and builtin are swapped, so the builtin one is now the default.

Fixes #33857

Signed-off-by: Daniel Leung <[email protected]>
  • Loading branch information
dcpleung authored and nashif committed Apr 2, 2021
1 parent a06d54c commit 9f0188d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/sys/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ typedef void *atomic_ptr_t;

/* Low-level primitives come in several styles: */

#if defined(CONFIG_ATOMIC_OPERATIONS_BUILTIN)
/* Default. See this file for the Doxygen reference: */
#include <sys/atomic_builtin.h>
#if defined(CONFIG_ATOMIC_OPERATIONS_C)
/* Generic-but-slow implementation based on kernel locking and syscalls */
#include <sys/atomic_c.h>
#elif defined(CONFIG_ATOMIC_OPERATIONS_ARCH)
/* Some architectures need their own implementation */
# ifdef CONFIG_XTENSA
/* Not all Xtensa toolchains support GCC-style atomic intrinsics */
# include <arch/xtensa/atomic_xtensa.h>
# endif
#else
/* Generic-but-slow implementation based on kernel locking and syscalls */
#include <sys/atomic_c.h>
/* Default. See this file for the Doxygen reference: */
#include <sys/atomic_builtin.h>
#endif

/* Portable higher-level utilities: */
Expand Down

0 comments on commit 9f0188d

Please sign in to comment.