From 9fd2ac7428afa4f414f32b8b4876ca817ee85f16 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 14 Jul 2013 01:43:31 -0700 Subject: Make TLS keys actually take up space If the TLS key is 0-sized, then the linux linker is apparently smart enough to put everything at the same pointer. OSX on the other hand, will reserve some space for all of them. To get around this, the TLS key now actuall consumes space to ensure that it gets a unique pointer --- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/expand.rs | 8 ++++++-- src/libsyntax/parse/token.rs | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 0b876bf1f81..a1d209d19ac 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -695,7 +695,7 @@ pub fn new_sctable_internal() -> SCTable { // fetch the SCTable from TLS, create one if it doesn't yet exist. pub fn get_sctable() -> @mut SCTable { #[cfg(not(stage0))] - static sctable_key: local_data::Key<@@mut SCTable> = &[]; + static sctable_key: local_data::Key<@@mut SCTable> = &local_data::Key; #[cfg(stage0)] fn sctable_key(_: @@mut SCTable) {} match local_data::get(sctable_key, |k| k.map(|&k| *k)) { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 4fbc3862848..b45cde6a8e3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -580,7 +580,9 @@ pub fn core_macros() -> @str { pub mod $c { #[allow(non_uppercase_statics)]; - static key: &'static [@::std::condition::Handler<$in, $out>] = &[]; + static key: ::std::local_data::Key< + @::std::condition::Handler<$in, $out>> = + &::std::local_data::Key; pub static cond : ::std::condition::Condition<$in,$out> = @@ -596,7 +598,9 @@ pub fn core_macros() -> @str { // FIXME (#6009): remove mod's `pub` below once variant above lands. pub mod $c { #[allow(non_uppercase_statics)]; - static key: &'static [@::std::condition::Handler<$in, $out>] = &[]; + static key: ::std::local_data::Key< + @::std::condition::Handler<$in, $out>> = + &::std::local_data::Key; pub static cond : ::std::condition::Condition<$in,$out> = diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 8737e571399..01860c3ae99 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -485,7 +485,8 @@ fn mk_fresh_ident_interner() -> @ident_interner { // fresh one. pub fn get_ident_interner() -> @ident_interner { #[cfg(not(stage0))] - static key: local_data::Key<@@::parse::token::ident_interner> = &[]; + static key: local_data::Key<@@::parse::token::ident_interner> = + &local_data::Key; #[cfg(stage0)] fn key(_: @@::parse::token::ident_interner) {} match local_data::get(key, |k| k.map(|&k| *k)) { -- cgit 1.4.1-3-g733a5