From ffad8d7f0cc4917f46757f5a431f6207238bf59b Mon Sep 17 00:00:00 2001 From: Jeff Olson Date: Fri, 17 Feb 2012 16:33:56 -0800 Subject: everything is laid out and working through a basic hw the core impl is there, with a async handle in place to take incoming operations from user code. No actual uv handle/operations are implemented yet, though. --- src/rt/rust_uvtmp.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/rt/rust_uvtmp.cpp') diff --git a/src/rt/rust_uvtmp.cpp b/src/rt/rust_uvtmp.cpp index 7bd0b4fe55b..4a8df1fa886 100644 --- a/src/rt/rust_uvtmp.cpp +++ b/src/rt/rust_uvtmp.cpp @@ -55,6 +55,58 @@ struct timer_start_data { chan_handle chan; }; +// UVTMP REWORK + +static void* +current_kernel_malloc(size_t size, const char* tag) { + return rust_task_thread::get_task()->malloc(size, tag); +} + +/* +static void +current_kernel_free(void* ptr) { + rust_task_thread::get_task()->free(ptr); +} +*/ + +extern "C" void* +rust_uvtmp_uv_loop_new() { + return (void*)uv_loop_new(); +} + +extern "C" void +rust_uvtmp_uv_loop_set_data(uv_loop_t* loop, void* data) { + loop->data = data; +} + +typedef void (*async_op_cb)(void* data); +void native_async_op_cb(uv_async_t* handle, int status) { + async_op_cb cb = (async_op_cb)handle->data; + void* loop_data = handle->loop->data; + cb(loop_data); +} + +extern "C" void* +rust_uvtmp_uv_bind_op_cb(uv_loop_t* loop, async_op_cb cb) { + uv_async_t* async = (uv_async_t*)current_kernel_malloc( + sizeof(uv_async_t), + "uv_async_t"); + uv_async_init(loop, async, native_async_op_cb); + async->data = (void*)cb; + return async; +} + +extern "C" void rust_uvtmp_uv_run(uv_loop_t* loop) { + uv_run(loop); +} + +extern "C" void +rust_uvtmp_uv_async_send(uv_async_t* handle) { + uv_async_send(handle); +} + +// UVTMP REWORK + // FIXME: Copied from rust_builtins.cpp. Could bitrot easily static void send(rust_task *task, chan_handle chan, void *data) { -- cgit 1.4.1-3-g733a5