mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / innodb_plugin / plug.in
blob4944738d568ffe66a86031c479573ffc458eaeb7
2 # Copyright (c) 2006, 2010, Innobase Oy. All Rights Reserved.
3
4 # This program is free software; you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License as published by the Free Software
6 # Foundation; version 2 of the License.
7
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11
12 # You should have received a copy of the GNU General Public License along with
13 # this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
14 # Fifth Floor, Boston, MA 02110-1301, USA
17 MYSQL_STORAGE_ENGINE(innodb_plugin,, [InnoDB Storage Engine],
18         [Transactional Tables using InnoDB], [max,max-no-ndb])
19 MYSQL_PLUGIN_DIRECTORY(innodb_plugin, [storage/innodb_plugin])
20 # Enable if you know what you are doing (trying to link both InnoDB and
21 # InnoDB Plugin statically into MySQL does not work).
22 #MYSQL_PLUGIN_STATIC(innodb_plugin, [libinnobase.a])
23 MYSQL_PLUGIN_DYNAMIC(innodb_plugin,  [ha_innodb_plugin.la])
24 MYSQL_PLUGIN_ACTIONS(innodb_plugin,  [
25   AC_CHECK_HEADERS(sched.h)
26   AC_CHECK_SIZEOF(int, 4)
27   AC_CHECK_SIZEOF(long, 4)
28   AC_CHECK_SIZEOF(void*, 4)
29   AC_CHECK_FUNCS(sched_yield fdatasync localtime_r)
30   AC_C_BIGENDIAN
31   case "$target_os" in
32         lin*)
33                 CFLAGS="$CFLAGS -DUNIV_LINUX";;
34         hpux10*)
35                 CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
36         hp*)
37                 CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
38         aix*)
39                 CFLAGS="$CFLAGS -DUNIV_AIX";;
40         irix*|osf*|sysv5uw7*|openbsd*)
41                 CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
42         *solaris*|*SunOS*)
43                 CFLAGS="$CFLAGS -DUNIV_SOLARIS";;
44   esac
46   INNODB_DYNAMIC_CFLAGS="-DMYSQL_DYNAMIC_PLUGIN"
48   case "$target_cpu" in
49         x86_64)
50                 # The AMD64 ABI forbids absolute addresses in shared libraries
51                 ;;
52         *86)
53                 # Use absolute addresses on IA-32
54                 INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic"
55                 ;;
56   esac
57   AC_SUBST(INNODB_DYNAMIC_CFLAGS)
59   AC_MSG_CHECKING(whether GCC atomic builtins are available)
60   # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
61   AC_TRY_RUN(
62     [
63       int main()
64       {
65         long    x;
66         long    y;
67         long    res;
68         char    c;
70         x = 10;
71         y = 123;
72         res = __sync_bool_compare_and_swap(&x, x, y);
73         if (!res || x != y) {
74           return(1);
75         }
77         x = 10;
78         y = 123;
79         res = __sync_bool_compare_and_swap(&x, x + 1, y);
80         if (res || x != 10) {
81           return(1);
82         }
84         x = 10;
85         y = 123;
86         res = __sync_add_and_fetch(&x, y);
87         if (res != 123 + 10 || x != 123 + 10) {
88           return(1);
89         }
91         c = 10;
92         res = __sync_lock_test_and_set(&c, 123);
93         if (res != 10 || c != 123) {
94           return(1);
95         }
97         return(0);
98       }
99     ],
100     [
101       AC_DEFINE([HAVE_IB_GCC_ATOMIC_BUILTINS], [1],
102                 [GCC atomic builtins are available])
103       AC_MSG_RESULT(yes)
104     ],
105     [
106       AC_MSG_RESULT(no)
107     ]
108   )
110   AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins)
111   # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
112   AC_TRY_RUN(
113     [
114       #include <pthread.h>
115       #include <string.h>
117       int main(int argc, char** argv) {
118         pthread_t       x1;
119         pthread_t       x2;
120         pthread_t       x3;
122         memset(&x1, 0x0, sizeof(x1));
123         memset(&x2, 0x0, sizeof(x2));
124         memset(&x3, 0x0, sizeof(x3));
126         __sync_bool_compare_and_swap(&x1, x2, x3);
128         return(0);
129       }
130     ],
131     [
132       AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_GCC], [1],
133                 [pthread_t can be used by GCC atomic builtins])
134       AC_MSG_RESULT(yes)
135     ],
136     [
137       AC_MSG_RESULT(no)
138     ]
139   )
141   AC_MSG_CHECKING(whether Solaris libc atomic functions are available)
142   # Define HAVE_IB_SOLARIS_ATOMICS if _all_ of the following
143   # functions are present.
144   AC_CHECK_FUNCS(atomic_add_long_nv \
145                  atomic_cas_32 \
146                  atomic_cas_64 \
147                  atomic_cas_ulong \
148                  atomic_swap_uchar)
150   if test "${ac_cv_func_atomic_add_long_nv}" = "yes" -a \
151           "${ac_cv_func_atomic_cas_32}" = "yes" -a \
152           "${ac_cv_func_atomic_cas_64}" = "yes" -a \
153           "${ac_cv_func_atomic_cas_ulong}" = "yes" -a \
154           "${ac_cv_func_atomic_swap_uchar}" = "yes" ; then
156     AC_DEFINE([HAVE_IB_SOLARIS_ATOMICS], [1],
157       [Define to 1 if Solaris libc atomic functions are available]
158     )
159   fi
161   AC_MSG_CHECKING(whether pthread_t can be used by Solaris libc atomic functions)
162   # either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
163   AC_TRY_RUN(
164     [
165       #include <pthread.h>
166       #include <string.h>
168       int main(int argc, char** argv) {
169         pthread_t       x1;
170         pthread_t       x2;
171         pthread_t       x3;
173         memset(&x1, 0x0, sizeof(x1));
174         memset(&x2, 0x0, sizeof(x2));
175         memset(&x3, 0x0, sizeof(x3));
177         if (sizeof(pthread_t) == 4) {
178         
179           atomic_cas_32(&x1, x2, x3);
180         
181         } else if (sizeof(pthread_t) == 8) {
182         
183           atomic_cas_64(&x1, x2, x3);
184         
185         } else {
186         
187           return(1);
188         }
190         return(0);
191       }
192     ],
193     [
194       AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS], [1],
195                 [pthread_t can be used by solaris atomics])
196       AC_MSG_RESULT(yes)
197     ],
198     [
199       AC_MSG_RESULT(no)
200     ]
201   )
203   # this is needed to know which one of atomic_cas_32() or atomic_cas_64()
204   # to use in the source
205   AC_CHECK_SIZEOF([pthread_t], [], [#include <pthread.h>])
207   # Check for x86 PAUSE instruction
208   AC_MSG_CHECKING(for x86 PAUSE instruction)
209   # We have to actually try running the test program, because of a bug
210   # in Solaris on x86_64, where it wrongly reports that PAUSE is not
211   # supported when trying to run an application. See
212   # http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6478684
213   # We use ib_ prefix to avoid collisoins if this code is added to
214   # mysql's configure.in.
215   AC_TRY_RUN(
216     [
217       int main() {
218         __asm__ __volatile__ ("pause");
219         return(0);
220       }
221     ],
222     [
223       AC_DEFINE([HAVE_IB_PAUSE_INSTRUCTION], [1], [Does x86 PAUSE instruction exist])
224       AC_MSG_RESULT(yes)
225     ],
226     [
227       AC_MSG_RESULT(no)
228     ],
229     [
230       AC_MSG_RESULT(no)
231     ]
232   )
233   ])
235 # vim: set ft=config: