diff --git a/src/core/sync/mutex.d b/src/core/sync/mutex.d index 605438c38f..a217072ba9 100644 --- a/src/core/sync/mutex.d +++ b/src/core/sync/mutex.d @@ -372,6 +372,9 @@ unittest // by checking that locking is not possible. This assumes // that the underlying implementation is well behaved // and makes the object non-lockable upon destruction. + // For example, Bionic doesn't appear to do so, so this test is + // not run on Android. + version (CRuntime_Bionic) {} else assert(!mtx.tryLock_nothrow()); free(cast(void*) mtx); diff --git a/src/core/thread.d b/src/core/thread.d index 24003b0c79..09c04747e8 100644 --- a/src/core/thread.d +++ b/src/core/thread.d @@ -1972,6 +1972,10 @@ extern (C) void thread_init() // functions to detect the condition and return immediately. Thread.initLocks(); + // The Android VM runtime intercepts SIGUSR1 and apparently doesn't allow + // its signal handler to run, so swap the two signals on Android, since + // thread_resumeHandler does nothing. + version( Android ) thread_setGCSignals(SIGUSR2, SIGUSR1); version( Darwin ) { diff --git a/src/rt/sections_android.d b/src/rt/sections_android.d index de7a4130b6..6193b618cc 100644 --- a/src/rt/sections_android.d +++ b/src/rt/sections_android.d @@ -67,7 +67,7 @@ void initSections() nothrow @nogc auto mend = cast(immutable ModuleInfo**)&__stop_minfo; _sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]); - auto pbeg = cast(void*)&_tls_end; + auto pbeg = cast(void*)&_tlsend; auto pend = cast(void*)&__bss_end__; _sections._gcRanges[0] = pbeg[0 .. pend - pbeg]; } @@ -93,11 +93,12 @@ void scanTLSRanges(void[]* rng, scope void delegate(void* pbeg, void* pend) noth dg(rng.ptr, rng.ptr + rng.length); } -/* NOTE: The Bionic C library does not allow storing thread-local data - * in the normal .tbss/.tdata ELF sections. So instead we roll our - * own by simply putting tls into the non-tls .data/.bss sections - * and using the _tlsstart/_tlsend symbols as delimiters of the tls - * data. +/* NOTE: The Bionic C library ignores thread-local data stored in the normal + * .tbss/.tdata ELF sections, which are marked with the SHF_TLS/STT_TLS + * flags. So instead we roll our own by keeping TLS data in the + * .tdata/.tbss sections but removing the SHF_TLS/STT_TLS flags, and + * access the TLS data using this function and the _tlsstart/_tlsend + * symbols as delimiters. * * This function is called by the code emitted by the compiler. It * is expected to translate an address in the TLS static data to