summaryrefslogtreecommitdiff
path: root/storage/xtradb/include/os0sync.ic
diff options
context:
space:
mode:
Diffstat (limited to 'storage/xtradb/include/os0sync.ic')
-rw-r--r--storage/xtradb/include/os0sync.ic31
1 files changed, 31 insertions, 0 deletions
diff --git a/storage/xtradb/include/os0sync.ic b/storage/xtradb/include/os0sync.ic
index 9a7e520ece6..5f4b0d24089 100644
--- a/storage/xtradb/include/os0sync.ic
+++ b/storage/xtradb/include/os0sync.ic
@@ -232,3 +232,34 @@ 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
+}