From nobody Mon Sep 17 00:00:00 2001 From: Pavel Afremov Date: Thu, 22 Feb 2007 15:27:54 +0300 Subject: [PATCH] Add port atomic functions support for Windows x86_64 platform. Patch adds port atomic functions support for Windows x86_64 platform. • port_atomic_cas16 and port_atomic_cas64 are defined via _InterlockedCompareExchange intrinsics • port_atomic_cas8 was defined in asm file, because C compiler for Windows x86_64 doesn’t support inline assembler. --- build/make/components/vm/port.xml | 4 ++++ vm/port/include/port_atomic.h | 15 +++++++++++++++ vm/port/src/atomic/win_em64t/port_atomic.asm | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 vm/port/src/atomic/win_em64t/port_atomic.asm af6bb78b8587f0bd71d673a07cb2acce10af0c1d diff --git a/build/make/components/vm/port.xml b/build/make/components/vm/port.xml index 54d8f6e..dfe1306 100644 --- a/build/make/components/vm/port.xml +++ b/build/make/components/vm/port.xml @@ -70,6 +70,10 @@ Version: $Revision: 1.3.2.2 $ + + diff --git a/vm/port/include/port_atomic.h b/vm/port/include/port_atomic.h index a6a5346..2608789 100644 --- a/vm/port/include/port_atomic.h +++ b/vm/port/include/port_atomic.h @@ -119,6 +119,21 @@ INLINE uint64 port_atomic_cas64(volatile return comp; } +#elif defined( WIN64 ) + +APR_DECLARE uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp); + +#pragma intrinsic(_InterlockedCompareExchange16); +#pragma intrinsic(_InterlockedCompareExchange64); + +INLINE uint16 port_atomic_cas16(volatile uint16 * data , uint16 value, uint16 comp) { + return _InterlockedCompareExchange16(data, value, comp); +} + +INLINE uint64 port_atomic_cas64(volatile uint64 * data , uint64 value, uint64 comp) { + return _InterlockedCompareExchange64(data, value, comp); +} + #elif defined (PLATFORM_POSIX) INLINE uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) { diff --git a/vm/port/src/atomic/win_em64t/port_atomic.asm b/vm/port/src/atomic/win_em64t/port_atomic.asm new file mode 100644 index 0000000..1225044 --- /dev/null +++ b/vm/port/src/atomic/win_em64t/port_atomic.asm @@ -0,0 +1,23 @@ +PUBLIC port_atomic_cas8 + +_TEXT SEGMENT + +port_atomic_cas8 PROC + +;uint8 port_atomic_cas8(volatile uint8 * data , uint8 value, uint8 comp) +; +; rcx - *data - pointer to the byte which shoud be exchanged +; rdx - value - new value +; r8 - comp - previous conditional value +; +; It's a leaf function so no prolog and epilog are used. + + mov rax, r8 + lock cmpxchg [rcx], dl + ret + +port_atomic_cas8 ENDP + +_TEXT ENDS + +END -- 1.3.3