Author: avg
Date: Mon Oct  7 12:53:27 2019
New Revision: 353270
URL: https://svnweb.freebsd.org/changeset/base/353270

Log:
  fix up r353168, add atomic_swap_64 to i386 version of opensolaris_atomic.S
  
  The compatibility code for the atomic operations in ZFS code is a bit
  messy.  In some cases the native definitions are directly made
  available, in some cases there are emulated operations in
  opensolaris_atomic.c and in yet other cases there are atomic operations
  implemented in assembly that were obtained from OpenSolaris / illumos.
  
  This commit adds atomic_swap_64 for use with i386 userland.
  The code is copied from illumos.
  
  I am not sure why FreeBSD does not provide that operation natively.
  Maybe because we try (or pretend) to support processors that did not
  have the necessary instructions.
  
  While here I also added atomic_load_64 for the same reasons.
  This is original code based on iilumos atomic_swap_64 and FreeBSD
  atomic_load_acq_64_i586.
  
  Pointyhat to: avg
  MFC after:    1 week

Modified:
  head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S

Modified: 
head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S
==============================================================================
--- head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S   
Mon Oct  7 12:51:36 2019        (r353269)
+++ head/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S   
Mon Oct  7 12:53:27 2019        (r353270)
@@ -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)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to