TLS for Android (and iOS)
David Nadlinger
code at klickverbot.at
Mon Mar 31 07:05:21 PDT 2014
On 31 Mar 2014, at 8:25, Jacob Carlborg wrote:
> You'll just need to add a call to druntime in one of the functions in
> the dyld TLS code. Have a look at:
>
> https://github.com/D-Programming-Language/druntime/blob/master/src/rt/sections_osx.d
More specifically, for the DMD TLS emulation implementation, this is
done in the initTLSRanges() function, which forwards to getTLSBlock().
IIRC, initTLSRanges() is only called for new threads. For the main
thread, the TLS ranges is included in the GC ranges detected in
initSections().
For LDC on OS X, which makes use of the 10.7+ system-level TLS
implementation, the place where this is handled is
https://github.com/ldc-developers/druntime/blob/a08f158618eb5d06c42bd4746b782312e937f6b3/src/rt/sections_ldc.d#L296.
_d_dyld_getTLSRange uses an undocumented dyld API function
(dyld_enumerate_tlv_storage) to get the actual TLS memory range on the
current thread:
https://github.com/ldc-developers/druntime/blob/a08f158618eb5d06c42bd4746b782312e937f6b3/src/ldc/osx_tls.c.
David
More information about the digitalmars-d-ldc
mailing list