libjava failed to build on Linux/x86
Bryce McKinlay
bryce@waitaki.otago.ac.nz
Thu Jan 24 18:35:00 GMT 2002
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;
}
More information about the Java
mailing list