Skip to content

Commit 5283b9f

Browse files
aldrik-ramaekersSiegeLord
authored andcommitted
assert
1 parent ba92119 commit 5283b9f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/unix/uxthread.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void _al_thread_create(_AL_THREAD *thread, void (*proc)(_AL_THREAD*, void*), voi
7272

7373
void _al_thread_with_stacksize_create(_AL_THREAD* thread, void (*proc)(_AL_THREAD*, void*), void *arg, size_t stacksize)
7474
{
75+
ASSERT(stacksize >= PTHREAD_STACK_MIN);
7576
ASSERT(thread);
7677
ASSERT(proc);
7778
{
@@ -83,14 +84,17 @@ void _al_thread_with_stacksize_create(_AL_THREAD* thread, void (*proc)(_AL_THREA
8384
thread->proc = proc;
8485
thread->arg = arg;
8586

86-
// stacksize should be PTHREAD_STACK_MIN or more (16kb?)
8787
pthread_attr_t thread_attr;
88-
int s = 0;
89-
s = pthread_attr_init(&thread_attr);
90-
ASSERT(s==0);
91-
s = pthread_attr_setstacksize(&thread_attr, stacksize);
92-
93-
status = pthread_create(&thread->thread, &thread_attr, thread_proc_trampoline, thread);
88+
int result = 0;
89+
result = pthread_attr_init(&thread_attr);
90+
ASSERT(result == 0);
91+
92+
// On some systems, pthread_attr_setstacksize() can fail
93+
// if stacksize is not a multiple of the system page size.
94+
result = pthread_attr_setstacksize(&thread_attr, stacksize);
95+
ASSERT(result == 0);
96+
97+
status = pthread_create(&thread->thread, &thread_attr, thread_proc_trampoline, thread);
9498
ASSERT(status == 0);
9599
if (status != 0)
96100
abort();

0 commit comments

Comments
 (0)