~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#
# Copyright (c) 2006, 2009, Innobase Oy. All Rights Reserved.
# 
# 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., 51 Franklin
# St, Fifth Floor, Boston, MA 02110-1301 USA
#

AC_DEFUN([AC_INNODB_ACTIONS],[
  PANDORA_REQUIRE_FLEX

  AC_REQUIRE([AC_FUNC_MMAP])

  AC_CHECK_LIB(rt, aio_read, [innodb_system_libs="-lrt"])
  AC_SUBST(innodb_system_libs)
  AC_CHECK_HEADERS(aio.h sched.h)
  AC_CHECK_SIZEOF(int, 4)
  AC_CHECK_SIZEOF(long, 4)
  AC_CHECK_SIZEOF(void*, 4)
  AC_CHECK_FUNCS(sched_yield fdatasync localtime_r pread)
  AC_CHECK_FUNCS([uname munmap memchr getpagesize bzero])
  AC_C_BIGENDIAN
  case "$target_os" in
         lin*)
           AM_CFLAGS="$AM_CFLAGS -DUNIV_LINUX";;
         hpux10*)
           AM_CFLAGS="$AM_CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
         hp*)
           AM_CFLAGS="$AM_CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
         aix*)
           AM_CFLAGS="$AM_CFLAGS -DUNIV_AIX";;
         irix*|osf*|sysv5uw7*|openbsd*)
           AM_CFLAGS="$AM_CFLAGS -DUNIV_MUST_NOT_INLINE";;
	 *solaris*|*SunOS*)
		# Begin Solaris atomic function checks
		AC_CHECK_FUNCS([atomic_cas_ulong atomic_cas_32 \
			       atomic_cas_64 atomic_add_long],
                              [plugin_innodb_have_solaris_atomics=yes],
                              [plugin_innodb_have_solaris_atomics=no])
 
                AS_IF([test "${plugin_innodb_have_solaris_atomics}" = "yes"],[
			AC_DEFINE([HAVE_SOLARIS_ATOMICS],
				  [1],
			  	  [Define to 1 if Solaris supports \
				   atomic functions.])
                ])
		### End Solaris atomic function checks
           AM_CFLAGS="$AM_CFLAGS -DUNIV_SOLARIS";;
  esac
  INNODB_DYNAMIC_CFLAGS="-DPANDORA_DYNAMIC_PLUGIN"
  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)

  AC_CACHE_CHECK([whether pthread_t can be used by GCC atomic builtins],
    [ac_cv_plugin_innodb_have_gcc_atomic],[
    AC_RUN_IFELSE([
      AC_LANG_PROGRAM([[
      #include <pthread.h>
      #include <string.h>
      ]],[[
        pthread_t       x1;
        pthread_t       x2;
        pthread_t       x3;

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

        __sync_bool_compare_and_swap(&x1, x2, x3);
      ]])],
      [ac_cv_plugin_innodb_have_gcc_atomic=yes],
      [ac_cv_plugin_innodb_have_gcc_atomic=no])
    ])
  AS_IF([test "${ac_cv_plugin_innodb_have_gcc_atomic}" = "yes"],[
      AC_DEFINE([HAVE_ATOMIC_PTHREAD_T], [1],
                [pthread_t can be used by GCC atomic builtins])
  ])

  AC_CACHE_CHECK(
    [whether __attribute__ visibility "hidden" is supported],
    [ac_cv_can_use_hidden_],[
      AC_LANG_PUSH(C++)
      dnl Must be done once we turn on warnings and such
      save_CXXFLAGS="${CXXFLAGS}"
      CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
      AC_LINK_IFELSE([
        AC_LANG_PROGRAM(
          [[
__attribute__((visibility ("hidden")))
void testme() {  }
          ]],[[testme()]]
        )],
        [ac_cv_can_use_hidden_=yes],
        [ac_cv_can_use_hidden_=no])
      CXXFLAGS="${save_CXXFLAGS}"
      AC_LANG_POP()])
  AS_IF([test "$ac_cv_can_use_hidden_" = "yes"],[
    AC_DEFINE(HAVE_ATTR_HIDDEN, 1,
    [Define to 1 if you have support for __attribute__((visibility("hidden")))])
  ])

  # Try using solaris atomics on SunOS if GCC atomics are not available
  AS_IF([test "${ac_cv_plugin_innodb_have_gcc_atomic}" = "yes"],[
      AC_MSG_NOTICE([no need to check pthread_t size])
    ],[
    AS_IF([test "${ac_cv_plugin_innodb_have_solaris_atomics}" = "yes"],[
      AC_CACHE_CHECK([checking if pthread_t size is integral],
        [ac_cv_plugin_innodb_pthread_integral],[
          AC_COMPILE_IFELSE([
            AC_LANG_PROGRAM([[
              #include <pthread.h>
            ]],[[
                pthread_t x = 0;
            ]])],[
              ac_cv_plugin_innodb_pthread_integral=yes
            ],[
              ac_cv_plugin_innodb_pthread_integral=no
            ])
        ])
      AS_IF([test "${ac_cv_plugin_innodb_pthread_integral}" = "yes"],[        
        AC_DEFINE([HAVE_ATOMIC_PTHREAD_T], [1],
                [pthread_t can be used by solaris atomics])
      ])
      # size of pthread_t is needed for typed solaris atomics
      AC_CHECK_SIZEOF([pthread_t], [], [
#include <pthread.h>
        ])
    ])
  ])

  # Check for x86 PAUSE instruction
  AC_CACHE_CHECK([for x86 PAUSE instruction],[ac_cv_plugin_innodb_has_pause],[
  # 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.
  dnl Must be done once we turn on warnings and such
  save_CFLAGS="${CFLAGS}"
  CFLAGS="${AM_CFLAGS} ${CFLAGS}"
  AC_RUN_IFELSE([AC_LANG_PROGRAM([[]],[[
        __asm__ __volatile__ ("pause");
    ]])],[
      ac_cv_plugin_innodb_has_pause=yes
    ],[
      ac_cv_plugin_innodb_has_pause=no
    ])
  ])
  CFLAGS="${save_CFLAGS}"
  AS_IF([test "${ac_cv_plugin_innodb_has_pause}" = "yes"],[
    AC_DEFINE([IB_HAVE_PAUSE_INSTRUCTION], [1],
              [Does x86 PAUSE instruction exist])
  ])

])

AC_INNODB_ACTIONS
# vim: set ft=config: