[Commits] 4650ed9: Clean-up InnoDB atomics

Sergey Vojtovich svoj at mariadb.org
Fri Sep 9 14:55:35 EEST 2016


revision-id: 4650ed9a8dbbd74be14dff79861cdd51008a97fe (mariadb-10.2.1-9-g4650ed9)
parent(s): 91151728a8d44d95c6045d9ed8b2578a23f20ca6
committer: Sergey Vojtovich
timestamp: 2016-09-09 15:55:35 +0400
message:

Clean-up InnoDB atomics

Replaced os_atomic_increment_uint64 and os_atomic_decrement_uint64 with
my_atomic_add64().

---
 storage/innobase/include/os0atomic.h | 18 ------------------
 storage/innobase/include/srv0mon.h   |  8 ++++----
 2 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/storage/innobase/include/os0atomic.h b/storage/innobase/include/os0atomic.h
index b476c52..03a979f 100644
--- a/storage/innobase/include/os0atomic.h
+++ b/storage/innobase/include/os0atomic.h
@@ -165,12 +165,6 @@ amount of increment. */
 		static_cast<lint>(amount)))			\
 	+ static_cast<ulint>(amount))
 
-# define os_atomic_increment_uint64(ptr, amount)		\
-	(static_cast<ib_uint64_t>(InterlockedExchangeAdd64(	\
-		reinterpret_cast<LONGLONG*>(ptr),		\
-		static_cast<LONGLONG>(amount)))			\
-	+ static_cast<ib_uint64_t>(amount))
-
 /**********************************************************//**
 Returns the resulting value, ptr is pointer to target, amount is the
 amount to decrement. There is no atomic substract function on Windows */
@@ -184,12 +178,6 @@ amount to decrement. There is no atomic substract function on Windows */
 		-(static_cast<lint>(amount))))			\
 	- static_cast<ulint>(amount))
 
-# define os_atomic_decrement_uint64(ptr, amount)		\
-	(static_cast<ib_uint64_t>(InterlockedExchangeAdd64(	\
-		reinterpret_cast<LONGLONG*>(ptr),		\
-		-(static_cast<LONGLONG>(amount))))		\
-	- static_cast<ib_uint64_t>(amount))
-
 #else
 /* Fall back to GCC-style atomic builtins. */
 
@@ -300,9 +288,6 @@ amount of increment. */
 # define os_atomic_increment_ulint(ptr, amount) \
 	os_atomic_increment(ptr, amount)
 
-# define os_atomic_increment_uint64(ptr, amount) \
-	os_atomic_increment(ptr, amount)
-
 /* Returns the resulting value, ptr is pointer to target, amount is the
 amount to decrement. */
 
@@ -325,9 +310,6 @@ amount to decrement. */
 # define os_atomic_decrement_ulint(ptr, amount) \
 	os_atomic_decrement(ptr, amount)
 
-# define os_atomic_decrement_uint64(ptr, amount) \
-	os_atomic_decrement(ptr, amount)
-
 #endif
 
 #define os_atomic_inc_ulint(m,v,d)	os_atomic_increment_ulint(v, d)
diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 14c1d62..1254013 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -613,8 +613,8 @@ Use MONITOR_INC if appropriate mutex protection exists.
 # define MONITOR_ATOMIC_INC(monitor)					\
 	if (MONITOR_IS_ON(monitor)) {					\
 		ib_uint64_t	value;					\
-		value  = os_atomic_increment_uint64(			\
-			(ib_uint64_t*) &MONITOR_VALUE(monitor),	 1);	\
+		value  = my_atomic_add64(				\
+			(int64*) &MONITOR_VALUE(monitor), 1) + 1;	\
 		/* Note: This is not 100% accurate because of the	\
 		inherent race, we ignore it due to performance. */	\
 		if (value > (ib_uint64_t) MONITOR_MAX_VALUE(monitor)) {	\
@@ -628,8 +628,8 @@ Use MONITOR_DEC if appropriate mutex protection exists.
 # define MONITOR_ATOMIC_DEC(monitor)					\
 	if (MONITOR_IS_ON(monitor)) {					\
 		ib_uint64_t	value;					\
-		value = os_atomic_decrement_uint64(			\
-			(ib_uint64_t*) &MONITOR_VALUE(monitor), 1);	\
+		value = my_atomic_add64(				\
+			(int64*) &MONITOR_VALUE(monitor), -1) - 1;	\
 		/* Note: This is not 100% accurate because of the	\
 		inherent race, we ignore it due to performance. */	\
 		if (value < (ib_uint64_t) MONITOR_MIN_VALUE(monitor)) {	\


More information about the commits mailing list