Skip to content

Commit 63fedeb

Browse files
elupushefloryd
authored andcommitted
feat(win): always assert that calls succeed
This matches behavior on rt-kernel and freertos. Our stacks are not expected to be able to handle the case these functions failing.
1 parent 0a10a01 commit 63fedeb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/windows/osal.c

+11-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ void os_free (void * ptr)
2929

3030
os_mutex_t * os_mutex_create (void)
3131
{
32-
return CreateMutex (NULL, FALSE, NULL);
32+
CRITICAL_SECTION * handle;
33+
handle = CreateMutex (NULL, FALSE, NULL);
34+
CC_ASSERT (handle != INVALID_HANDLE_VALUE);
35+
return handle;
3336
}
3437

3538
void os_mutex_lock (os_mutex_t * mutex)
@@ -62,6 +65,7 @@ os_thread_t * os_thread_create (
6265
HANDLE handle;
6366
handle =
6467
CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)entry, (LPVOID)arg, 0, NULL);
68+
CC_ASSERT (handle != INVALID_HANDLE_VALUE);
6569

6670
if (priority < 5)
6771
{
@@ -118,6 +122,7 @@ os_sem_t * os_sem_create (size_t count)
118122
os_sem_t * sem;
119123

120124
sem = (os_sem_t *)malloc (sizeof (*sem));
125+
CC_ASSERT (sem != NULL);
121126

122127
InitializeConditionVariable (&sem->condition);
123128
InitializeCriticalSection (&sem->lock);
@@ -139,7 +144,7 @@ bool os_sem_wait (os_sem_t * sem, uint32_t time)
139144
{
140145
goto timeout;
141146
}
142-
assert (success);
147+
CC_ASSERT (success);
143148
}
144149

145150
sem->count--;
@@ -168,6 +173,7 @@ os_event_t * os_event_create (void)
168173
os_event_t * event;
169174

170175
event = (os_event_t *)malloc (sizeof (*event));
176+
CC_ASSERT (event != NULL);
171177

172178
InitializeConditionVariable (&event->condition);
173179
InitializeCriticalSection (&event->lock);
@@ -221,6 +227,7 @@ os_mbox_t * os_mbox_create (size_t size)
221227
os_mbox_t * mbox;
222228

223229
mbox = (os_mbox_t *)malloc (sizeof (*mbox) + size * sizeof (void *));
230+
CC_ASSERT (mbox != NULL);
224231

225232
InitializeConditionVariable (&mbox->condition);
226233
InitializeCriticalSection (&mbox->lock);
@@ -246,7 +253,7 @@ bool os_mbox_fetch (os_mbox_t * mbox, void ** msg, uint32_t time)
246253
{
247254
goto timeout;
248255
}
249-
assert (success);
256+
CC_ASSERT (success);
250257
}
251258

252259
*msg = mbox->msg[mbox->r++];
@@ -275,7 +282,7 @@ bool os_mbox_post (os_mbox_t * mbox, void * msg, uint32_t time)
275282
{
276283
goto timeout;
277284
}
278-
assert (success);
285+
CC_ASSERT (success);
279286
}
280287

281288
mbox->msg[mbox->w++] = msg;

0 commit comments

Comments
 (0)