iOS progress

Dan Olson via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Tue Feb 17 10:10:39 PST 2015


Jacob Carlborg <doob at me.com> writes:

> On 2015-02-16 22:38, Dan Olson wrote:
>
>> I think directly using tlv_get_addr may lead to weird errors if thread
>> local descriptors have not been initialized by runtime. With
>> __tls_get_addr there is a check that descriptor is initialized, and if I
>> get around to changing llvm to call thunk directly, then uninitialized
>> descriptor will have thunk set to _tlv_bootstrap and code will cleanly
>> abort.
>
> I see that you used a constructor to initialize everything. Won't that
> be enough to know that tlv_get_addr is correctly initialized? No D
> code will be able to run before that, as far as I understand.

Actually I forgot that I switched to using a constructor. My original
solution had tlv_initializer called by D runtime but I decided to get
all Apple code out of druntime before I commited to git. You are
correct, descriptors should always be initialized. Only D code called in
__attribute__((constructor)) functions might run into problems, but that
would be unusual.

> On OS X tlv_initializer will be called by _dyld_initializer which is
> called by libSystem, if I understand the source code of dyld
> correctly. This doesn't happen on iOS?

iOS has a stub tlv_initializer() so nothing gets done automatically. I
had to change threadLocalVariables.c to include working tlv_initializer
for __arm__.


More information about the digitalmars-d-ldc mailing list