Add core::private::run_in_bare_thread

This begins executing Rust code in a fresh context with no runtime environment
This commit is contained in:
Brian Anderson 2013-01-10 19:03:13 -08:00
parent 4c441e95d6
commit 1b1700f44b
3 changed files with 67 additions and 0 deletions

View file

@ -15,6 +15,7 @@
#include "rust_util.h"
#include "rust_scheduler.h"
#include "sync/timer.h"
#include "sync/rust_thread.h"
#include "rust_abi.h"
#include "rust_port.h"
@ -972,6 +973,36 @@ rust_log_str(uint32_t level, const char *str, size_t size) {
task->sched_loop->get_log().log(task, level, "%.*s", (int)size, str);
}
extern "C" CDECL void record_sp_limit(void *limit);
class raw_thread: public rust_thread {
public:
fn_env_pair *fn;
raw_thread(fn_env_pair *fn) : fn(fn) { }
virtual void run() {
record_sp_limit(0);
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);
thread->start();
return thread;
}
extern "C" void
rust_raw_thread_join_delete(raw_thread *thread) {
assert(thread);
thread->join();
delete thread;
}
//
// Local Variables:
// mode: C++