diff options
| author | Ben Blum <bblum@andrew.cmu.edu> | 2012-06-27 13:07:00 -0400 |
|---|---|---|
| committer | Ben Blum <bblum@andrew.cmu.edu> | 2012-06-28 00:10:03 -0400 |
| commit | 1ba3028d8b7acb0c97859ea438f2beb4ccd364f9 (patch) | |
| tree | 6fa4930844a1c0bd20f27b3347a1a905b81e4eaa /src/rt/rust_task.cpp | |
| parent | e56ba156e223e24025a743247610283cca49b30a (diff) | |
| download | rust-1ba3028d8b7acb0c97859ea438f2beb4ccd364f9.tar.gz rust-1ba3028d8b7acb0c97859ea438f2beb4ccd364f9.zip | |
rt: Add task_local_data and related builtin calls (Closes #2680)
Diffstat (limited to 'src/rt/rust_task.cpp')
| -rw-r--r-- | src/rt/rust_task.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index e5d61fda93d..c899d997197 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -31,6 +31,8 @@ rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state, propagate_failure(true), cc_counter(0), total_stack_sz(0), + task_local_data(NULL), + task_local_data_cleanup(NULL), state(state), cond(NULL), cond_name("none"), @@ -115,6 +117,16 @@ cleanup_task(cleanup_args *args) { } } + // Clean up TLS. This will only be set if TLS was used to begin with. + // Because this is a crust function, it must be called from the C stack. + if (task->task_local_data_cleanup != NULL) { + // This assert should hold but it's not our job to ensure it (and + // the condition might change). Handled in libcore/task.rs. + // assert(task->task_local_data != NULL); + task->task_local_data_cleanup(task->task_local_data); + task->task_local_data = NULL; + } + // FIXME (#2676): For performance we should do the annihilator // instead of the cycle collector even under normal termination, but // since that would hide memory management errors (like not derefing |
