Skip to content

Commit

Permalink
Add _RUST_STAGE0 #ifdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslee committed May 28, 2013
1 parent 67283ea commit cddd274
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rt/rust_builtin.cpp
Expand Up @@ -754,7 +754,11 @@ class raw_thread: public rust_thread {

virtual void run() {
record_sp_limit(0);
#ifdef _RUST_STAGE0
fn.f(NULL, fn.env, NULL);
#else
fn.f(fn.env, NULL);
#endif
}
};

Expand Down
8 changes: 8 additions & 0 deletions src/rt/rust_task.cpp
Expand Up @@ -162,7 +162,11 @@ void task_start_wrapper(spawn_args *a)

bool threw_exception = false;
try {
#ifdef _RUST_STAGE0
a->f(NULL, a->envptr, a->argptr);
#else
a->f(a->envptr, a->argptr);
#endif
} catch (rust_task *ex) {
assert(ex == task && "Expected this task to be thrown for unwinding");
threw_exception = true;
Expand All @@ -183,7 +187,11 @@ void task_start_wrapper(spawn_args *a)
if(env) {
// free the environment (which should be a unique closure).
const type_desc *td = env->td;
#ifdef _RUST_STAGE0
td->drop_glue(NULL, NULL, NULL, box_body(env));
#else
td->drop_glue(NULL, NULL, box_body(env));
#endif
task->kernel->region()->free(env);
}

Expand Down
8 changes: 8 additions & 0 deletions src/rt/rust_type.h
Expand Up @@ -21,11 +21,19 @@ struct rust_opaque_box;
// - the main function: has a NULL environment, but uses the void* arg
// - unique closures of type fn~(): have a non-NULL environment, but
// no arguments (and hence the final void*) is harmless
#ifdef _RUST_STAGE0
typedef void (*CDECL spawn_fn)(void *, rust_opaque_box*, void *);
#else
typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *);
#endif

struct type_desc;

#ifdef _RUST_STAGE0
typedef void CDECL (glue_fn)(void *, void *, const type_desc **, void *);
#else
typedef void CDECL (glue_fn)(void *, const type_desc **, void *);
#endif

// Corresponds to the boxed data in the @ region. The body follows the
// header; you can obtain a ptr via box_body() below.
Expand Down

0 comments on commit cddd274

Please sign in to comment.