Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Jul 2000 15:01:04 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        hackers@freebsd.org
Subject:   GCC extended asm experts please look at this
Message-ID:  <XFMail.000702150104.jdp@polstra.com>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.000702150104.jdp>