Commit a5d1b1ce authored by marko's avatar marko

Minor cleanup of the Google SMP patch.

sync_array_object_signalled(): Add a (void) cast to eliminate a gcc warning
about the return value of os_atomic_increment() being ignored.

rw_lock_create_func(): Properly indent the preprocessor directives.

rw_lock_x_lock_low(), rw_lock_x_lock_func_nowait(): Split lines correctly.

rw_lock_set_writer_id_and_recursion_flag(): Silence a Valgrind warning.
Do not mix statements and variable declarations.
parent f3fab6e7
...@@ -276,14 +276,19 @@ rw_lock_set_writer_id_and_recursion_flag( ...@@ -276,14 +276,19 @@ rw_lock_set_writer_id_and_recursion_flag(
{ {
os_thread_id_t curr_thread = os_thread_get_curr_id(); os_thread_id_t curr_thread = os_thread_get_curr_id();
ut_ad(lock);
#ifdef INNODB_RW_LOCKS_USE_ATOMICS #ifdef INNODB_RW_LOCKS_USE_ATOMICS
os_thread_id_t local_thread;
ibool success;
/* Prevent Valgrind warnings about writer_thread being
uninitialized. It does not matter if writer_thread is
uninitialized, because we are comparing writer_thread against
itself, and the operation should always succeed. */
UNIV_MEM_VALID(&lock->writer_thread, sizeof lock->writer_thread);
os_thread_id_t local_thread = lock->writer_thread; local_thread = lock->writer_thread;
ibool success = os_compare_and_swap(&lock->writer_thread, success = os_compare_and_swap(&lock->writer_thread,
local_thread, local_thread, curr_thread);
curr_thread);
ut_a(success); ut_a(success);
lock->recursive = recursive; lock->recursive = recursive;
...@@ -458,8 +463,8 @@ rw_lock_x_lock_func_nowait( ...@@ -458,8 +463,8 @@ rw_lock_x_lock_func_nowait(
if (success) { if (success) {
rw_lock_set_writer_id_and_recursion_flag(lock, TRUE); rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
} else if (lock->recursive && } else if (lock->recursive
os_thread_eq(lock->writer_thread, curr_thread)) { && os_thread_eq(lock->writer_thread, curr_thread)) {
/* Relock: this lock_word modification is safe since no other /* Relock: this lock_word modification is safe since no other
threads can modify (lock, unlock, or reserve) lock_word while threads can modify (lock, unlock, or reserve) lock_word while
there is an exclusive writer and this is the writer thread. */ there is an exclusive writer and this is the writer thread. */
......
...@@ -857,7 +857,7 @@ sync_array_object_signalled( ...@@ -857,7 +857,7 @@ sync_array_object_signalled(
sync_array_t* arr) /* in: wait array */ sync_array_t* arr) /* in: wait array */
{ {
#ifdef HAVE_GCC_ATOMIC_BUILTINS #ifdef HAVE_GCC_ATOMIC_BUILTINS
os_atomic_increment(&arr->sg_count, 1); (void) os_atomic_increment(&arr->sg_count, 1);
#else #else
sync_array_enter(arr); sync_array_enter(arr);
......
...@@ -238,15 +238,15 @@ rw_lock_create_func( ...@@ -238,15 +238,15 @@ rw_lock_create_func(
lock->mutex.cfile_name = cfile_name; lock->mutex.cfile_name = cfile_name;
lock->mutex.cline = cline; lock->mutex.cline = cline;
#if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP # if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
lock->mutex.cmutex_name = cmutex_name; lock->mutex.cmutex_name = cmutex_name;
lock->mutex.mutex_type = 1; lock->mutex.mutex_type = 1;
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */ # endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
#else /* INNODB_RW_LOCKS_USE_ATOMICS */ #else /* INNODB_RW_LOCKS_USE_ATOMICS */
#ifdef UNIV_DEBUG # ifdef UNIV_DEBUG
UT_NOT_USED(cmutex_name); UT_NOT_USED(cmutex_name);
#endif # endif
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */ #endif /* INNODB_RW_LOCKS_USE_ATOMICS */
lock->lock_word = X_LOCK_DECR; lock->lock_word = X_LOCK_DECR;
...@@ -563,8 +563,8 @@ rw_lock_x_lock_low( ...@@ -563,8 +563,8 @@ rw_lock_x_lock_low(
} else { } else {
/* Decrement failed: relock or failed lock */ /* Decrement failed: relock or failed lock */
if (!pass && lock->recursive && if (!pass && lock->recursive
os_thread_eq(lock->writer_thread, curr_thread)) { && os_thread_eq(lock->writer_thread, curr_thread)) {
/* Relock */ /* Relock */
lock->lock_word -= X_LOCK_DECR; lock->lock_word -= X_LOCK_DECR;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment