Skip to content

Commit 00ef541

Browse files
committed
Change TLS key type to stack closure
1 parent a57d3e0 commit 00ef541

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/libcore/task.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,9 +1025,9 @@ fn kill_taskgroup(state: taskgroup_inner, me: *rust_task, is_main: bool) {
10251025

10261026
// FIXME (#2912): Work around core-vs-coretest function duplication. Can't use
10271027
// a proper closure because the #[test]s won't understand. Have to fake it.
1028-
unsafe fn taskgroup_key() -> local_data_key<tcb> {
1028+
macro_rules! taskgroup_key {
10291029
// Use a "code pointer" value that will never be a real code pointer.
1030-
unsafe::transmute((-2 as uint, 0u))
1030+
{} => (unsafe::transmute((-2 as uint, 0u)))
10311031
}
10321032

10331033
fn gen_child_taskgroup(linked: bool, supervised: bool)
@@ -1036,7 +1036,8 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
10361036
/*######################################################################*
10371037
* Step 1. Get spawner's taskgroup info.
10381038
*######################################################################*/
1039-
let spawner_group = match unsafe { local_get(spawner, taskgroup_key()) } {
1039+
let spawner_group = match unsafe { local_get(spawner,
1040+
taskgroup_key!()) } {
10401041
none => {
10411042
// Main task, doing first spawn ever. Lazily initialise here.
10421043
let mut members = new_taskset();
@@ -1047,7 +1048,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool)
10471048
// Main task/group has no ancestors, no notifier, etc.
10481049
let group =
10491050
@tcb(spawner, tasks, ancestor_list(none), true, none);
1050-
unsafe { local_set(spawner, taskgroup_key(), group); }
1051+
unsafe { local_set(spawner, taskgroup_key!(), group); }
10511052
group
10521053
}
10531054
some(group) => group
@@ -1162,7 +1163,7 @@ fn spawn_raw(+opts: task_opts, +f: fn~()) {
11621163
if enlist_many(child, child_arc, &mut ancestors) {
11631164
let group = @tcb(child, child_arc, ancestors,
11641165
is_main, notifier);
1165-
unsafe { local_set(child, taskgroup_key(), group); }
1166+
unsafe { local_set(child, taskgroup_key!(), group); }
11661167
// Run the child's body.
11671168
f();
11681169
// TLS cleanup code will exit the taskgroup.
@@ -1261,7 +1262,7 @@ fn spawn_raw(+opts: task_opts, +f: fn~()) {
12611262
*
12621263
* These two cases aside, the interface is safe.
12631264
*/
1264-
type local_data_key<T: owned> = fn@(+@T);
1265+
type local_data_key<T: owned> = &fn(+@T);
12651266

12661267
trait local_data { }
12671268
impl<T: owned> @T: local_data { }

0 commit comments

Comments
 (0)