* Clang powerpc pthread_arch.h patch.
@ 2013-11-24 19:23 Richard Pennington
2013-11-24 22:31 ` Rich Felker
0 siblings, 1 reply; 5+ messages in thread
From: Richard Pennington @ 2013-11-24 19:23 UTC (permalink / raw)
To: musl
I had a problem with clang and __pthread_self() on the powerpc. This is
the patch I applied to work around it.
Index: pthread_arch.h
===================================================================
--- pthread_arch.h (revision 3604)
+++ pthread_arch.h (working copy)
@@ -1,6 +1,11 @@
static inline struct pthread *__pthread_self()
{
+#ifdef __clang__
+ char *tp;
+ __asm__ __volatile__ ("mr %0, 2" : "=r" (tp) : : "2" );
+#else
register char* tp __asm__("r2");
+#endif
return (pthread_t)(tp - 0x7000 - sizeof(struct pthread));
}
-Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Clang powerpc pthread_arch.h patch.
2013-11-24 19:23 Clang powerpc pthread_arch.h patch Richard Pennington
@ 2013-11-24 22:31 ` Rich Felker
2013-11-24 22:46 ` Richard Pennington
0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2013-11-24 22:31 UTC (permalink / raw)
To: musl
On Sun, Nov 24, 2013 at 01:23:44PM -0600, Richard Pennington wrote:
> I had a problem with clang and __pthread_self() on the powerpc. This
> is the patch I applied to work around it.
>
> Index: pthread_arch.h
> ===================================================================
> --- pthread_arch.h (revision 3604)
> +++ pthread_arch.h (working copy)
> @@ -1,6 +1,11 @@
> static inline struct pthread *__pthread_self()
> {
> +#ifdef __clang__
> + char *tp;
> + __asm__ __volatile__ ("mr %0, 2" : "=r" (tp) : : "2" );
> +#else
Why is "2" in the clobberlist? It's just read, not written. In
principle there should be some way to indicate that the asm has hidden
state it reads so that it couldn't be reordered before the initial asm
call that initializes the register, but that would be massive
reordering that's not likely to happen anyway. I'm not sure what the
right way to encode this as a constraint is...
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Clang powerpc pthread_arch.h patch.
2013-11-24 22:31 ` Rich Felker
@ 2013-11-24 22:46 ` Richard Pennington
2013-12-02 7:48 ` Rich Felker
0 siblings, 1 reply; 5+ messages in thread
From: Richard Pennington @ 2013-11-24 22:46 UTC (permalink / raw)
To: musl
On 11/24/2013 04:31 PM, Rich Felker wrote:
> On Sun, Nov 24, 2013 at 01:23:44PM -0600, Richard Pennington wrote:
>> I had a problem with clang and __pthread_self() on the powerpc. This
>> is the patch I applied to work around it.
>>
>> Index: pthread_arch.h
>> ===================================================================
>> --- pthread_arch.h (revision 3604)
>> +++ pthread_arch.h (working copy)
>> @@ -1,6 +1,11 @@
>> static inline struct pthread *__pthread_self()
>> {
>> +#ifdef __clang__
>> + char *tp;
>> + __asm__ __volatile__ ("mr %0, 2" : "=r" (tp) : : "2" );
>> +#else
> Why is "2" in the clobberlist? It's just read, not written. In
> principle there should be some way to indicate that the asm has hidden
> state it reads so that it couldn't be reordered before the initial asm
> call that initializes the register, but that would be massive
> reordering that's not likely to happen anyway. I'm not sure what the
> right way to encode this as a constraint is...
>
> Rich
Hi Rich,
You're right about the clobber list. Not that it matters much in this
case I think.
-Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Clang powerpc pthread_arch.h patch.
2013-11-24 22:46 ` Richard Pennington
@ 2013-12-02 7:48 ` Rich Felker
2013-12-02 12:50 ` Richard Pennington
0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2013-12-02 7:48 UTC (permalink / raw)
To: musl
On Sun, Nov 24, 2013 at 04:46:48PM -0600, Richard Pennington wrote:
> On 11/24/2013 04:31 PM, Rich Felker wrote:
> >On Sun, Nov 24, 2013 at 01:23:44PM -0600, Richard Pennington wrote:
> >>I had a problem with clang and __pthread_self() on the powerpc. This
> >>is the patch I applied to work around it.
> >>
> >>Index: pthread_arch.h
> >>===================================================================
> >>--- pthread_arch.h (revision 3604)
> >>+++ pthread_arch.h (working copy)
> >>@@ -1,6 +1,11 @@
> >> static inline struct pthread *__pthread_self()
> >> {
> >>+#ifdef __clang__
> >>+ char *tp;
> >>+ __asm__ __volatile__ ("mr %0, 2" : "=r" (tp) : : "2" );
> >>+#else
> >Why is "2" in the clobberlist? It's just read, not written. In
> >principle there should be some way to indicate that the asm has hidden
> >state it reads so that it couldn't be reordered before the initial asm
> >call that initializes the register, but that would be massive
> >reordering that's not likely to happen anyway. I'm not sure what the
> >right way to encode this as a constraint is...
> >
> >Rich
> Hi Rich,
>
> You're right about the clobber list. Not that it matters much in
> this case I think.
Committed a fix based on your patch; let me know if you still have
problems with it.
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Clang powerpc pthread_arch.h patch.
2013-12-02 7:48 ` Rich Felker
@ 2013-12-02 12:50 ` Richard Pennington
0 siblings, 0 replies; 5+ messages in thread
From: Richard Pennington @ 2013-12-02 12:50 UTC (permalink / raw)
To: musl; +Cc: Rich Felker
On 12/02/2013 01:48 AM, Rich Felker wrote:
> On Sun, Nov 24, 2013 at 04:46:48PM -0600, Richard Pennington wrote:
>> On 11/24/2013 04:31 PM, Rich Felker wrote:
>>> On Sun, Nov 24, 2013 at 01:23:44PM -0600, Richard Pennington wrote:
>>>> I had a problem with clang and __pthread_self() on the powerpc. This
>>>> is the patch I applied to work around it.
>>>>
>>>> Index: pthread_arch.h
>>>> ===================================================================
>>>> --- pthread_arch.h (revision 3604)
>>>> +++ pthread_arch.h (working copy)
>>>> @@ -1,6 +1,11 @@
>>>> static inline struct pthread *__pthread_self()
>>>> {
>>>> +#ifdef __clang__
>>>> + char *tp;
>>>> + __asm__ __volatile__ ("mr %0, 2" : "=r" (tp) : : "2" );
>>>> +#else
>>> Why is "2" in the clobberlist? It's just read, not written. In
>>> principle there should be some way to indicate that the asm has hidden
>>> state it reads so that it couldn't be reordered before the initial asm
>>> call that initializes the register, but that would be massive
>>> reordering that's not likely to happen anyway. I'm not sure what the
>>> right way to encode this as a constraint is...
>>>
>>> Rich
>> Hi Rich,
>>
>> You're right about the clobber list. Not that it matters much in
>> this case I think.
> Committed a fix based on your patch; let me know if you still have
> problems with it.
>
> Rich
>
>
Thanks Rich. It has been working fine here.
-Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-02 12:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-24 19:23 Clang powerpc pthread_arch.h patch Richard Pennington
2013-11-24 22:31 ` Rich Felker
2013-11-24 22:46 ` Richard Pennington
2013-12-02 7:48 ` Rich Felker
2013-12-02 12:50 ` Richard Pennington
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).