2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2016-02-22 05:12:14 -06:00
|
|
|
// ignore-windows
|
2016-02-20 06:38:30 -06:00
|
|
|
// aux-build:thread-local-extern-static.rs
|
|
|
|
|
2017-08-08 10:22:51 -05:00
|
|
|
#![feature(cfg_target_thread_local, thread_local)]
|
2016-02-19 15:09:47 -06:00
|
|
|
|
2017-08-08 10:22:51 -05:00
|
|
|
#[cfg(target_thread_local)]
|
2016-01-12 14:02:06 -06:00
|
|
|
extern crate thread_local_extern_static;
|
|
|
|
|
2017-08-08 10:22:51 -05:00
|
|
|
#[cfg(target_thread_local)]
|
|
|
|
use std::cell::Cell;
|
|
|
|
|
|
|
|
#[cfg(target_thread_local)]
|
2020-09-01 16:12:52 -05:00
|
|
|
extern "C" {
|
2017-08-08 10:22:51 -05:00
|
|
|
#[thread_local]
|
|
|
|
static FOO: Cell<u32>;
|
2016-01-12 14:02:06 -06:00
|
|
|
}
|
|
|
|
|
2017-08-08 10:22:51 -05:00
|
|
|
#[cfg(target_thread_local)]
|
2016-01-12 14:02:06 -06:00
|
|
|
fn main() {
|
2017-07-07 19:01:11 -05:00
|
|
|
unsafe {
|
2017-08-08 10:22:51 -05:00
|
|
|
assert_eq!(FOO.get(), 3);
|
2017-07-07 19:01:11 -05:00
|
|
|
}
|
2016-01-12 14:02:06 -06:00
|
|
|
}
|
2017-08-08 10:22:51 -05:00
|
|
|
|
|
|
|
#[cfg(not(target_thread_local))]
|
|
|
|
fn main() {}
|