mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 02:48:37 +08:00
Compare commits
2 commits
aa6265a7fa
...
ec2f767d11
Author | SHA1 | Date | |
---|---|---|---|
|
ec2f767d11 | ||
|
5e23c4a79b |
1 changed files with 42 additions and 24 deletions
|
@ -554,19 +554,28 @@ irqstate_t spin_lock_irqsave(FAR volatile spinlock_t *lock)
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPINLOCK
|
||||
# define spin_trylock_irqsave_wo_note(l, f) \
|
||||
({ \
|
||||
f = up_irq_save(); \
|
||||
spin_trylock_wo_note(l) ? \
|
||||
true : ({ up_irq_restore(f); false; }); \
|
||||
})
|
||||
static inline_function
|
||||
bool spin_trylock_irqsave_wo_note(FAR volatile spinlock_t *lock,
|
||||
FAR irqstate_t *flags)
|
||||
{
|
||||
*flags = up_irq_save();
|
||||
|
||||
if (!spin_trylock_wo_note(lock))
|
||||
{
|
||||
up_irq_restore(*flags);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
# define spin_trylock_irqsave_wo_note(l, f) \
|
||||
({ \
|
||||
(void)(l); \
|
||||
f = up_irq_save(); \
|
||||
true; \
|
||||
})
|
||||
static inline_function
|
||||
bool spin_trylock_irqsave_wo_note(FAR volatile spinlock_t *lock,
|
||||
FAR irqstate_t *flags)
|
||||
{
|
||||
*flags = up_irq_save();
|
||||
return true;
|
||||
}
|
||||
#endif /* CONFIG_SPINLOCK */
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -590,19 +599,28 @@ irqstate_t spin_lock_irqsave(FAR volatile spinlock_t *lock)
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPINLOCK
|
||||
# define spin_trylock_irqsave(l, f) \
|
||||
({ \
|
||||
f = up_irq_save(); \
|
||||
spin_trylock(l) ? \
|
||||
true : ({ up_irq_restore(f); false; }); \
|
||||
})
|
||||
static inline_function
|
||||
bool spin_trylock_irqsave(FAR volatile spinlock_t *lock,
|
||||
FAR irqstate_t *flags)
|
||||
{
|
||||
*flags = up_irq_save();
|
||||
|
||||
if (!spin_trylock(lock))
|
||||
{
|
||||
up_irq_restore(*flags);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
# define spin_trylock_irqsave(l, f) \
|
||||
({ \
|
||||
(void)(l); \
|
||||
f = up_irq_save(); \
|
||||
true; \
|
||||
})
|
||||
static inline_function
|
||||
bool spin_trylock_irqsave(FAR volatile spinlock_t *lock,
|
||||
FAR irqstate_t *flags)
|
||||
{
|
||||
*flags = up_irq_save();
|
||||
return true;
|
||||
}
|
||||
#endif /* CONFIG_SPINLOCK */
|
||||
|
||||
/****************************************************************************
|
||||
|
|
Loading…
Reference in a new issue