Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 2020 11:14:23 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357806 - head/sys/sys
Message-ID:  <202002121114.01CBENXA085764@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Wed Feb 12 11:14:23 2020
New Revision: 357806
URL: https://svnweb.freebsd.org/changeset/base/357806

Log:
  Dedup zpcpu assertions into one macro and guard the rest with #ifndef
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/sys/pcpu.h

Modified: head/sys/sys/pcpu.h
==============================================================================
--- head/sys/sys/pcpu.h	Wed Feb 12 11:12:13 2020	(r357805)
+++ head/sys/sys/pcpu.h	Wed Feb 12 11:14:23 2020	(r357806)
@@ -228,6 +228,10 @@ extern struct pcpu *cpuid_to_pcpu[];
 #endif
 #define	curproc		(curthread->td_proc)
 
+#ifndef ZPCPU_ASSERT_PROTECTED
+#define ZPCPU_ASSERT_PROTECTED() MPASS(curthread->td_critnest > 0)
+#endif
+
 #ifndef zpcpu_offset_cpu
 #define zpcpu_offset_cpu(cpu)	(UMA_PCPU_ALLOC_SIZE * cpu)
 #endif
@@ -277,26 +281,32 @@ extern struct pcpu *cpuid_to_pcpu[];
 	_old;								\
 })
 
+#ifndef zpcpu_set_protected
 #define zpcpu_set_protected(base, val) ({				\
-	MPASS(curthread->td_critnest > 0);				\
+	ZPCPU_ASSERT_PROTECTED();					\
 	__typeof(val) *_ptr = zpcpu_get(base);				\
 									\
 	*_ptr = (val);							\
 })
+#endif
 
+#ifndef zpcpu_add_protected
 #define zpcpu_add_protected(base, val) ({				\
-	MPASS(curthread->td_critnest > 0);				\
+	ZPCPU_ASSERT_PROTECTED();					\
 	__typeof(val) *_ptr = zpcpu_get(base);				\
 									\
 	*_ptr += (val);							\
 })
+#endif
 
+#ifndef zpcpu_sub_protected
 #define zpcpu_sub_protected(base, val) ({				\
-	MPASS(curthread->td_critnest > 0);				\
+	ZPCPU_ASSERT_PROTECTED();					\
 	__typeof(val) *_ptr = zpcpu_get(base);				\
 									\
 	*_ptr -= (val);							\
 })
+#endif
 
 /*
  * Machine dependent callouts.  cpu_pcpu_init() is responsible for



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