Skip to content

Commit e8757ea

Browse files
committed
rt: Expose the C stack inside the Rust scheduler so that C calls can switch to it
1 parent dbf472b commit e8757ea

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/rt/rust_scheduler.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,10 @@ rust_scheduler::~rust_scheduler() {
5858

5959
void
6060
rust_scheduler::activate(rust_task *task) {
61-
context ctx;
62-
63-
task->ctx.next = &ctx;
61+
task->ctx.next = &c_context;
6462
DLOG(this, task, "descheduling...");
6563
lock.unlock();
66-
task->ctx.swap(ctx);
64+
task->ctx.swap(c_context);
6765
lock.lock();
6866
DLOG(this, task, "task has returned");
6967
}

src/rt/rust_scheduler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef RUST_SCHEDULER_H
22
#define RUST_SCHEDULER_H
33

4+
#include "context.h"
5+
46
#ifndef _WIN32
57
#include <pthread.h>
68
#else
@@ -72,6 +74,7 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
7274
static bool tls_initialized;
7375

7476
rust_env *env;
77+
context c_context;
7578

7679
// Only a pointer to 'name' is kept, so it must live as long as this
7780
// domain.

0 commit comments

Comments
 (0)