* cmpxchg8b help
@ 2002-09-19 9:10 Scott Moonen
0 siblings, 0 replies; only message in thread
From: Scott Moonen @ 2002-09-19 9:10 UTC (permalink / raw)
To: gcc-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.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-09-19 16:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-19 9:10 cmpxchg8b help Scott Moonen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).