From owner-freebsd-hackers Sun Jul 2 15: 1: 8 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 96BDE37BD6B for ; Sun, 2 Jul 2000 15:01:05 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.3) with ESMTP id PAA15746 for ; Sun, 2 Jul 2000 15:01:04 -0700 (PDT) (envelope-from jdp@polstra.com) Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Sun, 02 Jul 2000 15:01:04 -0700 (PDT) Organization: Polstra & Co., Inc. From: John Polstra To: hackers@freebsd.org Subject: GCC extended asm experts please look at this Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I _thought_ I was an expert in gcc's extended asm feature, but I can't figure out why this won't compile when optmization is disabled: =============================================================================== #define xchgl(v, m) ({ \ int __result; \ __asm __volatile ("xchgl %0, %1" \ : "=r"(__result), "=m"(m) \ : "0"(v), "1"(m)); \ (__result); }) void lock80386_acquire(volatile int *lock) { while (xchgl(1, *lock) != 0) while (*lock != 0) ; } =============================================================================== It compiles and works fine with -O or higher; but without -O gcc says: locktest.c: In function `lock80386_acquire': locktest.c:11: inconsistent operand constraints in an `asm' This happens with both gcc-2.95.2 (the version in -current) and with the much older gcc-2.7.2.3. I believe the code is correct according to the documentation in the gcc info pages. I tried changing several things anyway to make it more conservative, but I haven't been able to make it compile without optimization. Can any of you see an error in the code? John To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message