plug.in 5.55 KB
Newer Older
vasil's avatar
vasil committed
1
#
2
# Copyright (c) 2006, 2010, Innobase Oy. All Rights Reserved.
vasil's avatar
vasil committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16
# 
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
# 
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#

17
MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
18
        [Transactional Tables using InnoDB], [max,max-no-ndb])
19 20 21 22
MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
MYSQL_PLUGIN_STATIC(innobase,   [libinnobase.a])
MYSQL_PLUGIN_DYNAMIC(innobase,  [ha_innodb.la])
MYSQL_PLUGIN_ACTIONS(innobase,  [
23
  AC_CHECK_HEADERS(sched.h)
24 25 26
  AC_CHECK_SIZEOF(int, 4)
  AC_CHECK_SIZEOF(long, 4)
  AC_CHECK_SIZEOF(void*, 4)
27
  AC_CHECK_FUNCS(sched_yield fdatasync localtime_r)
28 29
  AC_C_BIGENDIAN
  case "$target_os" in
30
	lin*)
inaam's avatar
inaam committed
31
		CFLAGS="$CFLAGS -DUNIV_LINUX";;
32
	hpux10*)
inaam's avatar
inaam committed
33
		CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
34
	hp*)
inaam's avatar
inaam committed
35
		CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
36
	aix*)
inaam's avatar
inaam committed
37
		CFLAGS="$CFLAGS -DUNIV_AIX";;
38
	irix*|osf*|sysv5uw7*|openbsd*)
inaam's avatar
inaam committed
39
		CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
40
	*solaris*|*SunOS*)
inaam's avatar
inaam committed
41
		CFLAGS="$CFLAGS -DUNIV_SOLARIS";;
42
  esac
vasil's avatar
vasil committed
43

44
  INNODB_DYNAMIC_CFLAGS="-DMYSQL_DYNAMIC_PLUGIN"
vasil's avatar
vasil committed
45

46 47 48 49 50 51 52 53 54 55
  case "$target_cpu" in
	x86_64)
		# The AMD64 ABI forbids absolute addresses in shared libraries
		;;
	*86)
		# Use absolute addresses on IA-32
		INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic"
		;;
  esac
  AC_SUBST(INNODB_DYNAMIC_CFLAGS)
vasil's avatar
vasil committed
56 57

  AC_MSG_CHECKING(whether GCC atomic builtins are available)
vasil's avatar
vasil committed
58
  # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
vasil's avatar
vasil committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
  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 != 123 + 10 || x != 123 + 10) {
	  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)
    ]
vasil's avatar
vasil committed
106
  )
vasil's avatar
vasil committed
107

vasil's avatar
vasil committed
108
  AC_MSG_CHECKING(whether pthread_t can be used by GCC atomic builtins)
vasil's avatar
vasil committed
109
  # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
vasil's avatar
vasil committed
110 111 112
  AC_TRY_RUN(
    [
      #include <pthread.h>
vasil's avatar
vasil committed
113
      #include <string.h>
vasil's avatar
vasil committed
114 115 116 117 118 119

      int main(int argc, char** argv) {
        pthread_t       x1;
        pthread_t       x2;
        pthread_t       x3;

vasil's avatar
vasil committed
120 121 122 123
	memset(&x1, 0x0, sizeof(x1));
	memset(&x2, 0x0, sizeof(x2));
	memset(&x3, 0x0, sizeof(x3));

vasil's avatar
vasil committed
124 125 126 127 128 129
        __sync_bool_compare_and_swap(&x1, x2, x3);

        return(0);
      }
    ],
    [
vasil's avatar
vasil committed
130
      AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_GCC], [1],
vasil's avatar
vasil committed
131 132 133 134 135 136
                [pthread_t can be used by GCC atomic builtins])
      AC_MSG_RESULT(yes)
    ],
    [
      AC_MSG_RESULT(no)
    ]
vasil's avatar
vasil committed
137
  )
inaam's avatar
inaam committed
138

vasil's avatar
vasil committed
139
  AC_MSG_CHECKING(whether Solaris libc atomic functions are available)
vasil's avatar
vasil committed
140
  # either define HAVE_IB_SOLARIS_ATOMICS or not
vasil's avatar
vasil committed
141 142 143 144 145
  AC_CHECK_FUNCS(atomic_add_long \
		 atomic_cas_32 \
		 atomic_cas_64 \
		 atomic_cas_ulong,

vasil's avatar
vasil committed
146
		 AC_DEFINE([HAVE_IB_SOLARIS_ATOMICS], [1],
vasil's avatar
vasil committed
147 148 149 150 151
			   [Define to 1 if Solaris libc atomic functions \
			    are available])
  )

  AC_MSG_CHECKING(whether pthread_t can be used by Solaris libc atomic functions)
vasil's avatar
vasil committed
152
  # either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
vasil's avatar
vasil committed
153
  AC_TRY_RUN(
inaam's avatar
inaam committed
154
    [
vasil's avatar
vasil committed
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
      #include <pthread.h>
      #include <string.h>

      int main(int argc, char** argv) {
        pthread_t       x1;
        pthread_t       x2;
        pthread_t       x3;

        memset(&x1, 0x0, sizeof(x1));
        memset(&x2, 0x0, sizeof(x2));
        memset(&x3, 0x0, sizeof(x3));

        if (sizeof(pthread_t) == 4) {
        
          atomic_cas_32(&x1, x2, x3);
        
        } else if (sizeof(pthread_t) == 8) {
        
          atomic_cas_64(&x1, x2, x3);
        
        } else {
        
          return(1);
        }
vasil's avatar
vasil committed
179 180

	return(0);
vasil's avatar
vasil committed
181
      }
inaam's avatar
inaam committed
182 183
    ],
    [
vasil's avatar
vasil committed
184
      AC_DEFINE([HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS], [1],
inaam's avatar
inaam committed
185
                [pthread_t can be used by solaris atomics])
vasil's avatar
vasil committed
186 187 188 189 190 191 192 193 194 195 196
      AC_MSG_RESULT(yes)
    ],
    [
      AC_MSG_RESULT(no)
    ]
  )

  # this is needed to know which one of atomic_cas_32() or atomic_cas_64()
  # to use in the source
  AC_CHECK_SIZEOF([pthread_t], [], [#include <pthread.h>])

vasil's avatar
vasil committed
197
  # Check for x86 PAUSE instruction
vasil's avatar
vasil committed
198
  AC_MSG_CHECKING(for x86 PAUSE instruction)
vasil's avatar
vasil committed
199 200 201 202 203 204
  # We have to actually try running the test program, because of a bug
  # in Solaris on x86_64, where it wrongly reports that PAUSE is not
  # supported when trying to run an application. See
  # http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6478684
  # We use ib_ prefix to avoid collisoins if this code is added to
  # mysql's configure.in.
vasil's avatar
vasil committed
205 206
  AC_TRY_RUN(
    [
vasil's avatar
vasil committed
207 208 209 210 211
      int main() {
        __asm__ __volatile__ ("pause");
        return(0);
      }
    ],
vasil's avatar
vasil committed
212
    [
vasil's avatar
vasil committed
213
      AC_DEFINE([HAVE_IB_PAUSE_INSTRUCTION], [1], [Does x86 PAUSE instruction exist])
vasil's avatar
vasil committed
214 215 216 217 218 219 220 221
      AC_MSG_RESULT(yes)
    ],
    [
      AC_MSG_RESULT(no)
    ],
    [
      AC_MSG_RESULT(no)
    ]
vasil's avatar
vasil committed
222
  )
223 224
  ])

225
# vim: set ft=config: