Date: Tue, 22 Oct 2019 09:06:59 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353881 - in stable/12/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/common/atomic/i386 Message-ID: <201910220906.x9M96xma005148@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Tue Oct 22 09:06:59 2019 New Revision: 353881 URL: https://svnweb.freebsd.org/changeset/base/353881 Log: MFC r353167,r353270: ZFS: add emulation of atomic_swap_64 and atomic_load_64 Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c stable/12/sys/cddl/compat/opensolaris/sys/atomic.h stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue Oct 22 08:56:45 2019 (r353880) +++ stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue Oct 22 09:06:59 2019 (r353881) @@ -71,6 +71,29 @@ atomic_dec_64(volatile uint64_t *target) *target -= 1; mtx_unlock(&atomic_mtx); } + +uint64_t +atomic_swap_64(volatile uint64_t *a, uint64_t value) +{ + uint64_t ret; + + mtx_lock(&atomic_mtx); + ret = *a; + *a = value; + mtx_unlock(&atomic_mtx); + return (ret); +} + +uint64_t +atomic_load_64(volatile uint64_t *a) +{ + uint64_t ret; + + mtx_lock(&atomic_mtx); + ret = *a; + mtx_unlock(&atomic_mtx); + return (ret); +} #endif uint64_t Modified: stable/12/sys/cddl/compat/opensolaris/sys/atomic.h ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Tue Oct 22 08:56:45 2019 (r353880) +++ stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Tue Oct 22 09:06:59 2019 (r353881) @@ -44,6 +44,8 @@ !defined(ARM_HAVE_ATOMIC64) && !defined(I386_HAVE_ATOMIC64) extern void atomic_add_64(volatile uint64_t *target, int64_t delta); extern void atomic_dec_64(volatile uint64_t *target); +extern uint64_t atomic_swap_64(volatile uint64_t *a, uint64_t value); +extern uint64_t atomic_load_64(volatile uint64_t *a); #endif #ifndef __sparc64__ extern uint32_t atomic_cas_32(volatile uint32_t *target, uint32_t cmp, Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Tue Oct 22 08:56:45 2019 (r353880) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Tue Oct 22 09:06:59 2019 (r353881) @@ -126,6 +126,34 @@ ret SET_SIZE(atomic_cas_64) + ENTRY(atomic_swap_64) + pushl %esi + pushl %ebx + movl 12(%esp), %esi + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl (%esi), %eax + movl 4(%esi), %edx // %edx:%eax = old value +1: + lock + cmpxchg8b (%esi) + jne 1b + popl %ebx + popl %esi + ret + SET_SIZE(atomic_swap_64) + + ENTRY(atomic_load_64) + pushl %esi + movl 8(%esp), %esi + movl %ebx, %eax // make old and new values equal, so that + movl %ecx, %edx // destination is never changed + lock + cmpxchg8b (%esi) + popl %esi + ret + SET_SIZE(atomic_load_64) + ENTRY(membar_producer) lock xorl $0, (%esp)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910220906.x9M96xma005148>