Skip to content

Commit cddd274

Browse files
committed
Add _RUST_STAGE0 #ifdefs
1 parent 67283ea commit cddd274

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/rt/rust_builtin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,11 @@ class raw_thread: public rust_thread {
754754

755755
virtual void run() {
756756
record_sp_limit(0);
757+
#ifdef _RUST_STAGE0
758+
fn.f(NULL, fn.env, NULL);
759+
#else
757760
fn.f(fn.env, NULL);
761+
#endif
758762
}
759763
};
760764

src/rt/rust_task.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ void task_start_wrapper(spawn_args *a)
162162

163163
bool threw_exception = false;
164164
try {
165+
#ifdef _RUST_STAGE0
166+
a->f(NULL, a->envptr, a->argptr);
167+
#else
165168
a->f(a->envptr, a->argptr);
169+
#endif
166170
} catch (rust_task *ex) {
167171
assert(ex == task && "Expected this task to be thrown for unwinding");
168172
threw_exception = true;
@@ -183,7 +187,11 @@ void task_start_wrapper(spawn_args *a)
183187
if(env) {
184188
// free the environment (which should be a unique closure).
185189
const type_desc *td = env->td;
190+
#ifdef _RUST_STAGE0
191+
td->drop_glue(NULL, NULL, NULL, box_body(env));
192+
#else
186193
td->drop_glue(NULL, NULL, box_body(env));
194+
#endif
187195
task->kernel->region()->free(env);
188196
}
189197

src/rt/rust_type.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ struct rust_opaque_box;
2121
// - the main function: has a NULL environment, but uses the void* arg
2222
// - unique closures of type fn~(): have a non-NULL environment, but
2323
// no arguments (and hence the final void*) is harmless
24+
#ifdef _RUST_STAGE0
25+
typedef void (*CDECL spawn_fn)(void *, rust_opaque_box*, void *);
26+
#else
2427
typedef void (*CDECL spawn_fn)(rust_opaque_box*, void *);
28+
#endif
2529

2630
struct type_desc;
2731

32+
#ifdef _RUST_STAGE0
33+
typedef void CDECL (glue_fn)(void *, void *, const type_desc **, void *);
34+
#else
2835
typedef void CDECL (glue_fn)(void *, const type_desc **, void *);
36+
#endif
2937

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

0 commit comments

Comments
 (0)