Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Apr 2020 12:50:21 +0000 (UTC)
From:      Dimitry Andric <dim@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: r360300 - stable/12/sys/mips/include
Message-ID:  <202004251250.03PCoLlD063581@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004251250.03PCoLlD063581>