1
Fork 0

Do not pass taskpointers to "rust" native functions

Issue #466
This commit is contained in:
Marijn Haverbeke 2011-10-20 12:32:43 +02:00
parent 6323a012bd
commit 457683c7fe
9 changed files with 67 additions and 93 deletions

View file

@ -5762,7 +5762,7 @@ fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
let cast_to_i32; let cast_to_i32;
alt abi { alt abi {
ast::native_abi_rust. { ast::native_abi_rust. {
pass_task = true; pass_task = false;
uses_retptr = false; uses_retptr = false;
cast_to_i32 = true; cast_to_i32 = true;
} }

View file

@ -114,9 +114,9 @@ fn program_output(prog: str, args: [str]) ->
{status: int, out: str, err: str} { {status: int, out: str, err: str} {
let pr = start_program(prog, args); let pr = start_program(prog, args);
pr.close_input(); pr.close_input();
ret {status: pr.finish(), let out = read_all(pr.output());
out: read_all(pr.output()), let err = read_all(pr.err());
err: read_all(pr.err())}; ret {status: pr.finish(), out: out, err: err};
} }
/* Returns an exit status */ /* Returns an exit status */

View file

@ -38,7 +38,6 @@ native "rust" mod rustrt {
fn new_task() -> task_id; fn new_task() -> task_id;
fn drop_task(task: *rust_task); fn drop_task(task: *rust_task);
fn get_task_pointer(id: task_id) -> *rust_task; fn get_task_pointer(id: task_id) -> *rust_task;
fn get_task_trampoline() -> u32;
fn migrate_alloc(alloc: *u8, target: task_id); fn migrate_alloc(alloc: *u8, target: task_id);
fn start_task(id: task_id, closure: *u8); fn start_task(id: task_id, closure: *u8);

View file

@ -8,7 +8,7 @@
#endif #endif
extern "C" CDECL rust_str* extern "C" CDECL rust_str*
last_os_error(void *unused_task) { last_os_error() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, task, "last_os_error()"); LOG(task, task, "last_os_error()");
@ -51,7 +51,7 @@ last_os_error(void *unused_task) {
} }
extern "C" CDECL rust_str * extern "C" CDECL rust_str *
rust_getcwd(void *unused_task) { rust_getcwd() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, task, "rust_getcwd()"); LOG(task, task, "rust_getcwd()");
@ -71,47 +71,46 @@ rust_getcwd(void *unused_task) {
// TODO: Allow calling native functions that return double results. // TODO: Allow calling native functions that return double results.
extern "C" CDECL extern "C" CDECL
void squareroot(void *unused_task, double *input, double *output) { void squareroot(double *input, double *output) {
*output = sqrt(*input); *output = sqrt(*input);
} }
extern "C" CDECL size_t extern "C" CDECL size_t
size_of(void *unused_task, type_desc *t) { size_of(type_desc *t) {
return t->size; return t->size;
} }
extern "C" CDECL size_t extern "C" CDECL size_t
align_of(void *unused_task, type_desc *t) { align_of(type_desc *t) {
return t->align; return t->align;
} }
extern "C" CDECL void extern "C" CDECL void
leak(void *unused_task, type_desc *t, void *thing) { leak(type_desc *t, void *thing) {
// Do nothing. Call this with move-mode in order to say "Don't worry rust, // Do nothing. Call this with move-mode in order to say "Don't worry rust,
// I'll take care of this." // I'll take care of this."
} }
extern "C" CDECL intptr_t extern "C" CDECL intptr_t
refcount(void *unused_task, type_desc *t, intptr_t *v) { refcount(type_desc *t, intptr_t *v) {
// Passed-in value has refcount 1 too high // Passed-in value has refcount 1 too high
// because it was ref'ed while making the call. // because it was ref'ed while making the call.
return (*v) - 1; return (*v) - 1;
} }
extern "C" CDECL void extern "C" CDECL void
do_gc(void *unused_task) { do_gc() {
// TODO // TODO
} }
extern "C" CDECL void extern "C" CDECL void
unsupervise(void *unused_task) { unsupervise() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
task->unsupervise(); task->unsupervise();
} }
extern "C" CDECL void extern "C" CDECL void
vec_reserve_shared(void *unused_task, type_desc* ty, rust_vec** vp, vec_reserve_shared(type_desc* ty, rust_vec** vp,
size_t n_elts) { size_t n_elts) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
reserve_vec(task, vp, n_elts * ty->size); reserve_vec(task, vp, n_elts * ty->size);
@ -122,8 +121,7 @@ vec_reserve_shared(void *unused_task, type_desc* ty, rust_vec** vp,
* vector must have size zero. * vector must have size zero.
*/ */
extern "C" CDECL rust_vec* extern "C" CDECL rust_vec*
vec_from_buf_shared(void *unused_task, type_desc *ty, vec_from_buf_shared(type_desc *ty, void *ptr, size_t count) {
void *ptr, size_t count) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
size_t fill = ty->size * count; size_t fill = ty->size * count;
rust_vec* v = (rust_vec*)task->kernel->malloc(fill + sizeof(rust_vec), rust_vec* v = (rust_vec*)task->kernel->malloc(fill + sizeof(rust_vec),
@ -134,7 +132,7 @@ vec_from_buf_shared(void *unused_task, type_desc *ty,
} }
extern "C" CDECL void extern "C" CDECL void
rust_str_push(void *unused_task, rust_vec** sp, uint8_t byte) { rust_str_push(rust_vec** sp, uint8_t byte) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
size_t fill = (*sp)->fill; size_t fill = (*sp)->fill;
reserve_vec(task, sp, fill + 1); reserve_vec(task, sp, fill + 1);
@ -144,8 +142,7 @@ rust_str_push(void *unused_task, rust_vec** sp, uint8_t byte) {
} }
extern "C" CDECL void * extern "C" CDECL void *
rand_new(void *unused_task) rand_new() {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
rust_scheduler *sched = task->sched; rust_scheduler *sched = task->sched;
randctx *rctx = (randctx *) task->malloc(sizeof(randctx), "randctx"); randctx *rctx = (randctx *) task->malloc(sizeof(randctx), "randctx");
@ -158,32 +155,30 @@ rand_new(void *unused_task)
} }
extern "C" CDECL size_t extern "C" CDECL size_t
rand_next(void *unused_task, randctx *rctx) rand_next(randctx *rctx) {
{
return isaac_rand(rctx); return isaac_rand(rctx);
} }
extern "C" CDECL void extern "C" CDECL void
rand_free(void *unused_task, randctx *rctx) rand_free(randctx *rctx) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
task->free(rctx); task->free(rctx);
} }
extern "C" CDECL void extern "C" CDECL void
task_sleep(void *unused_task, size_t time_in_us) { task_sleep(size_t time_in_us) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
task->yield(time_in_us); task->yield(time_in_us);
} }
extern "C" CDECL void extern "C" CDECL void
task_yield(void *unused_task) { task_yield() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
task->yield(1); task->yield(1);
} }
extern "C" CDECL intptr_t extern "C" CDECL intptr_t
task_join(void *unused_task, rust_task_id tid) { task_join(rust_task_id tid) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
// If the other task is already dying, we don't have to wait for it. // If the other task is already dying, we don't have to wait for it.
rust_task *join_task = task->kernel->get_task_by_id(tid); rust_task *join_task = task->kernel->get_task_by_id(tid);
@ -211,25 +206,21 @@ task_join(void *unused_task, rust_task_id tid) {
/* Debug builtins for std::dbg. */ /* Debug builtins for std::dbg. */
static void static void
debug_tydesc_helper(void *unused_task, type_desc *t) debug_tydesc_helper(rust_task* task, type_desc *t) {
{
rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, " size %" PRIdPTR ", align %" PRIdPTR LOG(task, stdlib, " size %" PRIdPTR ", align %" PRIdPTR
", first_param 0x%" PRIxPTR, ", first_param 0x%" PRIxPTR,
t->size, t->align, t->first_param); t->size, t->align, t->first_param);
} }
extern "C" CDECL void extern "C" CDECL void
debug_tydesc(void *unused_task, type_desc *t) debug_tydesc(type_desc *t) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_tydesc"); LOG(task, stdlib, "debug_tydesc");
debug_tydesc_helper(task, t); debug_tydesc_helper(task, t);
} }
extern "C" CDECL void extern "C" CDECL void
debug_opaque(void *unused_task, type_desc *t, uint8_t *front) debug_opaque(type_desc *t, uint8_t *front) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_opaque"); LOG(task, stdlib, "debug_opaque");
debug_tydesc_helper(task, t); debug_tydesc_helper(task, t);
@ -248,8 +239,7 @@ struct rust_box {
}; };
extern "C" CDECL void extern "C" CDECL void
debug_box(void *unused_task, type_desc *t, rust_box *box) debug_box(type_desc *t, rust_box *box) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box); LOG(task, stdlib, "debug_box(0x%" PRIxPTR ")", box);
debug_tydesc_helper(task, t); debug_tydesc_helper(task, t);
@ -266,8 +256,7 @@ struct rust_tag {
}; };
extern "C" CDECL void extern "C" CDECL void
debug_tag(void *unused_task, type_desc *t, rust_tag *tag) debug_tag(type_desc *t, rust_tag *tag) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_tag"); LOG(task, stdlib, "debug_tag");
@ -285,9 +274,7 @@ struct rust_obj {
}; };
extern "C" CDECL void extern "C" CDECL void
debug_obj(void *unused_task, type_desc *t, rust_obj *obj, debug_obj(type_desc *t, rust_obj *obj, size_t nmethods, size_t nbytes) {
size_t nmethods, size_t nbytes)
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_obj with %" PRIdPTR " methods", nmethods); LOG(task, stdlib, "debug_obj with %" PRIdPTR " methods", nmethods);
@ -309,8 +296,7 @@ struct rust_fn {
}; };
extern "C" CDECL void extern "C" CDECL void
debug_fn(void *unused_task, type_desc *t, rust_fn *fn) debug_fn(type_desc *t, rust_fn *fn) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_fn"); LOG(task, stdlib, "debug_fn");
debug_tydesc_helper(task, t); debug_tydesc_helper(task, t);
@ -322,11 +308,9 @@ debug_fn(void *unused_task, type_desc *t, rust_fn *fn)
} }
extern "C" CDECL void * extern "C" CDECL void *
debug_ptrcast(void *unused_task, debug_ptrcast(type_desc *from_ty,
type_desc *from_ty,
type_desc *to_ty, type_desc *to_ty,
void *ptr) void *ptr) {
{
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, stdlib, "debug_ptrcast from"); LOG(task, stdlib, "debug_ptrcast from");
debug_tydesc_helper(task, from_ty); debug_tydesc_helper(task, from_ty);
@ -336,7 +320,7 @@ debug_ptrcast(void *unused_task,
} }
extern "C" CDECL rust_vec* extern "C" CDECL rust_vec*
rust_list_files(void *unused_task, rust_vec **path) { rust_list_files(rust_vec **path) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
array_list<rust_str*> strings; array_list<rust_str*> strings;
#if defined(__WIN32__) #if defined(__WIN32__)
@ -375,7 +359,7 @@ rust_list_files(void *unused_task, rust_vec **path) {
} }
extern "C" CDECL int extern "C" CDECL int
rust_file_is_dir(void *unused_task, char *path) { rust_file_is_dir(char *path) {
struct stat buf; struct stat buf;
if (stat(path, &buf)) { if (stat(path, &buf)) {
return 0; return 0;
@ -388,13 +372,13 @@ extern "C" CDECL FILE* rust_get_stdout() {return stdout;}
extern "C" CDECL FILE* rust_get_stderr() {return stderr;} extern "C" CDECL FILE* rust_get_stderr() {return stderr;}
extern "C" CDECL int extern "C" CDECL int
rust_ptr_eq(void *unused_task, type_desc *t, rust_box *a, rust_box *b) { rust_ptr_eq(type_desc *t, rust_box *a, rust_box *b) {
return a == b; return a == b;
} }
#if defined(__WIN32__) #if defined(__WIN32__)
extern "C" CDECL void extern "C" CDECL void
get_time(void *unused_task, uint32_t *sec, uint32_t *usec) { get_time(uint32_t *sec, uint32_t *usec) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
SYSTEMTIME systemTime; SYSTEMTIME systemTime;
FILETIME fileTime; FILETIME fileTime;
@ -410,7 +394,7 @@ get_time(void *unused_task, uint32_t *sec, uint32_t *usec) {
} }
#else #else
extern "C" CDECL void extern "C" CDECL void
get_time(void *unused_task, uint32_t *sec, uint32_t *usec) { get_time(uint32_t *sec, uint32_t *usec) {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
*sec = tv.tv_sec; *sec = tv.tv_sec;
@ -419,54 +403,48 @@ get_time(void *unused_task, uint32_t *sec, uint32_t *usec) {
#endif #endif
extern "C" CDECL void extern "C" CDECL void
nano_time(void *unused_task, uint64_t *ns) { nano_time(uint64_t *ns) {
timer t; timer t;
*ns = t.time_ns(); *ns = t.time_ns();
} }
extern "C" CDECL void extern "C" CDECL void
pin_task(void *unused_task) { pin_task() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
task->pin(); task->pin();
} }
extern "C" CDECL void extern "C" CDECL void
unpin_task(void *unused_task) { unpin_task() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
task->unpin(); task->unpin();
} }
extern "C" CDECL rust_task_id extern "C" CDECL rust_task_id
get_task_id(void *unused_task) { get_task_id() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
return task->user.id; return task->user.id;
} }
extern "C" CDECL rust_task_id extern "C" CDECL rust_task_id
new_task(void *unused_task) { new_task() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
return task->kernel->create_task(task, NULL); return task->kernel->create_task(task, NULL);
} }
extern "C" CDECL void extern "C" CDECL void
drop_task(void *unused_task, rust_task *target) { drop_task(rust_task *target) {
if(target) { if(target) {
target->deref(); target->deref();
} }
} }
extern "C" CDECL rust_task * extern "C" CDECL rust_task *
get_task_pointer(void *unused_task, rust_task_id id) { get_task_pointer(rust_task_id id) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
return task->kernel->get_task_by_id(id); return task->kernel->get_task_by_id(id);
} }
// FIXME: Transitional. Remove
extern "C" CDECL void **
get_task_trampoline(void *unused_task) {
return NULL;
}
struct fn_env_pair { struct fn_env_pair {
intptr_t f; intptr_t f;
intptr_t env; intptr_t env;
@ -480,7 +458,7 @@ void rust_spawn_wrapper(void* retptr, rust_task* taskptr, void* envptr,
} }
extern "C" CDECL void extern "C" CDECL void
start_task(void *unused_task, rust_task_id id, fn_env_pair *f) { start_task(rust_task_id id, fn_env_pair *f) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
rust_task *target = task->kernel->get_task_by_id(id); rust_task *target = task->kernel->get_task_by_id(id);
target->start((uintptr_t)rust_spawn_wrapper, f->f, f->env); target->start((uintptr_t)rust_spawn_wrapper, f->f, f->env);
@ -488,7 +466,7 @@ start_task(void *unused_task, rust_task_id id, fn_env_pair *f) {
} }
extern "C" CDECL void extern "C" CDECL void
migrate_alloc(void *unused_task, void *alloc, rust_task_id tid) { migrate_alloc(void *alloc, rust_task_id tid) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
if(!alloc) return; if(!alloc) return;
rust_task *target = task->kernel->get_task_by_id(tid); rust_task *target = task->kernel->get_task_by_id(tid);
@ -506,18 +484,18 @@ migrate_alloc(void *unused_task, void *alloc, rust_task_id tid) {
// defined in rust_task.cpp // defined in rust_task.cpp
extern size_t g_custom_min_stack_size; extern size_t g_custom_min_stack_size;
extern "C" CDECL void extern "C" CDECL void
set_min_stack(void *unused_task, uintptr_t stack_size) { set_min_stack(uintptr_t stack_size) {
g_custom_min_stack_size = stack_size; g_custom_min_stack_size = stack_size;
} }
extern "C" CDECL int extern "C" CDECL int
sched_threads(void *unused_task) { sched_threads() {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
return task->kernel->num_threads; return task->kernel->num_threads;
} }
extern "C" CDECL rust_port* extern "C" CDECL rust_port*
new_port(void *unused_task, size_t unit_sz) { new_port(size_t unit_sz) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, comm, "new_port(task=0x%" PRIxPTR " (%s), unit_sz=%d)", LOG(task, comm, "new_port(task=0x%" PRIxPTR " (%s), unit_sz=%d)",
(uintptr_t) task, task->name, unit_sz); (uintptr_t) task, task->name, unit_sz);
@ -527,7 +505,7 @@ new_port(void *unused_task, size_t unit_sz) {
} }
extern "C" CDECL void extern "C" CDECL void
del_port(void *unused_task, rust_port *port) { del_port(rust_port *port) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port); LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port);
I(task->sched, !port->ref_count); I(task->sched, !port->ref_count);
@ -538,12 +516,12 @@ del_port(void *unused_task, rust_port *port) {
} }
extern "C" CDECL rust_port_id extern "C" CDECL rust_port_id
get_port_id(void *unused_task, rust_port *port) { get_port_id(rust_port *port) {
return port->id; return port->id;
} }
extern "C" CDECL rust_chan* extern "C" CDECL rust_chan*
new_chan(void *unused_task, rust_port *port) { new_chan(rust_port *port) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
rust_scheduler *sched = task->sched; rust_scheduler *sched = task->sched;
LOG(task, comm, "new_chan(" LOG(task, comm, "new_chan("
@ -555,34 +533,34 @@ new_chan(void *unused_task, rust_port *port) {
} }
extern "C" CDECL extern "C" CDECL
void del_chan(void *unused_task, rust_chan *chan) { void del_chan(rust_chan *chan) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
LOG(task, comm, "del_chan(0x%" PRIxPTR ")", (uintptr_t) chan); LOG(task, comm, "del_chan(0x%" PRIxPTR ")", (uintptr_t) chan);
I(task->sched, false); I(task->sched, false);
} }
extern "C" CDECL extern "C" CDECL
void take_chan(void *unused_task, rust_chan *chan) { void take_chan(rust_chan *chan) {
chan->ref(); chan->ref();
} }
extern "C" CDECL extern "C" CDECL
void drop_chan(void *unused_task, rust_chan *chan) { void drop_chan(rust_chan *chan) {
chan->deref(); chan->deref();
} }
extern "C" CDECL extern "C" CDECL
void drop_port(void *, rust_port *port) { void drop_port(rust_port *port) {
port->ref_count--; port->ref_count--;
} }
extern "C" CDECL void extern "C" CDECL void
chan_send(void *unused_task, rust_chan *chan, void *sptr) { chan_send(rust_chan *chan, void *sptr) {
chan->send(sptr); chan->send(sptr);
} }
extern "C" CDECL void extern "C" CDECL void
chan_id_send(void *unused_task, type_desc *t, rust_task_id target_task_id, chan_id_send(type_desc *t, rust_task_id target_task_id,
rust_port_id target_port_id, void *sptr) { rust_port_id target_port_id, void *sptr) {
// FIXME: make sure this is thread-safe // FIXME: make sure this is thread-safe
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
@ -598,7 +576,7 @@ chan_id_send(void *unused_task, type_desc *t, rust_task_id target_task_id,
} }
extern "C" CDECL void extern "C" CDECL void
port_recv(void *unused_task, uintptr_t *dptr, rust_port *port) { port_recv(uintptr_t *dptr, rust_port *port) {
rust_task *task = rust_scheduler::get_task(); rust_task *task = rust_scheduler::get_task();
{ {
scoped_lock with(port->lock); scoped_lock with(port->lock);

View file

@ -288,7 +288,7 @@ struct type_desc {
#include "memory.h" #include "memory.h"
extern "C" CDECL void extern "C" CDECL void
port_recv(void *unused_task, uintptr_t *dptr, rust_port *port); port_recv(uintptr_t *dptr, rust_port *port);
#include "test/rust_test_harness.h" #include "test/rust_test_harness.h"
#include "test/rust_test_util.h" #include "test/rust_test_util.h"

View file

@ -2,7 +2,7 @@
#include "rust_port.h" #include "rust_port.h"
extern "C" CDECL rust_chan* extern "C" CDECL rust_chan*
new_chan(rust_task *task, rust_port *port); new_chan(rust_port *port);
rust_port::rust_port(rust_task *task, size_t unit_sz) rust_port::rust_port(rust_task *task, size_t unit_sz)
: ref_count(1), kernel(task->kernel), task(task), : ref_count(1), kernel(task->kernel), task(task),
@ -13,7 +13,7 @@ rust_port::rust_port(rust_task *task, size_t unit_sz)
PRIxPTR, (uintptr_t)task, unit_sz, (uintptr_t)this); PRIxPTR, (uintptr_t)task, unit_sz, (uintptr_t)this);
id = task->register_port(this); id = task->register_port(this);
remote_chan = new_chan(task, this); remote_chan = new_chan(this);
} }
rust_port::~rust_port() { rust_port::~rust_port() {

View file

@ -6,8 +6,7 @@
#include <io.h> #include <io.h>
extern "C" CDECL int extern "C" CDECL int
rust_run_program(void* task, const char* argv[], rust_run_program(const char* argv[], int in_fd, int out_fd, int err_fd) {
int in_fd, int out_fd, int err_fd) {
STARTUPINFO si; STARTUPINFO si;
ZeroMemory(&si, sizeof(STARTUPINFO)); ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO); si.cb = sizeof(STARTUPINFO);
@ -54,7 +53,7 @@ rust_run_program(void* task, const char* argv[],
} }
extern "C" CDECL int extern "C" CDECL int
rust_process_wait(void* task, int proc) { rust_process_wait(int proc) {
DWORD status; DWORD status;
while (true) { while (true) {
if (GetExitCodeProcess((HANDLE)proc, &status) && if (GetExitCodeProcess((HANDLE)proc, &status) &&
@ -73,8 +72,7 @@ rust_process_wait(void* task, int proc) {
#include <termios.h> #include <termios.h>
extern "C" CDECL int extern "C" CDECL int
rust_run_program(rust_task* task, char* argv[], rust_run_program(char* argv[], int in_fd, int out_fd, int err_fd) {
int in_fd, int out_fd, int err_fd) {
int pid = fork(); int pid = fork();
if (pid != 0) return pid; if (pid != 0) return pid;
@ -92,7 +90,7 @@ rust_run_program(rust_task* task, char* argv[],
} }
extern "C" CDECL int extern "C" CDECL int
rust_process_wait(void* task, int proc) { rust_process_wait(int proc) {
// FIXME: stub; exists to placate linker. // FIXME: stub; exists to placate linker.
return 0; return 0;
} }

View file

@ -45,10 +45,10 @@ copy_elements(rust_task *task, type_desc *elem_t,
} }
extern "C" CDECL void extern "C" CDECL void
upcall_fail(rust_task *task, upcall_fail(char const *expr,
char const *expr,
char const *file, char const *file,
size_t line) { size_t line) {
rust_task *task = rust_scheduler::get_task();
LOG_UPCALL_ENTRY(task); LOG_UPCALL_ENTRY(task);
LOG_ERR(task, upcall, "upcall fail '%s', %s:%" PRIdPTR, expr, file, line); LOG_ERR(task, upcall, "upcall fail '%s', %s:%" PRIdPTR, expr, file, line);
task->fail(); task->fail();

View file

@ -26,7 +26,6 @@ drop_task
get_port_id get_port_id
get_task_id get_task_id
get_task_pointer get_task_pointer
get_task_trampoline
get_time get_time
last_os_error last_os_error
leak leak