diff options
author | Michael Widenius <monty@askmonty.org> | 2012-08-01 17:27:34 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2012-08-01 17:27:34 +0300 |
commit | 1d0f70c2f894b27e98773a282871d32802f67964 (patch) | |
tree | 833e683e0ced29c4323c29a9d845703d4dfcd81b /storage/innobase/include/sync0sync.ic | |
parent | 5a86a61219826aadf8d08cbc447fe438f2bf50c3 (diff) | |
download | mariadb-git-1d0f70c2f894b27e98773a282871d32802f67964.tar.gz |
Temporary commit of merge of MariaDB 10.0-base and MySQL 5.6
Diffstat (limited to 'storage/innobase/include/sync0sync.ic')
-rw-r--r-- | storage/innobase/include/sync0sync.ic | 118 |
1 files changed, 79 insertions, 39 deletions
diff --git a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic index eb21f44c65e..746e73ebee7 100644 --- a/storage/innobase/include/sync0sync.ic +++ b/storage/innobase/include/sync0sync.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved. +Copyright (c) 1995, 2009, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -18,8 +18,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -94,7 +94,7 @@ mutex_test_and_set( mutex->lock_word = 1; } - return((byte)ret); + return((byte) ret); #endif } @@ -236,22 +236,22 @@ pfs_mutex_enter_func( const char* file_name, /*!< in: file name where locked */ ulint line) /*!< in: line where locked */ { - struct PSI_mutex_locker* locker = NULL; - PSI_mutex_locker_state state; - int result = 0; - - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - locker = PSI_server->get_thread_mutex_locker( - &state, mutex->pfs_psi, PSI_MUTEX_LOCK); - if (locker) { - PSI_server->start_mutex_wait(locker, file_name, line); - } - } + if (mutex->pfs_psi != NULL) + { + PSI_mutex_locker* locker; + PSI_mutex_locker_state state; + + locker = PSI_CALL(start_mutex_wait)(&state, mutex->pfs_psi, + PSI_MUTEX_LOCK, file_name, line); - mutex_enter_func(mutex, file_name, line); + mutex_enter_func(mutex, file_name, line); - if (locker) { - PSI_server->end_mutex_wait(locker, result); + if (locker != NULL) + PSI_CALL(end_mutex_wait)(locker, 0); + } + else + { + mutex_enter_func(mutex, file_name, line); } } /********************************************************************//** @@ -270,21 +270,23 @@ pfs_mutex_enter_nowait_func( ulint line) /*!< in: line where requested */ { ulint ret; - struct PSI_mutex_locker* locker = NULL; - PSI_mutex_locker_state state; - - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - locker = PSI_server->get_thread_mutex_locker( - &state, mutex->pfs_psi, PSI_MUTEX_TRYLOCK); - if (locker) { - PSI_server->start_mutex_wait(locker, file_name, line); - } - } - ret = mutex_enter_nowait_func(mutex, file_name, line); + if (mutex->pfs_psi != NULL) + { + PSI_mutex_locker* locker; + PSI_mutex_locker_state state; + + locker = PSI_CALL(start_mutex_wait)(&state, mutex->pfs_psi, + PSI_MUTEX_TRYLOCK, file_name, line); + + ret = mutex_enter_nowait_func(mutex, file_name, line); - if (locker) { - PSI_server->end_mutex_wait(locker, ret); + if (locker != NULL) + PSI_CALL(end_mutex_wait)(locker, (int) ret); + } + else + { + ret = mutex_enter_nowait_func(mutex, file_name, line); } return(ret); @@ -300,9 +302,8 @@ pfs_mutex_exit_func( /*================*/ mutex_t* mutex) /*!< in: pointer to mutex */ { - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - PSI_server->unlock_mutex(mutex->pfs_psi); - } + if (mutex->pfs_psi != NULL) + PSI_CALL(unlock_mutex)(mutex->pfs_psi); mutex_exit_func(mutex); } @@ -328,9 +329,7 @@ pfs_mutex_create_func( const char* cfile_name, /*!< in: file name where created */ ulint cline) /*!< in: file line where created */ { - mutex->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key)) - ? PSI_server->init_mutex(key, mutex) - : NULL; + mutex->pfs_psi = PSI_CALL(init_mutex)(key, mutex); mutex_create_func(mutex, # ifdef UNIV_DEBUG @@ -353,8 +352,9 @@ pfs_mutex_free_func( /*================*/ mutex_t* mutex) /*!< in: mutex */ { - if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) { - PSI_server->destroy_mutex(mutex->pfs_psi); + if (mutex->pfs_psi != NULL) + { + PSI_CALL(destroy_mutex)(mutex->pfs_psi); mutex->pfs_psi = NULL; } @@ -362,3 +362,43 @@ pfs_mutex_free_func( } #endif /* UNIV_PFS_MUTEX */ + +#ifndef HAVE_ATOMIC_BUILTINS +/**********************************************************//** +Function that uses a mutex to decrement a variable atomically */ +UNIV_INLINE +void +os_atomic_dec_ulint_func( +/*=====================*/ + mutex_t* mutex, /*!< in: mutex guarding the dec */ + volatile ulint* var, /*!< in/out: variable to decrement */ + ulint delta) /*!< in: delta to decrement */ +{ + mutex_enter(mutex); + + /* I don't think we will encounter a situation where + this check will not be required. */ + ut_ad(*var >= delta); + + *var -= delta; + + mutex_exit(mutex); +} + +/**********************************************************//** +Function that uses a mutex to increment a variable atomically */ +UNIV_INLINE +void +os_atomic_inc_ulint_func( +/*=====================*/ + mutex_t* mutex, /*!< in: mutex guarding the increment */ + volatile ulint* var, /*!< in/out: variable to increment */ + ulint delta) /*!< in: delta to increment */ +{ + mutex_enter(mutex); + + *var += delta; + + mutex_exit(mutex); +} +#endif /* !HAVE_ATOMIC_BUILTINS */ |