<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>it is here:</div><div><br></div><div><a href="http://www.opensource.apple.com/source/Libc/Libc-391/pthreads/">http://www.opensource.apple.com/source/Libc/Libc-391/pthreads/</a></div><div><br></div><div>look into pthread_internals.h</div><div><br></div><div>there is a function </div><div><br></div><div><pre><font face="UICTFontTextStyleBody"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);">inline <span class="enscript-type" style="font-weight: bold;">static</span> pthread_t <span class="enscript-function-name" style="font-weight: bold;">__attribute__</span>((__pure__))
<span class="enscript-function-name" style="font-weight: bold;">_pthread_self_direct</span>(<span class="enscript-type" style="font-weight: bold;">void</span>)
{
       pthread_t ret;
#<span class="enscript-reference" style="font-weight: bold;">if</span> <span class="enscript-reference" style="font-weight: bold;">defined</span>(<span class="enscript-variable-name" style="font-weight: bold;">__i386__</span>)
       asm(<span class="enscript-string" style="font-weight: bold;">"movl %%gs:%P1, %0"</span> : <span class="enscript-string" style="font-weight: bold;">"=r"</span> (ret) : <span class="enscript-string" style="font-weight: bold;">"i"</span> (offsetof(<span class="enscript-type" style="font-weight: bold;">struct</span> _pthread, tsd[0])));
#<span class="enscript-reference" style="font-weight: bold;">elif</span> <span class="enscript-reference" style="font-weight: bold;">defined</span>(<span class="enscript-variable-name" style="font-weight: bold;">__ppc64__</span>)
        <span class="enscript-type" style="font-weight: bold;">register</span> <span class="enscript-type" style="font-weight: bold;">const</span> pthread_t __pthread_self asm (<span class="enscript-string" style="font-weight: bold;">"r13"</span>);
        ret = __pthread_self;
#<span class="enscript-reference" style="font-weight: bold;">endif</span>
       <span class="enscript-keyword" style="font-weight: bold;">return</span> ret;
}</span></font></pre><pre><font face="UICTFontTextStyleBody"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);"><br></span></font></pre><pre><font face="UICTFontTextStyleBody"><span style="white-space: normal; background-color: rgba(255, 255, 255, 0);">i think this is what you are looking for.</span></font></pre><br>Von meinem iPad gesendet</div><div><br>Am 09.01.2015 um 20:49 schrieb <a href="mailto:cdavis5x@gmail.com">cdavis5x@gmail.com</a>:<br><br></div><blockquote type="cite"><div><span></span><br><blockquote type="cite"><span>On Jan 9, 2015, at 12:18 PM, Ken Thomases <<a href="mailto:ken@codeweavers.com">ken@codeweavers.com</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>On Jan 9, 2015, at 6:01 AM, Maarten Lankhorst <<a href="mailto:maarten@mblankhorst.nl">maarten@mblankhorst.nl</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>On 09-01-15 06:11, Ken Thomases wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>The Mac driver crashes in a 64-bit build for reasons I haven't investigated, so you have to use the X11 driver.  You can do this using WINEDLLOVERRIDES="winemac.drv=d" or by setting this in the registry after the prefix is created:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Doesn't win64 and mac64 both use the %gs register for TLS?</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Yes, but this incarnation of Wine64 does not attempt to directly manipulate %gs.  My understanding is that it can't without a syscall, anyway.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>Could that be related to the crash?</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>It could be, but I don't think it is in this case.</span><br></blockquote><span>Certainly not since both our patches implement NtCurrentTeb() to use a pthread key to store the Thread Environment Block pointer instead of stuffing the pointer into the GSBASE MSR--which we really can’t do (as Ken said) without special support from the system. In any case, every part of Wine that accesses the TEB does so by calling NtCurrentTeb().</span><br><span></span><br><blockquote type="cite"><span> We're hoping that few actually do use %gs and, so, that they won't break.  We can't fix the problem</span><br></blockquote><span>I’m not so sure about that, though I’m still waiting for Apple to release the source to their pthread stuff: in 10.9, they pulled it out of the kernel and into a kext, presumably so someone like me could replace it without replacing the whole kernel and use %fs instead of %gs for the pthread struct. (I can’t imagine any other reason they’d do that.) Then they closed my radar and told me they gave up on it, so I’m not holding my breath. I wonder how many pieces of the system other than the pthread kext and pthread library depend on %gs holding the current pthread pointer…</span><br><blockquote type="cite"><span>but maybe it won't actually matter much in the real world.  That's the purpose of this experiment: to find out if that's so.</span><br></blockquote><span>Maybe it won’t, but my understanding is that copy protection software likes to reach directly into the TEB. That’s why we set up %fs to point to it on i386, and try to set up %gs on x86-64. Even if they called NtCurrentTeb() to get the TEB pointer, they won’t work here, because NtCurrentTeb() (in Microsoft’s headers and without either of our patches) dereferences the %gs segment register to get it. But hopefully you’re right, and such copy protection software is rare.</span><br><span></span><br><span>Chip</span><br><span></span><br></div></blockquote></div></body></html>