From 9a5d1974dc5114d6990db47cfd1d1edaabe01ce8 Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Mon, 16 Apr 2012 22:39:17 -0700 Subject: [PATCH] don't use ::malloc for initializing the global_async_handle in rust_kernel --- src/libstd/uv_hl.rs | 1 - src/rt/rust_kernel.cpp | 5 +++-- src/rt/rust_kernel.h | 1 + src/rt/rust_uv.cpp | 4 ---- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libstd/uv_hl.rs b/src/libstd/uv_hl.rs index feb56317cbd..7737bd49fe3 100644 --- a/src/libstd/uv_hl.rs +++ b/src/libstd/uv_hl.rs @@ -17,7 +17,6 @@ native mod rustrt { fn rust_uv_get_kernel_global_chan_ptr() -> *libc::uintptr_t; fn rust_uv_get_kernel_global_async_handle() -> **libc::c_void; fn rust_uv_set_kernel_global_async_handle(handle: *ll::uv_async_t); - fn rust_uv_free_kernel_global_async_handle(); } #[doc = " diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index adc62053345..1ff6fad64ab 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -27,8 +27,9 @@ rust_kernel::rust_kernel(rust_env *env) : // set up storage of pointers needed to // access the global loop. global_loop_chan = 0; - global_async_handle = (void**)::malloc( // FIXME--can't use this->malloc() - sizeof(void*)); // .. what do? + int foo = 0; + async_handle_stub = (void*)&foo; + global_async_handle = &async_handle_stub; *global_async_handle = (void*)0; // Create the single threaded scheduler that will run on the platform's diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h index 2309f4e6c1a..b77f9850bef 100644 --- a/src/rt/rust_kernel.h +++ b/src/rt/rust_kernel.h @@ -75,6 +75,7 @@ class rust_kernel { // Used to communicate with the process-side, global libuv loop uintptr_t global_loop_chan; + void* async_handle_stub; void** global_async_handle; public: diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 287e45aecd6..01517539e7a 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -454,7 +454,3 @@ extern "C" void rust_uv_set_kernel_global_async_handle(uv_async_t* handle) { rust_get_current_task()->kernel->set_global_async_handle((void*)handle); } -extern "C" void -rust_uv_free_kernel_global_async_handle() { - free((void*)rust_get_current_task()->kernel->get_global_async_handle()); -}