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

Daniel Dunbar daniel at zuster.org
Tue May 19 11:29:36 PDT 2009


I think he is asking if it is an intentional incompatibility, and I
think, but am not sure, that Chris did intend to make this an error
and expect users to change their code.

 - Daniel

On Tue, May 19, 2009 at 11:01 AM, Mike Stump <mrs at apple.com> wrote:
> 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;
> }
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list