This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
cmpxchg8b help
- From: Scott Moonen <smoonen at andstuff dot org>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 19 Sep 2002 09:10:43 -0700
- Subject: cmpxchg8b help
List,
I have the following function in /usr/include/asm/system.h on my system.
I would like to modify it to take long long parameters and support an
8-byte cmpxchg8b as well. My expertise these days is in S/390 assembler
rather than Intel, much less GCC's syntax to allow it, so I have little
idea where to even start.
Would anyone on the list be able to help me? Thanks in advance! -- Scott
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_PREFIX "cmpxchgb %b1,%2"
: "=a"(prev)
: "q"(new), "m"(*__xg(ptr)), "0"(old)
: "memory");
return prev;
case 2:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
: "=a"(prev)
: "q"(new), "m"(*__xg(ptr)), "0"(old)
: "memory");
return prev;
case 4:
__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
: "=a"(prev)
: "q"(new), "m"(*__xg(ptr)), "0"(old)
: "memory");
return prev;
}
return old;
}
--
This is not a sentence.