c00lsnoopy
March 20th, 2009, 05:31 PM
Hi everyone,
I'm trying to make the following ASM code compile on MSVC. This code works fine when compiled on GCC. I know the structure is not the same but I couldn`t find any documentation on this issue. Any help will be appreciated. Thanks a bunch!
static inline unsigned long cmpxchg(volatile void *ptr, unsigned long old,
unsigned long _new, int size)
{
unsigned long prev;
switch (size) {
case 1:
__asm__ __volatile__(lock; "cmpxchgb %b1,%2"
: "=a"(prev)
: "q"(_new), "m"(*oro__xg(ptr)), "0"(old)
: "memory");
return prev;
case 2:
__asm__ __volatile__(lock; "cmpxchgw %w1,%2"
: "=a"(prev)
: "q"(_new), "m"(*oro__xg(ptr)), "0"(old)
: "memory");
return prev;
case 4:
__asm__ __volatile__(lock; "cmpxchgl %1,%2"
: "=a"(prev)
: "q"(_new), "m"(*oro__xg(ptr)), "0"(old)
: "memory");
return prev;
}
return old;
}
I'm trying to make the following ASM code compile on MSVC. This code works fine when compiled on GCC. I know the structure is not the same but I couldn`t find any documentation on this issue. Any help will be appreciated. Thanks a bunch!
static inline unsigned long cmpxchg(volatile void *ptr, unsigned long old,
unsigned long _new, int size)
{
unsigned long prev;
switch (size) {
case 1:
__asm__ __volatile__(lock; "cmpxchgb %b1,%2"
: "=a"(prev)
: "q"(_new), "m"(*oro__xg(ptr)), "0"(old)
: "memory");
return prev;
case 2:
__asm__ __volatile__(lock; "cmpxchgw %w1,%2"
: "=a"(prev)
: "q"(_new), "m"(*oro__xg(ptr)), "0"(old)
: "memory");
return prev;
case 4:
__asm__ __volatile__(lock; "cmpxchgl %1,%2"
: "=a"(prev)
: "q"(_new), "m"(*oro__xg(ptr)), "0"(old)
: "memory");
return prev;
}
return old;
}