summaryrefslogtreecommitdiff
path: root/storage/innobase/include/os0sync.ic
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-11-20 15:26:31 +0100
committerSergei Golubchik <sergii@pisem.net>2014-11-20 15:26:31 +0100
commitafca52bb52cec4cd0f8167b905eab63def8f0ad2 (patch)
tree67b39aeace1d2c45eef90cbbe0d96769eeae294d /storage/innobase/include/os0sync.ic
parent3495801e2e94df5a10cae6e056f65defa038a6b6 (diff)
parent6ea41f1e84eb6b864cac17ad0b862bde9820dc33 (diff)
downloadmariadb-git-afca52bb52cec4cd0f8167b905eab63def8f0ad2.tar.gz
5.5 merge
Diffstat (limited to 'storage/innobase/include/os0sync.ic')
-rw-r--r--storage/innobase/include/os0sync.ic32
1 files changed, 32 insertions, 0 deletions
diff --git a/storage/innobase/include/os0sync.ic b/storage/innobase/include/os0sync.ic
index 9a7e520ece6..4ebf84dba98 100644
--- a/storage/innobase/include/os0sync.ic
+++ b/storage/innobase/include/os0sync.ic
@@ -232,3 +232,35 @@ win_cmp_and_xchg_dword(
#endif /* HAVE_WINDOWS_ATOMICS */
+
+/**********************************************************//**
+Acquires ownership of a fast mutex. Implies a full memory barrier even on
+platforms such as PowerPC where this is not normally required.
+@return 0 if success, != 0 if was reserved by another thread */
+UNIV_INLINE
+ulint
+os_fast_mutex_trylock_full_barrier(
+/*==================*/
+ os_fast_mutex_t* fast_mutex) /*!< in: mutex to acquire */
+{
+#ifdef __WIN__
+ if (TryEnterCriticalSection(&fast_mutex->mutex)) {
+
+ return(0);
+ } else {
+
+ return(1);
+ }
+#else
+ /* NOTE that the MySQL my_pthread.h redefines pthread_mutex_trylock
+ so that it returns 0 on success. In the operating system
+ libraries, HP-UX-10.20 follows the old Posix 1003.4a Draft 4 and
+ returns 1 on success (but MySQL remaps that to 0), while Linux,
+ FreeBSD, Solaris, AIX, Tru64 Unix, HP-UX-11.0 return 0 on success. */
+
+#ifdef __powerpc__
+ os_mb;
+#endif
+ return((ulint) pthread_mutex_trylock(&fast_mutex->mutex));
+#endif
+}