diff options
| author | bors <bors@rust-lang.org> | 2013-05-03 09:09:40 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-03 09:09:40 -0700 |
| commit | 79aeb529d5603e38e1e1ca0e0307eb9e998e1104 (patch) | |
| tree | d568b3892d1473826dbdb25eb97d32e8fa0d229e /src/rt/rust_builtin.cpp | |
| parent | d9c7d0bc938dd7a1d14e0d86fa0df439faa1ed3f (diff) | |
| parent | 6c478c7de889ec4943b9dcdcbfbb8a8244f479cc (diff) | |
| download | rust-79aeb529d5603e38e1e1ca0e0307eb9e998e1104.tar.gz rust-79aeb529d5603e38e1e1ca0e0307eb9e998e1104.zip | |
auto merge of #6046 : brson/rust/io, r=graydon
r? @pcwalton Sorry this is so big, and sorry the first commit is just titled 'wip'. Some interesting bits * [LocalServices](https://github.com/brson/rust/commit/f9069baa70ea78117f2087fe6e359fb2ea0ae16a) - This is the set of runtime capabilities that *all* Rust code should expect access to, including the local heap, GC, logging, unwinding. * [impl Reader, etc. for Option](https://github.com/brson/rust/commit/5fbb0949a53a6ac51c6d9b187ef4c464e52ae536) - Constructors like `File::open` return Option<FileStream>. This lets you write I/O code without ever unwrapping an option. This series adds a lot of [documentation](https://github.com/brson/rust/blob/io/src/libcore/rt/io/mod.rs#L11) to `core::rt::io`.
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++ |
