PinCRT
Typedefs | Functions
Thread local storage

Typedefs

typedef VOID(* TLS_DESTRUCTOR) (VOID *)
 
typedef ADDRINT PIN_TLS_INDEX
 

Functions

VOID * OS_TlsGetBaseAddress ()
 
PIN_TLS_INDEX OS_TlsAlloc (TLS_DESTRUCTOR dest)
 
BOOL_T OS_TlsFree (PIN_TLS_INDEX idx)
 
VOID * OS_TlsGetValue (PIN_TLS_INDEX idx)
 
VOID * OS_TlsGetValueForThread (PIN_TLS_INDEX idx, NATIVE_TID ntid)
 
VOID ** OS_TlsGetArrayAddress (void)
 
VOID ** OS_TlsGetArrayAddressForThread (NATIVE_TID ntid)
 
BOOL_T OS_TlsSetValue (PIN_TLS_INDEX idx, VOID *val)
 
BOOL_T OS_TlsSetValueForThread (PIN_TLS_INDEX idx, NATIVE_TID ntid, VOID *val)
 
VOID OS_TlsFreeThreadTls (NATIVE_TID ntid)
 
BOOL_T OS_TlsAddStaticTlsDestructor (TLS_DESTRUCTOR destructor)
 

Detailed Description

Typedef Documentation

◆ PIN_TLS_INDEX

typedef ADDRINT PIN_TLS_INDEX

Type for index inside the dynamic TLS.

◆ TLS_DESTRUCTOR

typedef VOID(* TLS_DESTRUCTOR) (VOID *)

Prototype for TLS value destructor function. The only argument for this function is the value stored in TLS.

Function Documentation

◆ OS_TlsAddStaticTlsDestructor()

BOOL_T OS_TlsAddStaticTlsDestructor ( TLS_DESTRUCTOR  destructor)

Add a destructor for all threads' static TLS. The destructor for static TLS is called on each thread termination, provided that the thread had an allocated static TLS.

Parameters
[in]destructorDestructor function that will be called with the pointer to the fixed TLS when a thread terminates.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsAlloc()

PIN_TLS_INDEX OS_TlsAlloc ( TLS_DESTRUCTOR  dest)

Allocates a new slot in the dynamic TLS.

Parameters
[in]destOptional destructor function that will be called on each value stores in TLS when its corresponding thread dies.
Returns
Index for the newly allocated slot or OS_APIS_INVALID_PIN_TLS_INDEX on error.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsFree()

BOOL_T OS_TlsFree ( PIN_TLS_INDEX  idx)

Free a previously allocated slot in the dynamic TLS.

Parameters
[in]idxThe index to free.
Returns
True on success.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsFreeThreadTls()

VOID OS_TlsFreeThreadTls ( NATIVE_TID  ntid)

Free all resources that are used for a particular thread's TLS. This function is usually called when a thread is about to exit.

Parameters
[in]ntidThe thread ID for which the TLS need to be freed.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsGetArrayAddress()

VOID** OS_TlsGetArrayAddress ( void  )

Return the address of the static TLS for the current thread

Returns
Address of the static TLS for the current threads (which is a VOID* array).
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsGetArrayAddressForThread()

VOID** OS_TlsGetArrayAddressForThread ( NATIVE_TID  ntid)

Return the address of the static TLS for a particular thread

Parameters
[in]ntidThe thread ID for which the static TLS will be retrieved.
Returns
Address of the static TLS for the specified threads (which is a VOID* array).
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsGetBaseAddress()

VOID* OS_TlsGetBaseAddress ( )

Return the base address for the application-wide TLS data structure. The TLS data structure is used to implement a TLS which is not based on segment registers.

Returns
Pointer to the base address of the TLS data structure.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsGetValue()

VOID* OS_TlsGetValue ( PIN_TLS_INDEX  idx)

Get the value associated with a particular index from the current thread's dynamic TLS.

Parameters
[in]idxThe index of the value to get.
Returns
Pointer to the value, or NULL otherwise.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsGetValueForThread()

VOID* OS_TlsGetValueForThread ( PIN_TLS_INDEX  idx,
NATIVE_TID  ntid 
)

Get the value associated with a particular index of a particular thread's dynamic TLS.

Parameters
[in]idxThe index of the value to get.
[in]ntidThe thread ID for which the TLS value will be retrieved.
Returns
Pointer to the value, or NULL otherwise.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsSetValue()

BOOL_T OS_TlsSetValue ( PIN_TLS_INDEX  idx,
VOID *  val 
)

Set the value associated with a particular index in the current thread's dynamic TLS.

Parameters
[in]idxThe index of the value to set.
[in]valThe new value to set.
Returns
True on success.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_TlsSetValueForThread()

BOOL_T OS_TlsSetValueForThread ( PIN_TLS_INDEX  idx,
NATIVE_TID  ntid,
VOID *  val 
)

Set the value associated with a particular index in of a particular thread's dynamic TLS.

Parameters
[in]idxThe index of the value to set.
[in]ntidThe thread ID for which the value will be set in its TLS.
[in]valThe new value to set.
Returns
True on success.
Availability:
O/S: Windows, Linux & macOS*
CPU: All