ntdll: On Mac, use the Mach API as preferred approach to get a thread's GS.base.

The previous technique was a gross hack peeking at the internals of the pthreads
implementation.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2019-09-12 20:52:31 -05:00 committed by Alexandre Julliard
parent 06754af1e5
commit 84760a8fb2
1 changed files with 9 additions and 0 deletions

View File

@ -3204,9 +3204,18 @@ void signal_free_thread( TEB *teb )
*/
static void *mac_thread_gsbase(void)
{
struct thread_identifier_info tiinfo;
unsigned int info_count = THREAD_IDENTIFIER_INFO_COUNT;
static int gsbase_offset = -1;
void *ret;
kern_return_t kr = thread_info(mach_thread_self(), THREAD_IDENTIFIER_INFO, (thread_identifier_info_t) &tiinfo, &info_count);
if (kr == KERN_SUCCESS)
{
TRACE("pthread_self() %p thread ID %lx gsbase %lx\n", pthread_self(), tiinfo.thread_id, tiinfo.thread_handle);
return (void*)tiinfo.thread_handle;
}
if (gsbase_offset < 0)
{
/* Search for the array of TLS slots within the pthread data structure.