Revert "libs/libc/semaphore: Fix DEBUGASSERTS"

This reverts commit 300992203a to
fix a problem with `esp32-devkitc:blewifi`, which fails to boot up
if `CONFIG_DEBUG_ASSERTIONS=y`.

Introduced by https://github.com/apache/nuttx/pull/16176 with the
following description:

> The DEBUGASSERTS in nxsem_wait and nxsem_trywait are
non-functional, they don't check anything. These were broken in
previous commits.

The above statements are not valid. Originally, there was no
problem calling `nxsem_trywait` from the interrupt and the
`DEBUGASSERT` simply checked a corner case: if ran from the
interrupt context, the current (interrupted) task may be the idle
task. This case is allowed only if called from an interrupt and
that's what the original commit checks with:

```
  DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
              up_interrupt_context());
```
This commit is contained in:
Tiago Medicci Serrano 2025-04-14 13:52:38 -03:00 committed by Xiang Xiao
parent 1b08c1d522
commit 40c6af6dec
2 changed files with 8 additions and 6 deletions

View file

@ -106,12 +106,13 @@ int sem_trywait(FAR sem_t *sem)
int nxsem_trywait(FAR sem_t *sem)
{
DEBUGASSERT(sem != NULL);
/* This API should not be called from the idleloop or interrupt */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
DEBUGASSERT(sem != NULL);
DEBUGASSERT(!up_interrupt_context());
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
up_interrupt_context());
#endif
/* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that

View file

@ -134,12 +134,13 @@ errout_with_cancelpt:
int nxsem_wait(FAR sem_t *sem)
{
DEBUGASSERT(sem != NULL);
/* This API should not be called from the idleloop or interrupt */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
DEBUGASSERT(sem != NULL);
DEBUGASSERT(!up_interrupt_context());
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
up_interrupt_context());
#endif
/* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that