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