diff --git a/libs/libc/semaphore/sem_trywait.c b/libs/libc/semaphore/sem_trywait.c index 87e3fb8d55a..4cd4b1c59c2 100644 --- a/libs/libc/semaphore/sem_trywait.c +++ b/libs/libc/semaphore/sem_trywait.c @@ -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 diff --git a/libs/libc/semaphore/sem_wait.c b/libs/libc/semaphore/sem_wait.c index 0c56db9d962..77e03377d61 100644 --- a/libs/libc/semaphore/sem_wait.c +++ b/libs/libc/semaphore/sem_wait.c @@ -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