svn commit: r360300 - stable/12/sys/mips/include

Dimitry Andric dim at FreeBSD.org
Sat Apr 25 12:50:22 UTC 2020


Author: dim
Date: Sat Apr 25 12:50:21 2020
New Revision: 360300
URL: https://svnweb.freebsd.org/changeset/base/360300

Log:
  MFC r342022 (by imp):
  
  Correctly implemenet atomic_swap_long for mips64.
  
  MIPS64 has 64-bit longs, so use uint64_t for it, otherwise uint32_t.
  sizeof(long) == sizeof(ptr) for all platforms, so define
  atomic_swap_ptr in terms of atomic_swap_long.
  
  Submitted by: hps@

Modified:
  stable/12/sys/mips/include/atomic.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/mips/include/atomic.h
==============================================================================
--- stable/12/sys/mips/include/atomic.h	Sat Apr 25 12:49:48 2020	(r360299)
+++ stable/12/sys/mips/include/atomic.h	Sat Apr 25 12:50:21 2020	(r360300)
@@ -797,6 +797,7 @@ atomic_swap_64(volatile uint64_t *ptr, const uint64_t 
 }
 #endif
 
+#ifdef __mips_n64
 static __inline unsigned long
 atomic_swap_long(volatile unsigned long *ptr, const unsigned long value)
 {
@@ -804,16 +805,16 @@ atomic_swap_long(volatile unsigned long *ptr, const un
 
 	retval = *ptr;
 
-	while (!atomic_fcmpset_32((volatile uint32_t *)ptr,
-	    (uint32_t *)&retval, value))
+	while (!atomic_fcmpset_64((volatile uint64_t *)ptr,
+	    (uint64_t *)&retval, value))
 		;
 	return (retval);
 }
-
-static __inline uintptr_t
-atomic_swap_ptr(volatile uintptr_t *ptr, const uintptr_t value)
+#else
+static __inline unsigned long
+atomic_swap_long(volatile unsigned long *ptr, const unsigned long value)
 {
-	uintptr_t retval;
+	unsigned long retval;
 
 	retval = *ptr;
 
@@ -822,5 +823,7 @@ atomic_swap_ptr(volatile uintptr_t *ptr, const uintptr
 		;
 	return (retval);
 }
+#endif
+#define	atomic_swap_ptr(ptr, value) atomic_swap_long((unsigned long *)(ptr), value)
 
 #endif /* ! _MACHINE_ATOMIC_H_ */


More information about the svn-src-stable-12 mailing list