Skip to content

Commit fbaf582

Browse files
olsonjefferybrson
authored andcommitted
---
yaml --- r: 12560 b: refs/heads/master c: c6667c0 h: refs/heads/master v: v3
1 parent 95f5365 commit fbaf582

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: bf99a3aa932d32a1390ca58df403c68defc51a07
2+
refs/heads/master: c6667c06c34a25a8a21a1805b4f454f2d05d337c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rt/rust_kernel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ rust_kernel::rust_kernel(rust_env *env) :
2424
non_weak_tasks(0),
2525
env(env)
2626
{
27+
// set up storage of pointers needed to
28+
// access the global loop.
29+
global_loop_chan = 0;
30+
global_async_handle = (void**)::malloc( // FIXME -- can use this->malloc()
31+
sizeof(void*)); // .. what do?
32+
*global_async_handle = (void*)0;
33+
2734
// Create the single threaded scheduler that will run on the platform's
2835
// main thread
2936
rust_manual_sched_launcher_factory launchfac;

trunk/src/rt/rust_kernel.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class rust_kernel {
7373
rust_scheduler* get_scheduler_by_id_nolock(rust_sched_id id);
7474
void end_weak_tasks();
7575

76+
// Used to communicate with the process-side, global libuv loop
77+
uintptr_t global_loop_chan;
78+
void** global_async_handle;
79+
7680
public:
7781
struct rust_env *env;
7882

@@ -117,6 +121,11 @@ class rust_kernel {
117121
void unweaken_task(rust_port_id chan);
118122

119123
bool send_to_port(rust_port_id chan, void *sptr);
124+
125+
uintptr_t* get_global_loop() { return &global_loop_chan; }
126+
void** get_global_async_handle() { return global_async_handle; }
127+
void set_global_async_handle(void* handle) {
128+
*global_async_handle = handle; }
120129
};
121130

122131
template <typename T> struct kernel_owned {

trunk/src/rt/rust_uv.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,24 @@ rust_uv_ip4_addr(const char* ip, int port) {
425425
LOG(task, stdlib, "after creating .. port: %d\n", addr.sin_port);
426426
return addr;
427427
}
428+
429+
extern "C" uintptr_t*
430+
rust_uv_get_kernel_global_chan_ptr() {
431+
uintptr_t* result = rust_get_current_task()->kernel->get_global_loop();
432+
printf("global loop: %lu\n", (unsigned long int)result);
433+
printf("global loop val: %lu\n", (unsigned long int)*result);
434+
return result;
435+
}
436+
437+
extern "C" void**
438+
rust_uv_get_kernel_global_async_handle() {
439+
return rust_get_current_task()->kernel->get_global_async_handle();
440+
}
441+
extern "C" void
442+
rust_uv_set_kernel_global_async_handle(uv_async_t* handle) {
443+
rust_get_current_task()->kernel->set_global_async_handle((void*)handle);
444+
}
445+
extern "C" void
446+
rust_uv_free_kernel_global_async_handle() {
447+
free((void*)rust_get_current_task()->kernel->get_global_async_handle());
448+
}

trunk/src/rt/rustrt.def.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ rust_uv_get_data_for_req
134134
rust_uv_set_data_for_req
135135
rust_uv_get_base_from_buf
136136
rust_uv_get_len_from_buf
137+
rust_uv_get_kernel_global_chan_ptr
138+
rust_uv_get_kernel_global_async_handle
139+
rust_uv_set_kernel_global_async_handle
140+
rust_uv_free_kernel_global_async_handle
137141
rust_dbg_lock_create
138142
rust_dbg_lock_destroy
139143
rust_dbg_lock_lock

0 commit comments

Comments
 (0)