Commit 4ec11743 authored by vasil's avatar vasil

branches/zip:

Implement a check whether pthread_t objects can be used by GCC atomic
builtin functions. This check is implemented in plug.in and defines the
macro HAVE_ATOMIC_PTHREAD_T. This macro is checked in univ.i and the
relevant part of the code enabled (the one that uses GCC atomics against
pthread_t objects).

In addition to this, the same program that is compiled as part of the
plug.in check is added in ut/ut0auxconf.c. In the InnoDB Plugin source
archives that are shipped to the users, a generated Makefile.in is added.
That Makefile.in will be modified to compile ut/ut0auxconf.c and define
the macro HAVE_ATOMIC_PTHREAD_T if the compilation succeeds. I.e.
Makefile.in will emulate the work that is done by plug.in. This is done in
order to make the check happen and HAVE_ATOMIC_PTHREAD_T eventually
defined without regenerating MySQL's ./configure from
./storage/innobase/plug.in. The point is not to ask users to install the
autotools and regenerate ./configure.

rb://95

Approved by:	Marko
parent 3f05aa36
...@@ -116,10 +116,20 @@ of the 32-bit x86 assembler in mutex operations. */ ...@@ -116,10 +116,20 @@ of the 32-bit x86 assembler in mutex operations. */
/* For InnoDB rw_locks to work with atomics we need the thread_id /* 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 to be no more than machine word wide. The following enables using
atomics for InnoDB rw_locks where these conditions are met. */ atomics for InnoDB rw_locks where these conditions are met. */
# if defined(HAVE_GCC_ATOMIC_BUILTINS) && (defined(__linux__) \ #ifdef HAVE_GCC_ATOMIC_BUILTINS
|| defined(__FreeBSD__)) /* if HAVE_ATOMIC_PTHREAD_T is defined at this point that means that
the code from plug.in has defined it and we do not need to include
ut0auxconf.h which would either define HAVE_ATOMIC_PTHREAD_T or will
be empty */
# ifndef HAVE_ATOMIC_PTHREAD_T
# include "ut0auxconf.h"
# endif /* HAVE_ATOMIC_PTHREAD_T */
/* now HAVE_ATOMIC_PTHREAD_T is eventually defined either by plug.in or
from Makefile.in->ut0auxconf.h */
# ifdef HAVE_ATOMIC_PTHREAD_T
# define INNODB_RW_LOCKS_USE_ATOMICS # define INNODB_RW_LOCKS_USE_ATOMICS
# endif # endif /* HAVE_ATOMIC_PTHREAD_T */
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
/* We only try to do explicit inlining of functions with gcc and /* We only try to do explicit inlining of functions with gcc and
Microsoft Visual C++ */ Microsoft Visual C++ */
......
/* Do not remove this file even though it is empty.
This file is included in univ.i and will cause compilation failure
if not present.
A custom check has been added in the generated
storage/innobase/Makefile.in that is shipped with with the InnoDB Plugin
source archive. This check tries to compile a test program and if
successful then adds "#define HAVE_ATOMIC_PTHREAD_T" to this file.
This is a hack that has been developed in order to check for pthread_t
atomicity without the need to regenerate the ./configure script that is
distributed in the MySQL 5.1 official source archives.
If by any chance Makefile.in and ./configure are regenerated and thus
the hack from Makefile.in wiped away then the "real" check from plug.in
will take over.
*/
...@@ -51,6 +51,30 @@ MYSQL_PLUGIN_ACTIONS(innobase, [ ...@@ -51,6 +51,30 @@ MYSQL_PLUGIN_ACTIONS(innobase, [
;; ;;
esac esac
AC_SUBST(INNODB_DYNAMIC_CFLAGS) AC_SUBST(INNODB_DYNAMIC_CFLAGS)
AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins)
AC_TRY_RUN(
[
#include <pthread.h>
int main(int argc, char** argv) {
pthread_t x1;
pthread_t x2;
pthread_t x3;
__sync_bool_compare_and_swap(&x1, x2, x3);
return(0);
}
],
[
AC_DEFINE([HAVE_ATOMIC_PTHREAD_T], [1],
[pthread_t can be used by GCC atomic builtins])
AC_MSG_RESULT(yes)
],
[
AC_MSG_RESULT(no)
]
)
]) ])
# vim: set ft=config: # vim: set ft=config:
#include <pthread.h>
int
main(int argc, char** argv)
{
pthread_t x1;
pthread_t x2;
pthread_t x3;
__sync_bool_compare_and_swap(&x1, x2, x3);
return(0);
}
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