From da6f8fac772b3fa1c588e90cb9402f66b77b0837 Mon Sep 17 00:00:00 2001 From: Kevin Koltzau Date: Mon, 18 Jul 2005 09:11:52 +0000 Subject: [PATCH] Add x86_64 interlocked functions. --- libs/port/interlocked.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libs/port/interlocked.c b/libs/port/interlocked.c index 6223369f30..18abe1b7af 100644 --- a/libs/port/interlocked.c +++ b/libs/port/interlocked.c @@ -101,6 +101,35 @@ __declspec(naked) long interlocked_xchg_add( long *dest, long incr ) # error You must implement the interlocked* functions for your compiler #endif +#elif defined(__x86_64__) + +#ifdef __GNUC__ + +__ASM_GLOBAL_FUNC(interlocked_cmpxchg, + "mov %edx, %eax\n\t" + "lock cmpxchgl %esi,(%rdi)\n\t" + "ret"); +__ASM_GLOBAL_FUNC(interlocked_cmpxchg_ptr, + "mov %rdx, %rax\n\t" + "lock cmpxchgq %rsi,(%rdi)\n\t" + "ret"); +__ASM_GLOBAL_FUNC(interlocked_xchg, + "mov %esi, %eax\n\t" + "lock xchgl %eax, (%rdi)\n\t" + "ret"); +__ASM_GLOBAL_FUNC(interlocked_xchg_ptr, + "mov %rsi, %rax\n\t" + "lock xchgq %rax,(%rdi)\n\t" + "ret"); +__ASM_GLOBAL_FUNC(interlocked_xchg_add, + "mov %esi, %eax\n\t" + "lock xaddl %eax, (%rdi)\n\t" + "ret"); + +#else +# error You must implement the interlocked* functions for your compiler +#endif + #elif defined(__powerpc__) void* interlocked_cmpxchg_ptr( void **dest, void* xchg, void* compare) {