Skip to content

Commit

Permalink
spinlock: compile spinlock only if CONFIG_SPINLOCK is enabled
Browse files Browse the repository at this point in the history
Regression by: apache#12599

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Aug 4, 2024
1 parent 386c6e3 commit d8a3b6c
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions include/nuttx/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ static inline spinlock_t up_testset(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#ifdef CONFIG_SPINLOCK
static inline_function void spin_lock_wo_note(FAR volatile spinlock_t *lock)
{
#ifdef CONFIG_TICKET_SPINLOCK
Expand All @@ -272,6 +273,7 @@ static inline_function void spin_lock_wo_note(FAR volatile spinlock_t *lock)

SP_DMB();
}
#endif /* CONFIG_SPINLOCK */

/****************************************************************************
* Name: spin_lock
Expand All @@ -296,6 +298,7 @@ static inline_function void spin_lock_wo_note(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#ifdef CONFIG_SPINLOCK
static inline_function void spin_lock(FAR volatile spinlock_t *lock)
{
/* Notify that we are waiting for a spinlock */
Expand All @@ -310,6 +313,7 @@ static inline_function void spin_lock(FAR volatile spinlock_t *lock)

sched_note_spinlock_locked(lock);
}
#endif /* CONFIG_SPINLOCK */

/****************************************************************************
* Name: spin_trylock_wo_note
Expand All @@ -333,6 +337,7 @@ static inline_function void spin_lock(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#ifdef CONFIG_SPINLOCK
static inline_function bool
spin_trylock_wo_note(FAR volatile spinlock_t *lock)
{
Expand Down Expand Up @@ -367,6 +372,7 @@ spin_trylock_wo_note(FAR volatile spinlock_t *lock)
SP_DMB();
return true;
}
#endif /* CONFIG_SPINLOCK */

/****************************************************************************
* Name: spin_trylock
Expand All @@ -387,6 +393,7 @@ spin_trylock_wo_note(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#ifdef CONFIG_SPINLOCK
static inline_function bool spin_trylock(FAR volatile spinlock_t *lock)
{
bool locked;
Expand All @@ -413,6 +420,7 @@ static inline_function bool spin_trylock(FAR volatile spinlock_t *lock)

return locked;
}
#endif /* CONFIG_SPINLOCK */

/****************************************************************************
* Name: spin_unlock_wo_note
Expand All @@ -434,6 +442,7 @@ static inline_function bool spin_trylock(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#ifdef CONFIG_SPINLOCK
static inline_function void
spin_unlock_wo_note(FAR volatile spinlock_t *lock)
{
Expand All @@ -446,6 +455,7 @@ spin_unlock_wo_note(FAR volatile spinlock_t *lock)
SP_DSB();
SP_SEV();
}
#endif /* CONFIG_SPINLOCK */

/****************************************************************************
* Name: spin_unlock
Expand All @@ -464,7 +474,8 @@ spin_unlock_wo_note(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#ifdef __SP_UNLOCK_FUNCTION
#ifdef CONFIG_SPINLOCK
# ifdef __SP_UNLOCK_FUNCTION
static inline_function void spin_unlock(FAR volatile spinlock_t *lock)
{
/* Unlock without trace note */
Expand All @@ -475,9 +486,10 @@ static inline_function void spin_unlock(FAR volatile spinlock_t *lock)

sched_note_spinlock_unlock(lock);
}
#else
# define spin_unlock(l) do { *(l) = SP_UNLOCKED; } while (0)
#endif
# else
# define spin_unlock(l) do { *(l) = SP_UNLOCKED; } while (0)
# endif
#endif /* CONFIG_SPINLOCK */

/****************************************************************************
* Name: spin_is_locked
Expand Down Expand Up @@ -528,7 +540,7 @@ static inline_function void spin_unlock(FAR volatile spinlock_t *lock)
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
static inline_function
irqstate_t spin_lock_irqsave_wo_note(FAR spinlock_t *lock)
{
Expand Down Expand Up @@ -590,7 +602,7 @@ irqstate_t spin_lock_irqsave_wo_note(FAR spinlock_t *lock)
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
static inline_function
irqstate_t spin_lock_irqsave(FAR spinlock_t *lock)
{
Expand Down Expand Up @@ -622,7 +634,7 @@ irqstate_t spin_lock_irqsave(FAR spinlock_t *lock)
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
static inline_function
void spin_unlock_irqrestore_wo_note(FAR spinlock_t *lock, irqstate_t flags)
{
Expand Down Expand Up @@ -677,7 +689,7 @@ void spin_unlock_irqrestore_wo_note(FAR spinlock_t *lock, irqstate_t flags)
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
static inline_function
void spin_unlock_irqrestore(FAR spinlock_t *lock, irqstate_t flags)
{
Expand Down Expand Up @@ -969,7 +981,7 @@ static inline_function void write_unlock(FAR volatile rwlock_t *lock)
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
irqstate_t read_lock_irqsave(FAR rwlock_t *lock);
#else
# define read_lock_irqsave(l) ((void)(l), up_irq_save())
Expand Down Expand Up @@ -1002,7 +1014,7 @@ irqstate_t read_lock_irqsave(FAR rwlock_t *lock);
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
void read_unlock_irqrestore(FAR rwlock_t *lock, irqstate_t flags);
#else
# define read_unlock_irqrestore(l, f) ((void)(l), up_irq_restore(f))
Expand Down Expand Up @@ -1041,7 +1053,7 @@ void read_unlock_irqrestore(FAR rwlock_t *lock, irqstate_t flags);
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
irqstate_t write_lock_irqsave(FAR rwlock_t *lock);
#else
# define write_lock_irqsave(l) ((void)(l), up_irq_save())
Expand Down Expand Up @@ -1076,7 +1088,7 @@ irqstate_t write_lock_irqsave(FAR rwlock_t *lock);
*
****************************************************************************/

#if defined(CONFIG_SPINLOCK)
#ifdef CONFIG_SPINLOCK
void write_unlock_irqrestore(FAR rwlock_t *lock, irqstate_t flags);
#else
# define write_unlock_irqrestore(l, f) ((void)(l), up_irq_restore(f))
Expand Down

0 comments on commit d8a3b6c

Please sign in to comment.