Struct miri::shims::tls::TlsData

source ·
pub struct TlsData<'tcx> {
    next_key: u128,
    keys: BTreeMap<u128, TlsEntry<'tcx>>,
    macos_thread_dtors: BTreeMap<ThreadId, (Instance<'tcx>, Scalar<Provenance>)>,
}

Fields§

§next_key: u128

The Key to use for the next thread-local allocation.

§keys: BTreeMap<u128, TlsEntry<'tcx>>

pthreads-style thread-local storage.

§macos_thread_dtors: BTreeMap<ThreadId, (Instance<'tcx>, Scalar<Provenance>)>

A single per thread destructor of the thread local storage (that’s how things work on macOS) with a data argument.

Implementations§

Generate a new TLS key with the given destructor. max_size determines the integer size the key has to fit in.

Set the thread wide destructor of the thread local storage for the given thread. This function is used to implement _tlv_atexit shim on MacOS.

Thread wide dtors are available only on MacOS. There is one destructor per thread as can be guessed from the following comment in the _tlv_atexit implementation:

NOTE: this does not need locks because it only operates on current thread data

Returns a dtor, its argument and its index, if one is supposed to run. key is the last dtors that was run; we return the next one after that.

An optional destructor function may be associated with each key value. At thread exit, if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument. The order of destructor calls is unspecified if more than one destructor exists for a thread when it exits.

If, after all the destructors have been called for all non-NULL values with associated destructors, there are still some non-NULL values with associated destructors, then the process is repeated. If, after at least {PTHREAD_DESTRUCTOR_ITERATIONS} iterations of destructor calls for outstanding non-NULL values, there are still some non-NULL values with associated destructors, implementations may stop calling destructors, or they may continue calling destructors until no non-NULL values with associated destructors exist, even though this might result in an infinite loop.

Delete all TLS entries for the given thread. This function should be called after all TLS destructors have already finished.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 64 bytes