diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-05-02 20:51:56 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-05-02 20:51:56 -0700 |
| commit | 6c478c7de889ec4943b9dcdcbfbb8a8244f479cc (patch) | |
| tree | 7f9fd01150a7611007255cbb2e45cf41e0cd4989 /src/rt/rust_builtin.cpp | |
| parent | baa1c1834f608c8c789db6d2495626ff9d28dd96 (diff) | |
| parent | f8dffc6789113a10c9dbf1d815c3569b19b53e96 (diff) | |
| download | rust-6c478c7de889ec4943b9dcdcbfbb8a8244f479cc.tar.gz rust-6c478c7de889ec4943b9dcdcbfbb8a8244f479cc.zip | |
Merge remote-tracking branch 'brson/io' into incoming
Conflicts: mk/rt.mk src/libcore/run.rs
Diffstat (limited to 'src/rt/rust_builtin.cpp')
| -rw-r--r-- | src/rt/rust_builtin.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index ee025a39ff4..8b7b89680fc 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -856,6 +856,63 @@ rust_initialize_global_state() { } } +extern "C" CDECL memory_region* +rust_new_memory_region(uintptr_t synchronized, + uintptr_t detailed_leaks, + uintptr_t poison_on_free) { + return new memory_region((bool)synchronized, + (bool)detailed_leaks, + (bool)poison_on_free); +} + +extern "C" CDECL void +rust_delete_memory_region(memory_region *region) { + delete region; +} + +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); +} + +extern "C" CDECL void +rust_delete_boxed_region(boxed_region *region) { + delete region; +} + +extern "C" CDECL rust_opaque_box* +rust_boxed_region_malloc(boxed_region *region, type_desc *td, size_t size) { + return region->malloc(td, size); +} + +extern "C" CDECL void +rust_boxed_region_free(boxed_region *region, rust_opaque_box *box) { + region->free(box); +} + +typedef void *(rust_try_fn)(void*, void*); + +extern "C" CDECL uintptr_t +rust_try(rust_try_fn f, void *fptr, void *env) { + try { + f(fptr, env); + } catch (uintptr_t token) { + assert(token != 0); + return token; + } + return 0; +} + +extern "C" CDECL void +rust_begin_unwind(uintptr_t token) { +#ifndef __WIN32__ + throw token; +#else + abort(); +#endif +} + // // Local Variables: // mode: C++ |
