Index: srv/srv0start.c =================================================================== --- srv/srv0start.c (revision 5708) +++ srv/srv0start.c (working copy) @@ -1103,13 +1103,13 @@ innobase_start_or_create_for_mysql(void) if (UNIV_LIKELY(srv_use_sys_malloc)) { fprintf(stderr, "InnoDB: The InnoDB memory heap is disabled\n"); } -#ifdef HAVE_GCC_ATOMIC_BUILTINS +#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"); @@ -1127,16 +1127,16 @@ innobase_start_or_create_for_mysql(void) 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_GCC_ATOMIC_BUILTINS */ +#else /* HAVE_IB_GCC_ATOMIC_BUILTINS */ fprintf(stderr, "InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n"); -#endif /* HAVE_GCC_ATOMIC_BUILTINS */ +#endif /* HAVE_IB_GCC_ATOMIC_BUILTINS */ /* Since InnoDB does not currently clean up all its internal data structures in MySQL Embedded Server Library server_end(), we print an error message if someone tries to start up InnoDB a second time during the process lifetime. */ Index: include/univ.i =================================================================== --- include/univ.i (revision 5708) +++ include/univ.i (working copy) @@ -122,17 +122,17 @@ if we are compiling on Windows. */ # endif # ifdef HAVE_SCHED_H # include # endif -# if defined(HAVE_GCC_ATOMIC_BUILTINS) || defined(HAVE_SOLARIS_ATOMICS) \ +# if defined(HAVE_IB_GCC_ATOMIC_BUILTINS) || defined(HAVE_SOLARIS_ATOMICS) \ || defined(HAVE_WINDOWS_ATOMICS) /* If atomics are defined we use them in InnoDB mutex implementation */ # define HAVE_ATOMIC_BUILTINS -# endif /* (HAVE_GCC_ATOMIC_BUILTINS) || (HAVE_SOLARIS_ATOMICS) +# endif /* (HAVE_IB_GCC_ATOMIC_BUILTINS) || (HAVE_SOLARIS_ATOMICS) || (HAVE_WINDOWS_ATOMICS) */ /* For InnoDB rw_locks to work with atomics we need the thread_id to be no more than machine word wide. The following enables using atomics for InnoDB rw_locks where these conditions are met. */ #ifdef HAVE_ATOMIC_BUILTINS Index: include/os0sync.h =================================================================== --- include/os0sync.h (revision 5708) +++ include/os0sync.h (working copy) @@ -282,13 +282,13 @@ os_fast_mutex_free( /*===============*/ os_fast_mutex_t* fast_mutex); /*!< in: mutex to free */ /**********************************************************//** Atomic compare-and-swap and increment for InnoDB. */ -#ifdef HAVE_GCC_ATOMIC_BUILTINS +#ifdef HAVE_IB_GCC_ATOMIC_BUILTINS /**********************************************************//** Returns true if swapped, ptr is pointer to target, old_val is value to compare to, new_val is the value to swap in. */ # define os_compare_and_swap(ptr, old_val, new_val) \ __sync_bool_compare_and_swap(ptr, old_val, new_val) # define os_compare_and_swap_ulint(ptr, old_val, new_val) \ @@ -374,13 +374,13 @@ amount of increment. */ /**********************************************************//** Returns the old value of *ptr, atomically sets *ptr to new_val. InterlockedExchange() operates on LONG, and the LONG will be clobbered */ # define os_atomic_test_and_set_byte(ptr, new_val) \ ((byte) InterlockedExchange(ptr, new_val)) -#endif /* HAVE_GCC_ATOMIC_BUILTINS */ +#endif /* HAVE_IB_GCC_ATOMIC_BUILTINS */ #ifndef UNIV_NONINL #include "os0sync.ic" #endif #endif Index: plug.in =================================================================== --- plug.in (revision 5708) +++ plug.in (working copy) @@ -58,12 +58,63 @@ MYSQL_PLUGIN_ACTIONS(innobase, [ *86) # Use absolute addresses on IA-32 INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic" ;; esac AC_SUBST(INNODB_DYNAMIC_CFLAGS) + + AC_MSG_CHECKING(whether GCC atomic builtins are available) + AC_TRY_RUN( + [ + int main() + { + long x; + long y; + long res; + char c; + + x = 10; + y = 123; + res = __sync_bool_compare_and_swap(&x, x, y); + if (!res || x != y) { + return(1); + } + + x = 10; + y = 123; + res = __sync_bool_compare_and_swap(&x, x + 1, y); + if (res || x != 10) { + return(1); + } + + x = 10; + y = 123; + res = __sync_add_and_fetch(&x, y); + if (res != 133 || x != 133) { + return(1); + } + + c = 10; + res = __sync_lock_test_and_set(&c, 123); + if (res != 10 || c != 123) { + return(1); + } + + return(0); + } + ], + [ + AC_DEFINE([HAVE_IB_GCC_ATOMIC_BUILTINS], [1], + [GCC atomic builtins are available]) + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + ] + ) + AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins) AC_TRY_RUN( [ #include #include