svn commit: r270138 - projects/amd64_xen_pv/sys/amd64/include/xen

Cherry G. Mathew cherry at FreeBSD.org
Mon Aug 18 16:08:07 UTC 2014


Author: cherry
Date: Mon Aug 18 16:08:07 2014
New Revision: 270138
URL: http://svnweb.freebsd.org/changeset/base/270138

Log:
  Add a "Compare and set" style support function.
  
  Approved by:	gibbs (implicit)

Modified:
  projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h

Modified: projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h	Mon Aug 18 16:06:04 2014	(r270137)
+++ projects/amd64_xen_pv/sys/amd64/include/xen/xenpmap.h	Mon Aug 18 16:08:07 2014	(r270138)
@@ -226,10 +226,12 @@ do { 								\
 
 #define	pde_store(pdep, pde) pte_store(pdep, pde)
 
-static inline pt_entry_t pte_load_store(pt_entry_t *ptep, pt_entry_t npte)
+static __inline pt_entry_t
+pte_load_store(pt_entry_t *ptep, pt_entry_t npte)
 {
 	pt_entry_t pte;
 
+	/* XXX: review for SMP */
 	pte = *ptep;
 	
 	pte_store(ptep, npte);
@@ -245,6 +247,22 @@ static inline pt_entry_t pte_load_store(
 
 #define pte_load_clear(ptep) pte_load_store(ptep, 0);
 
+static inline bool
+pte_cmp_store(pt_entry_t *ptep, pt_entry_t oldpte, pt_entry_t newpte)
+{
+	/* XXX: locking for SMP */
+	pt_entry_t tpte;
+
+	tpte = *ptep;
+
+	if (*ptep == oldpte) {
+		pte_store(ptep, newpte);
+		return true;
+	}
+	else {
+		return false;
+	}
+}
 
 static __inline vm_paddr_t
 xpmap_mtop(vm_paddr_t mpa)


More information about the svn-src-projects mailing list