kernel: Move LOCKED() macro to kernel_internal.h
Remove duplication in the code by moving macro LOCKED() to the correct
kernel_internal.h header.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
diff --git a/arch/arc/core/arc_connect.c b/arch/arc/core/arc_connect.c
index 76a4e5a..6faaeba 100644
--- a/arch/arc/core/arc_connect.c
+++ b/arch/arc/core/arc_connect.c
@@ -13,16 +13,10 @@
#include <kernel.h>
#include <arch/cpu.h>
#include <spinlock.h>
-
+#include <kernel_internal.h>
static struct k_spinlock arc_connect_spinlock;
-#define LOCKED(lck) for (k_spinlock_key_t __i = {}, \
- __key = k_spin_lock(lck); \
- !__i.key; \
- k_spin_unlock(lck, __key), __i.key = 1)
-
-
/* Generate an inter-core interrupt to the target core */
void z_arc_connect_ici_generate(uint32_t core)
{
diff --git a/kernel/include/kernel_internal.h b/kernel/include/kernel_internal.h
index 8ae14ff..7ca6c9f 100644
--- a/kernel/include/kernel_internal.h
+++ b/kernel/include/kernel_internal.h
@@ -202,6 +202,11 @@
/* Workaround for build-time page table mapping of the kernel */
void z_kernel_map_fixup(void);
+#define LOCKED(lck) for (k_spinlock_key_t __i = {}, \
+ __key = k_spin_lock(lck); \
+ !__i.key; \
+ k_spin_unlock(lck, __key), __i.key = 1)
+
#ifdef __cplusplus
}
#endif
diff --git a/kernel/sched.c b/kernel/sched.c
index 2084a29..e378978 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -60,11 +60,6 @@
static void update_cache(int);
-#define LOCKED(lck) for (k_spinlock_key_t __i = {}, \
- __key = k_spin_lock(lck); \
- !__i.key; \
- k_spin_unlock(lck, __key), __i.key = 1)
-
static inline int is_preempt(struct k_thread *thread)
{
#ifdef CONFIG_PREEMPT_ENABLED
diff --git a/kernel/timeout.c b/kernel/timeout.c
index 6d3c3d8..70c76ae 100644
--- a/kernel/timeout.c
+++ b/kernel/timeout.c
@@ -12,11 +12,6 @@
#include <drivers/timer/system_timer.h>
#include <sys_clock.h>
-#define LOCKED(lck) for (k_spinlock_key_t __i = {}, \
- __key = k_spin_lock(lck); \
- __i.key == 0; \
- k_spin_unlock(lck, __key), __i.key = 1)
-
static uint64_t curr_tick;
static sys_dlist_t timeout_list = SYS_DLIST_STATIC_INIT(&timeout_list);