about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-08-10 18:48:57 -0700
committerEric Holk <eholk@mozilla.com>2011-08-15 09:26:51 -0700
commitb2dad8af31d5d77e9e7da8561d87249fff216e80 (patch)
tree29e255b492c44064e8e96a1375cfc3d240776013 /src/rt/rust_builtin.cpp
parent871d1317e51fce142def29b7bde9dcb1225050bf (diff)
downloadrust-b2dad8af31d5d77e9e7da8561d87249fff216e80.tar.gz
rust-b2dad8af31d5d77e9e7da8561d87249fff216e80.zip
Added a library version of spawn. Before long, we can remove the old version.
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index a7d6a902231..0c957cef3a9 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -707,6 +707,37 @@ get_task_id(rust_task *task) {
     return task->id;
 }
 
+extern "C" CDECL rust_task_id
+new_task(rust_task *task) {
+    return task->kernel->create_task(task, NULL);
+}
+
+extern "C" CDECL registers_t *
+get_task_context(rust_task *task, rust_task_id id) {
+    registers_t *regs = &task->kernel->get_task_by_id(id)->ctx.regs;
+    // This next line is a little dangerous.. It means we can only safely call
+    // this when starting a task.
+    regs->esp = task->rust_sp;
+    return regs;
+}
+
+extern "C" CDECL rust_task *
+get_task_pointer(rust_task *task, rust_task_id id) {
+    return task->kernel->get_task_by_id(id);
+}
+
+extern "C" CDECL void
+start_task(rust_task *task, rust_task_id id) {
+    task->kernel->get_task_by_id(id)->start();
+}
+
+extern "C" void *task_trampoline asm("task_trampoline");
+
+extern "C" CDECL void **
+get_task_trampoline(rust_task *task) {
+    return &task_trampoline;
+}
+
 extern "C" CDECL rust_chan *
 clone_chan(rust_task *task, rust_chan *chan) {
     return chan->clone(task);