Skip to content

Commit 40c6af6

Browse files
tmediccixiaoxiang781216
authored andcommitted
Revert "libs/libc/semaphore: Fix DEBUGASSERTS"
This reverts commit 3009922 to fix a problem with `esp32-devkitc:blewifi`, which fails to boot up if `CONFIG_DEBUG_ASSERTIONS=y`. Introduced by #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()); ```
1 parent 1b08c1d commit 40c6af6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

libs/libc/semaphore/sem_trywait.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ int sem_trywait(FAR sem_t *sem)
106106

107107
int nxsem_trywait(FAR sem_t *sem)
108108
{
109+
DEBUGASSERT(sem != NULL);
110+
109111
/* This API should not be called from the idleloop or interrupt */
110112

111113
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
112-
DEBUGASSERT(sem != NULL);
113-
DEBUGASSERT(!up_interrupt_context());
114-
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
114+
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
115+
up_interrupt_context());
115116
#endif
116117

117118
/* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that

libs/libc/semaphore/sem_wait.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ int sem_wait(FAR sem_t *sem)
134134

135135
int nxsem_wait(FAR sem_t *sem)
136136
{
137+
DEBUGASSERT(sem != NULL);
138+
137139
/* This API should not be called from the idleloop or interrupt */
138140

139141
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
140-
DEBUGASSERT(sem != NULL);
141-
DEBUGASSERT(!up_interrupt_context());
142-
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
142+
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
143+
up_interrupt_context());
143144
#endif
144145

145146
/* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that

0 commit comments

Comments
 (0)