[PATCH 3/3] ntdll: For Mac 64-bit, poke NtCurrentTeb()->ThreadLocalStoragePointer to the corresponding offset from %gs.
Sebastian Lackner
sebastian at fds-team.de
Wed Jul 27 12:53:21 CDT 2016
On 27.07.2016 19:42, Ken Thomases wrote:
>>
>> Hm, I see. Do you know if the offset really changed in the past?
>
> Yes, it has changed in the past.
>
>> I am asking
>> because I assume the bruteforcing is an attempt to make the code more reliable,
>> however on the other hand you still make the assumption that pthread keys
>> directly correspond to indices into the %gs segment, which could also change.
>
> Well, we made various proposals to Apple to get a more comprehensive, less kludgy fix and they were rejected because of binary compatibility. Basically, they were unwilling to change how pthread_getspecific() works. Mono depends on it, for example. So, it seems pretty reliable.
>
>> A check that it matches expected behavior is probably sufficient.
>>
>> Besides that, if the gsbase cannot be located, it probably would be preferred
>> to skip this code on following attempts.
>
> It already does that. gsbase_offset is static. It will only be negative on the first call.
Sorry, I missed the "gsbase_offset = 0;" call. You are probably right that there
is not much to improve unless Apple offers a better interface.
I have only two suggestions:
- gsbase_offset == 0 (key == i) could also be valid, so it would be useful to distinguish this case.
- the logic could be moved to a helper function, for example using the init once mechanism
>
> -Ken
>
More information about the wine-devel
mailing list