@@ -10,45 +10,14 @@ const USIZE_BITS: usize = 64;
10
10
const TLS_KEYS : usize = 128 ; // Same as POSIX minimum
11
11
const TLS_KEYS_BITSET_SIZE : usize = ( TLS_KEYS + ( USIZE_BITS - 1 ) ) / USIZE_BITS ;
12
12
13
+ #[ cfg( not( test) ) ]
13
14
static TLS_KEY_IN_USE : SyncBitset = SYNC_BITSET_INIT ;
14
15
macro_rules! dup {
15
16
( ( * $( $exp: tt) * ) $( $val: tt) * ) => ( dup!( ( $( $exp) * ) $( $val) * $( $val) * ) ) ;
16
17
( ( ) $( $val: tt) * ) => ( [ $( $val) ,* ] )
17
18
}
18
- static TLS_DESTRUCTOR : [ AtomicUsize ; TLS_KEYS ] = [
19
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
20
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
21
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
22
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
23
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
24
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
25
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
26
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
27
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
28
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
29
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
30
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
31
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
32
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
33
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
34
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
35
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
36
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
37
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
38
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
39
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
40
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
41
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
42
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
43
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
44
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
45
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
46
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
47
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
48
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
49
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
50
- AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) , AtomicUsize :: new ( 0 ) ,
51
- ] ;
19
+ #[ cfg( not( test) ) ]
20
+ static TLS_DESTRUCTOR : [ AtomicUsize ; TLS_KEYS ] = dup ! ( ( * * * * * * * ) ( AtomicUsize :: new( 0 ) ) ) ;
52
21
53
22
extern "C" {
54
23
fn get_tls_ptr ( ) -> * const u8 ;
@@ -86,6 +55,7 @@ pub struct ActiveTls<'a> {
86
55
tls : & ' a Tls
87
56
}
88
57
58
+ #[ cfg( not( test) ) ]
89
59
impl < ' a > Drop for ActiveTls < ' a > {
90
60
fn drop ( & mut self ) {
91
61
let value_with_destructor = |key : usize | {
@@ -127,7 +97,10 @@ impl Tls {
127
97
unsafe fn current < ' a > ( ) -> & ' a Tls {
128
98
& * ( get_tls_ptr ( ) as * const Tls )
129
99
}
100
+ }
130
101
102
+ #[ cfg( not( test) ) ]
103
+ impl Tls {
131
104
pub fn create ( dtor : Option < unsafe extern fn ( * mut u8 ) > ) -> Key {
132
105
let index = TLS_KEY_IN_USE . set ( ) . expect ( "TLS limit exceeded" ) ;
133
106
TLS_DESTRUCTOR [ index] . store ( dtor. map_or ( 0 , |f| f as usize ) , Ordering :: Relaxed ) ;
@@ -151,6 +124,25 @@ impl Tls {
151
124
}
152
125
}
153
126
127
+ #[ cfg( test) ]
128
+ impl Tls {
129
+ pub fn create ( _dtor : Option < unsafe extern fn ( * mut u8 ) > ) -> Key {
130
+ rtabort ! ( "Calling cfg-test version of thread-local storage internals" )
131
+ }
132
+
133
+ pub fn set ( _key : Key , _value : * mut u8 ) {
134
+ rtabort ! ( "Calling cfg-test version of thread-local storage internals" )
135
+ }
136
+
137
+ pub fn get ( _key : Key ) -> * mut u8 {
138
+ rtabort ! ( "Calling cfg-test version of thread-local storage internals" )
139
+ }
140
+
141
+ pub fn destroy ( _key : Key ) {
142
+ rtabort ! ( "Calling cfg-test version of thread-local storage internals" )
143
+ }
144
+ }
145
+
154
146
mod sync_bitset {
155
147
use sync:: atomic:: { AtomicUsize , Ordering } ;
156
148
use iter:: { Enumerate , Peekable } ;
0 commit comments