// This struct is small, so the linker can allocate a temporary copy on its // stack. It can't be combined with pthread_internal_t because: // - native bridge requires pthread_internal_t to have the same layout across // architectures, and // - On x86, this struct would have to be placed at the front of // pthread_internal_t, moving fields like `tid`. // - We'd like to avoid having a temporary pthread_internal_t object that // needs to be transferred once the final size of static TLS is known. struct bionic_tcb { void* raw_slots_storage[BIONIC_TLS_SLOTS];
// Return a reference to a slot given its TP-relative TLS_SLOT_xxx index. // The thread pointer (i.e. __get_tls()) points at &tls_slot(0). void*& tls_slot(size_t tpindex) { return raw_slots_storage[tpindex - MIN_TLS_SLOT];
}
// Initialize the main thread's final object using its bootstrap object. void copy_from_bootstrap(const bionic_tcb* boot) { // Copy everything. Problematic slots will be reinitialized.
*this = *boot;
}
/* Internally, jemalloc uses a single key for per thread data. */ #define JEMALLOC_PTHREAD_KEY_RESERVED_COUNT 1 #define BIONIC_PTHREAD_KEY_RESERVED_COUNT (LIBC_PTHREAD_KEY_RESERVED_COUNT + JEMALLOC_PTHREAD_KEY_RESERVED_COUNT)
class pthread_key_data_t { public:
uintptr_t seq; // Use uintptr_t just for alignment, as we use pointer below. void* data;
};
// Defines the memory layout for the TLS buffers used by basename() and // dirname() in libgen.h. // // This struct is separated out from bionic TLS to ensure that the libgen // buffers, when mapped, occupy their own set of memory pages distinct // from the primary bionic_tls structure. This helps improve memory usage // if libgen functions are not heavily used, especially on 16KB page size // systems. struct libgen_buffers { char basename_buf[MAXPATHLEN]; char dirname_buf[MAXPATHLEN];
};
// This struct is allocated as static TLS memory (i.e. at a fixed offset // from the thread pointer). struct bionic_tls {
pthread_key_data_t key_data[BIONIC_PTHREAD_KEY_COUNT];
// Initialize the main thread's final object using its bootstrap object. void copy_from_bootstrap(const bionic_tls* boot __attribute__((unused))) { // Nothing in bionic_tls needs to be preserved in the transition to the // final TLS objects, so don't copy anything.
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.