diff options
| author | bors <bors@rust-lang.org> | 2013-03-11 20:21:45 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-11 20:21:45 -0700 |
| commit | 48cb9a8ac0b95408a142ea7bc9767414eba2cbb3 (patch) | |
| tree | 2aa22a3dbbdbf2364a41feba5f358dfd3e979574 /src/rt | |
| parent | a6bb4a0f1a61ab00e09c4cb24dfff95c6c2481c7 (diff) | |
| parent | 676e0290ed4d306e6d7b517de1409c109309a0b2 (diff) | |
| download | rust-48cb9a8ac0b95408a142ea7bc9767414eba2cbb3.tar.gz rust-48cb9a8ac0b95408a142ea7bc9767414eba2cbb3.zip | |
auto merge of #5303 : brson/rust/newsched4, r=brson
r? Followup to #5022. This is the same, but everything is in `core::rt` now. `std::uv_ll` is moved to `core::unstable::uvll`, with the intent that it eventually move into its own crate (blocked on #5192 at least). I've had to disable the uv tests because of #2064. All of `core::rt` is disabled on platforms that aren't mac or linux until I complete the windows thread local storage bindings and ARM context switching. My immediate next priorities will be to fix #2064 and clean up the uv bindings, get everything building on all platforms.
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/arch/i386/_context.S | 10 | ||||
| -rw-r--r-- | src/rt/arch/i386/context.cpp | 3 | ||||
| -rw-r--r-- | src/rt/arch/x86_64/_context.S | 10 | ||||
| -rw-r--r-- | src/rt/arch/x86_64/context.cpp | 3 | ||||
| -rw-r--r-- | src/rt/rust.cpp | 15 | ||||
| -rw-r--r-- | src/rt/rust_builtin.cpp | 8 | ||||
| -rw-r--r-- | src/rt/rust_uv.cpp | 41 | ||||
| -rw-r--r-- | src/rt/rustrt.def.in | 7 |
8 files changed, 69 insertions, 28 deletions
diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S index a9e329f0bf3..d8b7281e72b 100644 --- a/src/rt/arch/i386/_context.S +++ b/src/rt/arch/i386/_context.S @@ -15,9 +15,15 @@ getcontext. The registers_t variable is in (%esp) */ +#if defined(__APPLE__) || defined(_WIN32) +#define SWAP_REGISTERS _swap_registers +#else +#define SWAP_REGISTERS swap_registers +#endif + // swap_registers(registers_t *oregs, registers_t *regs) -.globl swap_registers -swap_registers: +.globl SWAP_REGISTERS +SWAP_REGISTERS: // save the old context movl 4(%esp), %eax movl %ebx, 4(%eax) diff --git a/src/rt/arch/i386/context.cpp b/src/rt/arch/i386/context.cpp index 50a15e8d86c..94e6f0418d0 100644 --- a/src/rt/arch/i386/context.cpp +++ b/src/rt/arch/i386/context.cpp @@ -13,8 +13,7 @@ #include "../../rust_globals.h" extern "C" uint32_t CDECL swap_registers(registers_t *oregs, - registers_t *regs) - asm ("swap_registers"); + registers_t *regs); context::context() { diff --git a/src/rt/arch/x86_64/_context.S b/src/rt/arch/x86_64/_context.S index 7fdc6114b0a..1f9ae1c83c5 100644 --- a/src/rt/arch/x86_64/_context.S +++ b/src/rt/arch/x86_64/_context.S @@ -49,9 +49,15 @@ First four arguments: anyhow. */ +#if defined(__APPLE__) || defined(_WIN32) +#define SWAP_REGISTERS _swap_registers +#else +#define SWAP_REGISTERS swap_registers +#endif + // swap_registers(registers_t *oregs, registers_t *regs) -.globl swap_registers -swap_registers: +.globl SWAP_REGISTERS +SWAP_REGISTERS: // n.b. when we enter, the return address is at the top of // the stack (i.e., 0(%RSP)) and the argument is in // RUSTRT_ARG0_S. We diff --git a/src/rt/arch/x86_64/context.cpp b/src/rt/arch/x86_64/context.cpp index b7f82b57468..6a265dff761 100644 --- a/src/rt/arch/x86_64/context.cpp +++ b/src/rt/arch/x86_64/context.cpp @@ -13,8 +13,7 @@ #include "../../rust_globals.h" extern "C" void CDECL swap_registers(registers_t *oregs, - registers_t *regs) -asm ("swap_registers"); + registers_t *regs); context::context() { diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp index 803da32cbc8..d9ef6a52dbe 100644 --- a/src/rt/rust.cpp +++ b/src/rt/rust.cpp @@ -21,6 +21,17 @@ void* global_crate_map = NULL; +#ifndef _WIN32 +pthread_key_t sched_key; +#else +DWORD sched_key; +#endif + +extern "C" void* +rust_get_sched_tls_key() { + return &sched_key; +} + /** The runtime entrypoint. The (C ABI) main function generated by rustc calls `rust_start`, providing the address of the Rust ABI main function, the @@ -30,6 +41,10 @@ void* global_crate_map = NULL; extern "C" CDECL int rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) { +#ifndef _WIN32 + pthread_key_create(&sched_key, NULL); +#endif + // Load runtime configuration options from the environment. // FIXME #1497: Should provide a way to get these from the command // line as well. diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index a621d61cdf7..248f851e5b9 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -769,20 +769,20 @@ extern "C" CDECL void record_sp_limit(void *limit); class raw_thread: public rust_thread { public: - fn_env_pair *fn; + fn_env_pair fn; - raw_thread(fn_env_pair *fn) : fn(fn) { } + raw_thread(fn_env_pair fn) : fn(fn) { } virtual void run() { record_sp_limit(0); - fn->f(NULL, fn->env, NULL); + fn.f(NULL, fn.env, NULL); } }; extern "C" raw_thread* rust_raw_thread_start(fn_env_pair *fn) { assert(fn); - raw_thread *thread = new raw_thread(fn); + raw_thread *thread = new raw_thread(*fn); thread->start(); return thread; } diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index f08261c336d..51594348737 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -376,16 +376,7 @@ current_kernel_malloc_alloc_cb(uv_handle_t* handle, extern "C" void rust_uv_buf_init(uv_buf_t* out_buf, char* base, size_t len) { - rust_task* task = rust_get_current_task(); - LOG(task, stdlib,"rust_uv_buf_init: base: %lu" \ - "len: %lu", - (unsigned long int)base, - (unsigned long int)len); *out_buf = uv_buf_init(base, len); - LOG(task, stdlib, "rust_uv_buf_init: after: " - "result->base: %" PRIxPTR " len: %" PRIxPTR, - (unsigned long int)(*out_buf).base, - (unsigned long int)(*out_buf).len); } extern "C" uv_loop_t* @@ -481,18 +472,11 @@ rust_uv_free_base_of_buf(uv_buf_t buf) { extern "C" struct sockaddr_in rust_uv_ip4_addr(const char* ip, int port) { - rust_task* task = rust_get_current_task(); - LOG(task, stdlib, "before creating addr_ptr.. ip %s" \ - " port %d\n", ip, port); struct sockaddr_in addr = uv_ip4_addr(ip, port); - LOG(task, stdlib, "after creating .. port: %d", addr.sin_port); return addr; } extern "C" struct sockaddr_in6 rust_uv_ip6_addr(const char* ip, int port) { - rust_task* task = rust_get_current_task(); - LOG(task, stdlib, "before creating addr_ptr.. ip %s" \ - " port %d\n", ip, port); return uv_ip6_addr(ip, port); } extern "C" int @@ -554,3 +538,28 @@ extern "C" sockaddr_in6* rust_uv_addrinfo_as_sockaddr_in6(addrinfo* input) { return (sockaddr_in6*)input->ai_addr; } + +extern "C" uv_idle_t* +rust_uv_idle_new() { + return new uv_idle_t; +} + +extern "C" void +rust_uv_idle_delete(uv_idle_t* handle) { + delete handle; +} + +extern "C" int +rust_uv_idle_init(uv_loop_t* loop, uv_idle_t* idle) { + return uv_idle_init(loop, idle); +} + +extern "C" int +rust_uv_idle_start(uv_idle_t* idle, uv_idle_cb cb) { + return uv_idle_start(idle, cb); +} + +extern "C" int +rust_uv_idle_stop(uv_idle_t* idle) { + return uv_idle_stop(idle); +} diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index 284f827bc75..e27e0d52405 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -140,6 +140,11 @@ rust_uv_current_kernel_malloc rust_uv_current_kernel_free rust_uv_getaddrinfo rust_uv_freeaddrinfo +rust_uv_idle_new +rust_uv_idle_delete +rust_uv_idle_init +rust_uv_idle_start +rust_uv_idle_stop rust_dbg_lock_create rust_dbg_lock_destroy rust_dbg_lock_lock @@ -187,3 +192,5 @@ rust_get_global_data_ptr rust_inc_kernel_live_count rust_dec_kernel_live_count rust_get_exchange_count_ptr +rust_get_sched_tls_key +swap_registers |
