summaryrefslogtreecommitdiff
path: root/source/kit/threads.win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/kit/threads.win32.c')
-rw-r--r--source/kit/threads.win32.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/kit/threads.win32.c b/source/kit/threads.win32.c
index ce77fab..910ee82 100644
--- a/source/kit/threads.win32.c
+++ b/source/kit/threads.win32.c
@@ -322,10 +322,12 @@ void __threads_win32_tls_callback(void) {
/*------------------- 7.25.5 Thread functions -------------------*/
// 7.25.5.1
-int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) {
+int thrd_create_with_stack(thrd_t *thr, thrd_start_t func, void *arg,
+ ptrdiff_t const stack_size) {
impl_thrd_param_t *pack;
uintptr_t handle;
assert(thr != NULL);
+ assert(stack_size >= 0 && stack_size < 0x100000000);
kit_allocator_t alloc = kit_alloc_default();
pack = (impl_thrd_param_t *) alloc.allocate(
alloc.state, (sizeof(impl_thrd_param_t)));
@@ -334,8 +336,9 @@ int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) {
pack->func = func;
pack->arg = arg;
pack->alloc = alloc;
- handle = _beginthreadex(NULL, 0, impl_thrd_routine, pack,
- CREATE_SUSPENDED, NULL);
+ handle = _beginthreadex(NULL, (unsigned) stack_size,
+ impl_thrd_routine, pack, CREATE_SUSPENDED,
+ NULL);
if (handle == 0) {
alloc.deallocate(alloc.state, pack);
if (errno == EAGAIN || errno == EACCES)
@@ -348,6 +351,10 @@ int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) {
return thrd_success;
}
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) {
+ return thrd_create_with_stack(thr, func, arg);
+}
+
// 7.25.5.2
thrd_t thrd_current(void) {
/* GetCurrentThread() returns a pseudo-handle, which we need