Commit 1b6e332f 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 7abbc07d
......@@ -276,14 +276,19 @@ rw_lock_set_writer_id_and_recursion_flag(
{
os_thread_id_t curr_thread = os_thread_get_curr_id();
ut_ad(lock);
#ifdef INNODB_RW_LOCKS_USE_ATOMICS
os_thread_id_t local_thread = lock->writer_thread;
ibool success = os_compare_and_swap(&lock->writer_thread,
local_thread,
curr_thread);
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);
local_thread = lock->writer_thread;
success = os_compare_and_swap(&lock->writer_thread,
local_thread, curr_thread);
ut_a(success);
lock->recursive = recursive;
......@@ -458,8 +463,8 @@ rw_lock_x_lock_func_nowait(
if (success) {
rw_lock_set_writer_id_and_recursion_flag(lock, TRUE);
} else if (lock->recursive &&
os_thread_eq(lock->writer_thread, curr_thread)) {
} else if (lock->recursive
&& os_thread_eq(lock->writer_thread, curr_thread)) {
/* Relock: this lock_word modification is safe since no other
threads can modify (lock, unlock, or reserve) lock_word while
there is an exclusive writer and this is the writer thread. */
......
......@@ -857,7 +857,7 @@ sync_array_object_signalled(
sync_array_t* arr) /* in: wait array */
{
#ifdef HAVE_GCC_ATOMIC_BUILTINS
os_atomic_increment(&arr->sg_count, 1);
(void) os_atomic_increment(&arr->sg_count, 1);
#else
sync_array_enter(arr);
......
......@@ -238,15 +238,15 @@ rw_lock_create_func(
lock->mutex.cfile_name = cfile_name;
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.mutex_type = 1;
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
# endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
#ifdef UNIV_DEBUG
# ifdef UNIV_DEBUG
UT_NOT_USED(cmutex_name);
#endif
# endif
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
lock->lock_word = X_LOCK_DECR;
......@@ -563,8 +563,8 @@ rw_lock_x_lock_low(
} else {
/* Decrement failed: relock or failed lock */
if (!pass && lock->recursive &&
os_thread_eq(lock->writer_thread, curr_thread)) {
if (!pass && lock->recursive
&& os_thread_eq(lock->writer_thread, curr_thread)) {
/* Relock */
lock->lock_word -= X_LOCK_DECR;
} 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