aboutsummaryrefslogtreecommitdiffstats
path: root/erts/lib_src/win/ethread.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/lib_src/win/ethread.c')
-rw-r--r--erts/lib_src/win/ethread.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/erts/lib_src/win/ethread.c b/erts/lib_src/win/ethread.c
index e0f19f7ba1..aa43e03435 100644
--- a/erts/lib_src/win/ethread.c
+++ b/erts/lib_src/win/ethread.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2010-2016. All Rights Reserved.
+ * Copyright Ericsson AB 2010-2017. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -56,6 +56,7 @@ typedef struct {
void *(*thr_func)(void *);
void *arg;
void *prep_func_res;
+ size_t stacksize;
} ethr_thr_wrap_data__;
#define ETHR_INVALID_TID_ID -1
@@ -94,6 +95,7 @@ static void thr_exit_cleanup(ethr_tid *tid, void *res)
static unsigned __stdcall thr_wrapper(LPVOID vtwd)
{
+ char c;
ethr_tid my_tid;
ethr_sint32_t result;
void *res;
@@ -102,6 +104,8 @@ static unsigned __stdcall thr_wrapper(LPVOID vtwd)
void *arg = twd->arg;
ethr_ts_event *tsep = NULL;
+ ethr_set_stacklimit__(&c, twd->stacksize);
+
result = (ethr_sint32_t) ethr_make_ts_event__(&tsep);
if (result == 0) {
@@ -199,6 +203,8 @@ ethr_init(ethr_init_data *id)
if (!ethr_not_inited__)
return EINVAL;
+ ethr_not_inited__ = 0;
+
#ifdef _WIN32_WINNT
os_version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os_version);
@@ -234,8 +240,6 @@ ethr_init(ethr_init_data *id)
if (erts_get_cpu_configured(ethr_cpu_info__) == 1)
child_wait_spin_count = 0;
- ethr_not_inited__ = 0;
-
return 0;
error:
@@ -305,18 +309,21 @@ ethr_thr_create(ethr_tid *tid, void * (*func)(void *), void *arg,
tid->jdata->res = NULL;
}
+ twd.stacksize = 0;
+
if (use_stack_size >= 0) {
size_t suggested_stack_size = (size_t) use_stack_size;
#ifdef ETHR_DEBUG
suggested_stack_size /= 2; /* Make sure we got margin */
#endif
- if (suggested_stack_size < ethr_min_stack_size__)
- stack_size = (unsigned) ETHR_KW2B(ethr_min_stack_size__);
- else if (suggested_stack_size > ethr_max_stack_size__)
- stack_size = (unsigned) ETHR_KW2B(ethr_max_stack_size__);
- else
- stack_size = (unsigned)
- ETHR_PAGE_ALIGN(ETHR_KW2B(suggested_stack_size));
+ stack_size = (unsigned) ETHR_PAGE_ALIGN(ETHR_KW2B(suggested_stack_size));
+
+ if (stack_size < (unsigned) ethr_min_stack_size__)
+ stack_size = (unsigned) ethr_min_stack_size__;
+ else if (stack_size > (unsigned) ethr_max_stack_size__)
+ stack_size = (unsigned) ethr_max_stack_size__;
+
+ twd.stacksize = stack_size;
}
ethr_atomic32_init(&twd.result, -1);