Skip to main content

dr_raw_tls_calloc

Function dr_raw_tls_calloc 

Source
pub unsafe extern "C" fn dr_raw_tls_calloc(
    tls_register: *mut reg_id_t,
    offset: *mut uint,
    num_slots: uint,
    alignment: uint,
) -> bool_
Expand description

Allocates \p num_slots contiguous thread-local storage (TLS) slots that can be directly accessed via an offset from \p tls_register. If \p alignment is non-zero, the slots will be aligned to \p alignment. These slots will be initialized to 0 for each new thread. The slot offsets are [\p offset .. \p offset + (num_slots - 1)]. These slots are disjoint from the #dr_spill_slot_t register spill slots and the client tls field (dr_get_tls_field()). Returns whether or not the slots were successfully obtained. The linear address of the TLS base pointed at by \p tls_register can be obtained using #dr_get_dr_segment_base. Raw TLs slots can be read directly using dr_insert_read_raw_tls() and written using dr_insert_write_raw_tls().

Supports passing 0 for \p num_slots, in which case \p tls_register will be written but no other action taken.

\note These slots are useful for thread-shared code caches. With thread-private caches, DR’s memory pools are guaranteed to be reachable via absolute or rip-relative accesses from the code cache and client libraries.

\note These slots are a limited resource. On Windows the slots are shared with the application and reserving even one slot can result in failure to initialize for certain applications. On Linux they are more plentiful and transparent but currently DR limits clients to no more than 64 slots.

\note On Mac OS, TLS slots may not be initialized to zero.