* An error of gcc-ss-20030303
@ 2003-04-23 10:36 Jie Zhang
2003-04-23 22:27 ` tm_gccmail
2003-04-23 22:43 ` Richard Henderson
0 siblings, 2 replies; 4+ messages in thread
From: Jie Zhang @ 2003-04-23 10:36 UTC (permalink / raw)
To: gcc
The following code is copied from spinlock.c in uClibc (after
preprocessing and 'inline' after static removed):
static void __pthread_release(int * spinlock)
{
asm ("" : : : "memory");
*spinlock = 0;
__asm __volatile ("" : "=m" (*spinlock) : "0" (*spinlock));
}
When compiled using gcc-3.0.2, no error is reported. But gcc-3.2 and
gcc-ss-20030303 report the follwing error:
t.c: In function `__pthread_release':
t.c:5: inconsistent operand constraints in an `asm'
I dump the rtl using -dr and find that gcc-3.0.2 uses a pseudo register
to hold the address of 'spinlock' and the output operand and input
operand of __asm__ use the same register. But gcc-ss-20030303 uses two
pseudo registers for the output operand and input operand of __asm__
respectively, both pseudo registers hold the same value -- the address
of 'spinlock'. Then when checking the constraints, gcc reports the error.
Is it a bug of gcc-3.2.x and gcc-3.3? Or the above __asm__ usage is
wrong in gcc-3.2.x and gcc-3.3? I think gcc-3.0.2 is right?
- Jie
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: An error of gcc-ss-20030303
2003-04-23 10:36 An error of gcc-ss-20030303 Jie Zhang
@ 2003-04-23 22:27 ` tm_gccmail
2003-04-23 22:43 ` Richard Henderson
1 sibling, 0 replies; 4+ messages in thread
From: tm_gccmail @ 2003-04-23 22:27 UTC (permalink / raw)
To: Jie Zhang; +Cc: gcc
On Wed, 23 Apr 2003, Jie Zhang wrote:
> The following code is copied from spinlock.c in uClibc (after
> preprocessing and 'inline' after static removed):
>
> static void __pthread_release(int * spinlock)
> {
> asm ("" : : : "memory");
> *spinlock = 0;
> __asm __volatile ("" : "=m" (*spinlock) : "0" (*spinlock));
> }
>
Why not use a pointer to a volatile int?
Toshi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: An error of gcc-ss-20030303
2003-04-23 10:36 An error of gcc-ss-20030303 Jie Zhang
2003-04-23 22:27 ` tm_gccmail
@ 2003-04-23 22:43 ` Richard Henderson
2003-04-24 5:42 ` Jie Zhang
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2003-04-23 22:43 UTC (permalink / raw)
To: Jie Zhang; +Cc: gcc
On Wed, Apr 23, 2003 at 03:41:45PM +0800, Jie Zhang wrote:
> __asm __volatile ("" : "=m" (*spinlock) : "0" (*spinlock));
Don't use matching constraints on memories.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: An error of gcc-ss-20030303
2003-04-23 22:43 ` Richard Henderson
@ 2003-04-24 5:42 ` Jie Zhang
0 siblings, 0 replies; 4+ messages in thread
From: Jie Zhang @ 2003-04-24 5:42 UTC (permalink / raw)
To: gcc
Richard Henderson wrote:
> On Wed, Apr 23, 2003 at 03:41:45PM +0800, Jie Zhang wrote:
>
>
>> __asm __volatile ("" : "=m" (*spinlock) : "0" (*spinlock));
>>
>
>
> Don't use matching constraints on memories.
>
>
The problem is solved by changing this line into
__asm __volatile ("" : "+m" (*spinlock));
I should have read the document more carefully :-P
Thanks all!
- Jie
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-24 2:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23 10:36 An error of gcc-ss-20030303 Jie Zhang
2003-04-23 22:27 ` tm_gccmail
2003-04-23 22:43 ` Richard Henderson
2003-04-24 5:42 ` Jie Zhang
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 read-only IMAP folder(s) and NNTP newsgroup(s).