[cfe-dev] clang-cc regression on inline asm?

Mike Stump mrs at apple.com
Tue May 19 11:01:06 PDT 2009


On May 19, 2009, at 7:01 AM, Enea Zaffanella wrote:
> bug.c:11:9: error: unsupported inline asm: input with type 'int'
> matching output with type 'char'

> Is this a regression?

If you mean, does it work in gcc and not in clang yet, yes, it is a  
regression from gcc to clang.  If you're asking if it is a bug, yes,  
it is.  You can work around this by ensuring that the input and output  
types are the same, something like:

typedef struct {
   volatile unsigned int lock;
} spinlock_t;

int spin_trylock(spinlock_t *lock)
{
   char oldval;
   __asm__ __volatile__(
		       "xchgb %b0,%1"
		       :"=q" (oldval), "=m" (lock->lock)
		       :"0" ((char)0) : "memory");
   return oldval > 0;
}




More information about the cfe-dev mailing list