diff options
| author | Eric Reed <ereed@mozilla.com> | 2013-06-25 11:45:44 -0700 |
|---|---|---|
| committer | Eric Reed <ereed@mozilla.com> | 2013-06-25 11:45:44 -0700 |
| commit | 4870dce3ebfd0e988a2e45360c724ebe912c3ad5 (patch) | |
| tree | c676e677bf36924cbf177b0723b4ffe0fc435d40 /src/rt/rust_builtin.cpp | |
| parent | 794923c99511398bc90400e380dd11770ec8e614 (diff) | |
| parent | e65d0cbabebc73f2c9733a7ed158576c9702e71e (diff) | |
| download | rust-4870dce3ebfd0e988a2e45360c724ebe912c3ad5.tar.gz rust-4870dce3ebfd0e988a2e45360c724ebe912c3ad5.zip | |
Merge remote-tracking branch 'upstream/io' into io
Conflicts: src/rt/rustrt.def.in
Diffstat (limited to 'src/rt/rust_builtin.cpp')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index fe4e75fb8d2..51e2849eb54 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -17,6 +17,7 @@ #include "sync/timer.h" #include "sync/rust_thread.h" #include "rust_abi.h" +#include "vg/valgrind.h" #include <time.h> @@ -67,11 +68,10 @@ rust_env_pairs() { } #endif -extern "C" CDECL void -vec_reserve_shared_actual(type_desc* ty, rust_vec_box** vp, - size_t n_elts) { +extern "C" CDECL void * +rust_local_realloc(rust_opaque_box *ptr, size_t size) { rust_task *task = rust_get_current_task(); - reserve_vec_exact_shared(task, vp, n_elts * ty->size); + return task->boxed.realloc(ptr, size); } // This is completely misnamed. @@ -590,12 +590,18 @@ rust_log_console_on() { log_console_on(); } -extern void log_console_off(rust_env *env); +extern void log_console_off(); extern "C" CDECL void rust_log_console_off() { - rust_task *task = rust_get_current_task(); - log_console_off(task->kernel->env); + log_console_off(); +} + +extern bool should_log_console(); + +extern "C" CDECL uintptr_t +rust_should_log_console() { + return (uintptr_t)should_log_console(); } extern "C" CDECL void @@ -731,17 +737,10 @@ rust_task_deref(rust_task *task) { // Must call on rust stack. extern "C" CDECL void rust_call_tydesc_glue(void *root, size_t *tydesc, size_t glue_index) { -#ifdef _RUST_STAGE0 - void (*glue_fn)(void *, void *, void *, void *) = - (void (*)(void *, void *, void *, void *))tydesc[glue_index]; - if (glue_fn) - glue_fn(0, 0, 0, root); -#else void (*glue_fn)(void *, void *, void *) = (void (*)(void *, void *, void *))tydesc[glue_index]; if (glue_fn) glue_fn(0, 0, root); -#endif } // Don't run on the Rust stack! @@ -761,11 +760,7 @@ public: virtual void run() { record_sp_limit(0); -#ifdef _RUST_STAGE0 - fn.f(NULL, fn.env, NULL); -#else fn.f(fn.env, NULL); -#endif } }; @@ -888,6 +883,12 @@ rust_delete_memory_region(memory_region *region) { } extern "C" CDECL boxed_region* +rust_current_boxed_region() { + rust_task *task = rust_get_current_task(); + return &task->boxed; +} + +extern "C" CDECL boxed_region* rust_new_boxed_region(memory_region *region, uintptr_t poison_on_free) { return new boxed_region(region, poison_on_free); @@ -903,6 +904,11 @@ rust_boxed_region_malloc(boxed_region *region, type_desc *td, size_t size) { return region->malloc(td, size); } +extern "C" CDECL rust_opaque_box* +rust_boxed_region_realloc(boxed_region *region, rust_opaque_box *ptr, size_t size) { + return region->realloc(ptr, size); +} + extern "C" CDECL void rust_boxed_region_free(boxed_region *region, rust_opaque_box *box) { region->free(box); @@ -930,6 +936,11 @@ rust_begin_unwind(uintptr_t token) { #endif } +extern "C" CDECL uintptr_t +rust_running_on_valgrind() { + return RUNNING_ON_VALGRIND; +} + extern int get_num_cpus(); extern "C" CDECL uintptr_t @@ -937,6 +948,24 @@ rust_get_num_cpus() { return get_num_cpus(); } +static lock_and_signal global_args_lock; +static uintptr_t global_args_ptr = 0; + +extern "C" CDECL void +rust_take_global_args_lock() { + global_args_lock.lock(); +} + +extern "C" CDECL void +rust_drop_global_args_lock() { + global_args_lock.unlock(); +} + +extern "C" CDECL uintptr_t* +rust_get_global_args_ptr() { + return &global_args_ptr; +} + // // Local Variables: // mode: C++ |
