Merge "Fix LP32 large pid detection."
am: d330bbbac8
Change-Id: I98bf5b2e82963998505ed56445931de3c00319e1
This commit is contained in:
commit
be443611da
2 changed files with 19 additions and 5 deletions
|
@ -57,3 +57,14 @@ On 32-bit Android, `time_t` is 32-bit. The header `<time64.h>` and type
|
|||
Android all use the 32-bit `time_t`.
|
||||
|
||||
In the 64-bit ABI, `time_t` is 64-bit.
|
||||
|
||||
`pthread_mutex_t` is too small for large pids
|
||||
---------------------------------------------
|
||||
|
||||
This doesn't generally affect Android devices, because on devices
|
||||
`/proc/sys/kernel/pid_max` is usually too small to hit the 16-bit limit,
|
||||
but 32-bit bionic's `pthread_mutex` is a total of 32 bits, leaving just
|
||||
16 bits for the owner thread id. This means bionic isn't able to support
|
||||
mutexes for tids that don't fit in 16 bits. This typically manifests as
|
||||
a hang in `pthread_mutex_lock` if the libc startup code doesn't detect
|
||||
this condition and abort.
|
||||
|
|
|
@ -77,11 +77,14 @@ static void __libc_preinit_impl(KernelArgumentBlock& args) {
|
|||
netdClientInit();
|
||||
}
|
||||
|
||||
// We flag the __libc_preinit function as a constructor to ensure
|
||||
// that its address is listed in libc.so's .init_array section.
|
||||
// This ensures that the function is called by the dynamic linker
|
||||
// as soon as the shared library is loaded.
|
||||
__attribute__((constructor)) static void __libc_preinit() {
|
||||
// We flag the __libc_preinit function as a constructor to ensure that
|
||||
// its address is listed in libc.so's .init_array section.
|
||||
// This ensures that the function is called by the dynamic linker as
|
||||
// soon as the shared library is loaded.
|
||||
// We give this constructor priority 1 because we want libc's constructor
|
||||
// to run before any others (such as the jemalloc constructor), and lower
|
||||
// is better (http://b/68046352).
|
||||
__attribute__((constructor(1))) static void __libc_preinit() {
|
||||
// Read the kernel argument block pointer from TLS.
|
||||
void** tls = __get_tls();
|
||||
KernelArgumentBlock** args_slot = &reinterpret_cast<KernelArgumentBlock**>(tls)[TLS_SLOT_BIONIC_PREINIT];
|
||||
|
|
Loading…
Reference in a new issue