From 21051b2142e0266c99f9666a0e00a0ea63dbb933 Mon Sep 17 00:00:00 2001 From: vasil Date: Mon, 14 Sep 2009 07:38:45 +0000 Subject: [PATCH] branches/zip: Back-merge c5880 and c5881 from branches/embedded-1.0: ------------------------------------------------------------------------ r5880 | vasil | 2009-09-12 17:28:44 +0300 (Sat, 12 Sep 2009) | 18 lines Changed paths: M /branches/embedded-1.0/configure.in M /branches/embedded-1.0/include/os0sync.h M /branches/embedded-1.0/srv/srv0start.c branches/embedded-1.0: Clean up and simplify the code that surrounds the atomic ops: * Simplify the code that prints what atomics are used: Instead of repeating the same conditions on which each atomics are used use just one printf that prints a variable defined by the code which chooses what atomics to use. * In os0sync.h pick up each atomic variant only if it has been selected by autoconf (based on IB_ATOMIC_MODE_* macros). Define the startup message to be printed. * In configure.in: check what user has chosen and if he has chosen something that is not available, emit an error. If nothing has been chosen explicitly by the user, auto select an option according to the described logic in configure.in. ------------------------------------------------------------------------ r5881 | vasil | 2009-09-12 20:08:27 +0300 (Sat, 12 Sep 2009) | 4 lines Changed paths: M /branches/embedded-1.0/configure.in branches/embedded-1.0: Fix syntax error in test program. ------------------------------------------------------------------------ --- include/os0sync.h | 20 ++++++++++++++++++-- plug.in | 2 +- srv/srv0start.c | 29 +---------------------------- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/include/os0sync.h b/include/os0sync.h index 317c6d612fd..0c22162b900 100644 --- a/include/os0sync.h +++ b/include/os0sync.h @@ -285,7 +285,7 @@ os_fast_mutex_free( /**********************************************************//** Atomic compare-and-swap and increment for InnoDB. */ -#ifdef HAVE_IB_GCC_ATOMIC_BUILTINS +#if defined(HAVE_IB_GCC_ATOMIC_BUILTINS) #define HAVE_ATOMIC_BUILTINS @@ -306,6 +306,11 @@ compare to, new_val is the value to swap in. */ # define os_compare_and_swap_thread_id(ptr, old_val, new_val) \ os_compare_and_swap(ptr, old_val, new_val) # define INNODB_RW_LOCKS_USE_ATOMICS +# define IB_ATOMICS_STARTUP_MSG \ + "Mutexes and rw_locks use GCC atomic builtins" +# else /* HAVE_IB_ATOMIC_PTHREAD_T_GCC */ +# define IB_ATOMICS_STARTUP_MSG \ + "Mutexes use GCC atomic builtins, rw_locks do not" # endif /* HAVE_IB_ATOMIC_PTHREAD_T_GCC */ /**********************************************************//** @@ -356,7 +361,12 @@ compare to, new_val is the value to swap in. */ # else # error "SIZEOF_PTHREAD_T != 4 or 8" # endif /* SIZEOF_PTHREAD_T CHECK */ -# define INNODB_RW_LOCKS_USE_ATOMICS +# define INNODB_RW_LOCKS_USE_ATOMICS +# define IB_ATOMICS_STARTUP_MSG \ + "Mutexes and rw_locks use Solaris atomic functions" +# else /* HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS */ +# define IB_ATOMICS_STARTUP_MSG \ + "Mutexes use Solaris atomic functions, rw_locks do not" # endif /* HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS */ /**********************************************************//** @@ -401,6 +411,9 @@ compare to, new_val is the value to swap in. */ /* windows thread objects can always be passed to windows atomic functions */ # define os_compare_and_swap_thread_id(ptr, old_val, new_val) \ (InterlockedCompareExchange(ptr, new_val, old_val) == old_val) +# define INNODB_RW_LOCKS_USE_ATOMICS +# define IB_ATOMICS_STARTUP_MSG \ + "Mutexes and rw_locks use Windows interlocked functions" /**********************************************************//** Returns the resulting value, ptr is pointer to target, amount is the @@ -420,6 +433,9 @@ clobbered */ # define os_atomic_test_and_set_byte(ptr, new_val) \ ((byte) InterlockedExchange(ptr, new_val)) +#else +# define IB_ATOMICS_STARTUP_MSG \ + "Mutexes and rw_locks use InnoDB's own implementation" #endif #ifndef UNIV_NONINL diff --git a/plug.in b/plug.in index 8025162925e..da4412e88ca 100644 --- a/plug.in +++ b/plug.in @@ -176,7 +176,7 @@ MYSQL_PLUGIN_ACTIONS(innobase, [ return(1); } - + } ], [ AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS], [1], diff --git a/srv/srv0start.c b/srv/srv0start.c index 068cb9dbe64..1d7f5e1227e 100644 --- a/srv/srv0start.c +++ b/srv/srv0start.c @@ -1107,34 +1107,7 @@ innobase_start_or_create_for_mysql(void) "InnoDB: The InnoDB memory heap is disabled\n"); } -#ifdef HAVE_IB_GCC_ATOMIC_BUILTINS -# ifdef INNODB_RW_LOCKS_USE_ATOMICS - fprintf(stderr, - "InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n"); -# else /* INNODB_RW_LOCKS_USE_ATOMICS */ - fprintf(stderr, - "InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n"); -# endif /* INNODB_RW_LOCKS_USE_ATOMICS */ -#elif defined(HAVE_IB_SOLARIS_ATOMICS) -# ifdef INNODB_RW_LOCKS_USE_ATOMICS - fprintf(stderr, - "InnoDB: Mutexes and rw_locks use Solaris atomic functions.\n"); -# else - fprintf(stderr, - "InnoDB: Mutexes use Solaris atomic functions.\n"); -# endif /* INNODB_RW_LOCKS_USE_ATOMICS */ -#elif HAVE_WINDOWS_ATOMICS -# ifdef INNODB_RW_LOCKS_USE_ATOMICS - fprintf(stderr, - "InnoDB: Mutexes and rw_locks use Windows interlocked functions.\n"); -# else - fprintf(stderr, - "InnoDB: Mutexes use Windows interlocked functions.\n"); -# endif /* INNODB_RW_LOCKS_USE_ATOMICS */ -#else /* HAVE_IB_GCC_ATOMIC_BUILTINS */ - fprintf(stderr, - "InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n"); -#endif /* HAVE_IB_GCC_ATOMIC_BUILTINS */ + fprintf(stderr, "InnoDB: %s\n", IB_ATOMICS_STARTUP_MSG); /* Since InnoDB does not currently clean up all its internal data structures in MySQL Embedded Server Library server_end(), we