diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-07-27 14:34:39 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-07-28 12:23:01 -0700 |
| commit | 4ef1ec580aaf9f95d66c1654ce942f5e454a0b4d (patch) | |
| tree | 39b600f84688f7e49c734285593fbe9911214cd5 /src/rt/rust_task.cpp | |
| parent | 75985ab75ed216cd8c873c9ef08cd88708f8354f (diff) | |
| download | rust-4ef1ec580aaf9f95d66c1654ce942f5e454a0b4d.tar.gz rust-4ef1ec580aaf9f95d66c1654ce942f5e454a0b4d.zip | |
Do all runtime calls to getenv at initialization
getenv is not threadsafe and (maybe as a result) it's randomly crashing with CFLAGS=-g and RUST_THREADS=32. Calls from rust code are still on their own.
Diffstat (limited to 'src/rt/rust_task.cpp')
| -rw-r--r-- | src/rt/rust_task.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index a144879cc04..6f3e0202472 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -10,28 +10,25 @@ #include "globals.h" -// Stacks +// Stack size +size_t g_custom_min_stack_size = 0; -// FIXME (issue #151): This should be 0x300; the change here is for -// practicality's sake until stack growth is working. -size_t g_min_stack_size = 0x300000; - -static size_t get_min_stk_size() { - char *stack_size = getenv("RUST_MIN_STACK"); - if(stack_size) { - return strtol(stack_size, NULL, 0); - } - else { - return g_min_stack_size; +static size_t +get_min_stk_size(size_t default_size) { + if (g_custom_min_stack_size != 0) { + return g_custom_min_stack_size; + } else { + return default_size; } } + // Task stack segments. Heap allocated and chained together. static stk_seg* -new_stk(rust_task *task, size_t minsz) +new_stk(rust_scheduler *sched, rust_task *task, size_t minsz) { - size_t min_stk_bytes = get_min_stk_size(); + size_t min_stk_bytes = get_min_stk_size(sched->min_stack_size); if (minsz < min_stk_bytes) minsz = min_stk_bytes; size_t sz = sizeof(stk_seg) + minsz; @@ -90,7 +87,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, LOGPTR(sched, "new task", (uintptr_t)this); DLOG(sched, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this); - stk = new_stk(this, 0); + stk = new_stk(sched, this, 0); rust_sp = stk->limit; } |
