diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-02-27 12:39:11 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-02-27 12:39:11 -0800 |
| commit | 1b1017087be4e842ef0ff43486da8b4e9b085f14 (patch) | |
| tree | c4a891456c2316f104c7d18261580e956e06d2d7 | |
| parent | a8f07dc9df24af3cf06171bfde1a68b3058e2ec5 (diff) | |
| download | rust-1b1017087be4e842ef0ff43486da8b4e9b085f14.tar.gz rust-1b1017087be4e842ef0ff43486da8b4e9b085f14.zip | |
rt: Make some runtime calls work outside of task context
| -rw-r--r-- | src/rt/rust_builtin.cpp | 6 | ||||
| -rw-r--r-- | src/rt/rust_upcall.cpp | 7 | ||||
| -rw-r--r-- | src/rt/rust_util.h | 7 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 2c5b56f3fa4..1243d824603 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -124,8 +124,7 @@ vec_reserve_shared_actual(type_desc* ty, rust_vec_box** vp, extern "C" CDECL void vec_reserve_shared(type_desc* ty, rust_vec_box** vp, size_t n_elts) { - rust_task *task = rust_get_current_task(); - reserve_vec_exact(task, vp, n_elts * ty->size); + reserve_vec_exact(vp, n_elts * ty->size); } extern "C" CDECL size_t @@ -445,9 +444,8 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff, out_tm->tm_nsec = nsec; if (zone != NULL) { - rust_task *task = rust_get_current_task(); size_t size = strlen(zone); - reserve_vec_exact(task, &out_tm->tm_zone, size + 1); + reserve_vec_exact(&out_tm->tm_zone, size + 1); memcpy(out_tm->tm_zone->body.data, zone, size); out_tm->tm_zone->body.fill = size + 1; out_tm->tm_zone->body.data[size] = '\0'; diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 008b470fede..b0e13717b82 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -118,7 +118,12 @@ extern "C" CDECL void upcall_fail(char const *expr, char const *file, size_t line) { - rust_task *task = rust_get_current_task(); + rust_task *task = rust_try_get_current_task(); + if (task == NULL) { + // NOTE: Need to think about what to do here + printf("failure outside of a task"); + abort(); + } s_fail_args args = {task,expr,file,line}; UPCALL_SWITCH_STACK(task, &args, upcall_s_fail); } diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index 0385804a778..fbedb9bc6ef 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -67,11 +67,12 @@ inline void reserve_vec_exact_shared(rust_task* task, rust_vec_box** vpp, } } -inline void reserve_vec_exact(rust_task* task, rust_vec_box** vpp, +inline void reserve_vec_exact(rust_vec_box** vpp, size_t size) { if (size > (*vpp)->body.alloc) { - *vpp = (rust_vec_box*)task->kernel - ->realloc(*vpp, size + sizeof(rust_vec_box)); + rust_exchange_alloc exchange_alloc; + *vpp = (rust_vec_box*)exchange_alloc + .realloc(*vpp, size + sizeof(rust_vec_box)); (*vpp)->body.alloc = size; } } |
