@@ -9,6 +9,7 @@ pub use paste::paste;
9
9
//==============================================================================
10
10
11
11
/// Wrapper around an `extern` `static` ref to avoid requiring `unsafe` for imported globals.
12
+ #[ doc( hidden) ]
12
13
pub struct TrustedExtern < T : ' static > ( pub & ' static T ) ;
13
14
14
15
use std:: ops:: Deref ;
@@ -27,6 +28,7 @@ impl<T> Deref for TrustedExtern<T> {
27
28
/// value (since its value is only known as load time, not compile time).
28
29
///
29
30
/// As a result, imported thread-locals have an additional layer of indirection.
31
+ #[ doc( hidden) ]
30
32
pub struct TrustedExternDouble < T : ' static > ( pub & ' static & ' static T ) ;
31
33
32
34
impl < T > Deref for TrustedExternDouble < T > {
@@ -41,6 +43,22 @@ impl<T> Deref for TrustedExternDouble<T> {
41
43
// Thread-locals
42
44
//==============================================================================
43
45
46
+ /// Imports or exports a thread-local, depending on the enabled cargo features.
47
+ ///
48
+ /// Usage:
49
+ ///
50
+ /// ```ignore
51
+ /// use rubicon::process_local;
52
+ ///
53
+ /// process_local! {
54
+ /// static FOO: u32 = 42;
55
+ /// }
56
+ /// ```
57
+ ///
58
+ /// This will import `FOO` if the `import-globals` feature is enabled, and export it if the
59
+ /// `export-globals` feature is enabled.
60
+ ///
61
+ /// If neither feature is enabled, this will expand to the static declaration itself.
44
62
#[ cfg( not( any( feature = "import-globals" , feature = "export-globals" ) ) ) ]
45
63
#[ macro_export]
46
64
macro_rules! thread_local {
@@ -113,6 +131,23 @@ macro_rules! thread_local_inner {
113
131
// Process-locals (statics)
114
132
//==============================================================================
115
133
134
+ /// Imports or exports a `static`, depending on the enabled cargo features.
135
+ ///
136
+ /// Usage:
137
+ ///
138
+ /// ```ignore
139
+ /// rubicon::process_local! {
140
+ /// static FOO: u32 = 42;
141
+ /// }
142
+ /// ```
143
+ ///
144
+ /// This will import `FOO` if the `import-globals` feature is enabled, and export it if the
145
+ /// `export-globals` feature is enabled.
146
+ ///
147
+ /// If neither feature is enabled, this will expand to the static declaration itself.
148
+ ///
149
+ /// This macro supports multiple declarations, along with `static mut` declarations
150
+ /// (which have a slightly different expansion).
116
151
#[ cfg( all( not( feature = "import-globals" ) , not( feature = "export-globals" ) ) ) ]
117
152
#[ macro_export]
118
153
macro_rules! process_local {
@@ -217,8 +252,7 @@ macro_rules! process_local_inner_mut {
217
252
#[ used]
218
253
static SHARED_OBJECT_ID_REF : u64 = 0 ;
219
254
220
- /// Returns a unique identifier for the current shared object
221
- /// (based on the address of the `SHARED_OBJECT_ID_REF` static).
255
+ /// Returns a unique identifier for the current shared object.
222
256
pub fn shared_object_id ( ) -> u64 {
223
257
& SHARED_OBJECT_ID_REF as * const _ as u64
224
258
}
@@ -239,6 +273,8 @@ pub static RUBICON_MODE: &str = "N"; // "normal"
239
273
compile_error ! ( "The features \" import-globals\" and \" export-globals\" are mutually exclusive" ) ;
240
274
241
275
/// A `u64` whose 24-bit ANSI color is determined by its value.
276
+ ///
277
+ /// Used by the [`soprintln`] macro to visually distinguish shared objects and threads.
242
278
pub struct Beacon < ' a > {
243
279
fg : ( u8 , u8 , u8 ) ,
244
280
bg : ( u8 , u8 , u8 ) ,
0 commit comments