This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: libjava failed to build on Linux/x86
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: Richard Henderson <rth at redhat dot com>
- Cc: "Boehm, Hans" <hans_boehm at hp dot com>, "'Per Bothner'" <per at bothner dot com>, "H . J . Lu" <hjl at lucon dot org>, gcc-patches at gcc dot gnu dot org, java at gcc dot gnu dot org
- Date: Fri, 25 Jan 2002 15:35:43 +1300
- Subject: Re: libjava failed to build on Linux/x86
- References: <40700B4C02ABD5119F000090278766443BEF30@hplex1.hpl.hp.com> <20020124170110.B10796@redhat.com>
Richard Henderson wrote:
>On Thu, Jan 24, 2002 at 03:42:32PM -0800, Boehm, Hans wrote:
>
>>This happened once before. IIRC, the conclusion then was that it might be
>>better to change "=m" to "+m" and to remove the "0"(*(addr)) argument.
>>
>
>The two are functionally identical, as "+" is expanded to "="/"0".
>With memories, matching constraints are rarely needed or useful.
>
Strangely, one works while the other does not. The following will fail
without -O but works fine with -O:
#include <stddef.h>
static char
compare_and_swap(volatile size_t *addr, size_t *old, size_t *new_val)
{
char result;
__asm__ __volatile__("lock; cmpxchgl %2, %0; setz %1"
: "=m"(*(addr)), "=q"(result)
: "r" (new_val), "0"(*(addr)), "a"(old) : "memory");
return (char) result;
}
The patch below seems to fix it. Does it look ok?
2002-01-25 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* java/lang/natObject.cc (X86 compare_and_swap): Use +m constraint.
Index: natObject.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natObject.cc,v
retrieving revision 1.20
diff -u -r1.20 natObject.cc
--- natObject.cc 2001/10/31 00:48:16 1.20
+++ natObject.cc 2002/01/25 02:29:20
@@ -327,8 +327,9 @@
{
char result;
__asm__ __volatile__("lock; cmpxchgl %2, %0; setz %1"
- : "=m"(*(addr)), "=q"(result)
- : "r" (new_val), "0"(*(addr)), "a"(old) : "memory");
+ : "+m"(*(addr)), "=q"(result)
+ : "r" (new_val), "a"(old)
+ : "memory");
return (bool) result;
}