about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index a2053c115bb..9349db17d56 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -882,6 +882,37 @@ rust_get_rt_env() {
     return task->kernel->env;
 }
 
+typedef void *(*nullary_fn)();
+
+extern "C" CDECL void
+rust_call_nullary_fn(nullary_fn f) {
+    f();
+}
+
+
+#ifndef _WIN32
+pthread_key_t sched_key;
+#else
+DWORD sched_key;
+#endif
+
+extern "C" void*
+rust_get_sched_tls_key() {
+    return &sched_key;
+}
+
+extern "C" CDECL void
+rust_initialize_global_state() {
+
+#ifndef _WIN32
+    assert(!pthread_key_create(&sched_key, NULL));
+#else
+    sched_key = TlsAlloc();
+    assert(sched_key != TLS_OUT_OF_INDEXES);
+#endif
+
+}
+
 //
 // Local Variables:
 // mode: C++