diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index c16a006c96b9614852af9b23037f7ead3024337d..517aea5b2c41f319e1cf34d5316e199d25c8c423 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-16  Andrew Haley  <aph@redhat.com>
+
+	* sysdep/x86-64/locks.h: Don't use in/out memory constraints.
+	* sysdep/i386/locks.h: Likewise.
+
 2004-01-16  Fernando Nasser  <fnasser@redhat.com>
 
 	* java/awt/EventDispatchThread.java (run): Stop running when
diff --git a/libjava/sysdep/i386/locks.h b/libjava/sysdep/i386/locks.h
index a9501ae99b23729584bef89a2fdd62f99bbe1a3d..0e2cd797148afaeeef72ecbc21af883fdcc20df5 100644
--- a/libjava/sysdep/i386/locks.h
+++ b/libjava/sysdep/i386/locks.h
@@ -25,8 +25,8 @@ compare_and_swap(volatile obj_addr_t *addr,
 {
   char result;
   __asm__ __volatile__("lock; cmpxchgl %2, %0; setz %1"
-	      : "+m"(*(addr)), "=q"(result)
-	      : "r" (new_val), "a"(old)
+	      : "=m"(*addr), "=q"(result)
+	      : "r" (new_val), "a"(old), "m"(*addr)
 	      : "memory");
   return (bool) result;
 }
diff --git a/libjava/sysdep/x86-64/locks.h b/libjava/sysdep/x86-64/locks.h
index bad6de6dc6f6043de240146771be8d7653b429a8..7fb9bbba0bf6fe12bd3bdbf573fcdcdef88484ee 100644
--- a/libjava/sysdep/x86-64/locks.h
+++ b/libjava/sysdep/x86-64/locks.h
@@ -26,13 +26,13 @@ compare_and_swap(volatile obj_addr_t *addr, obj_addr_t old, obj_addr_t new_val)
   char result;
 #ifdef __x86_64__
   __asm__ __volatile__("lock; cmpxchgq %2, %0; setz %1"
-	      : "+m"(*(addr)), "=q"(result)
-	      : "r" (new_val), "a"(old)
+	      : "=m"(*(addr)), "=q"(result)
+	      : "r" (new_val), "a"(old), "m"(*addr)
 	      : "memory");
 #else
   __asm__ __volatile__("lock; cmpxchgl %2, %0; setz %1"
-		       : "+m"(*(addr)), "=q"(result)
-		       : "r" (new_val), "a"(old)
+		       : "=m"(*(addr)), "=q"(result)
+		       : "r" (new_val), "a"(old), "m"(*addr)
 		       : "memory");
 #endif
   return (bool) result;