diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 2c5b56f3fa4ef..1243d82460346 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 008b470fede76..b0e13717b8289 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 0385804a77871..fbedb9bc6efb2 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; } }