/[pdpsoft]/trunk/grid-mw-security/ees/m4/attributes.m4
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/m4/attributes.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 427 - (show annotations) (download)
Tue Jun 16 10:06:39 2009 UTC (13 years, 3 months ago) by aramv
File size: 9983 byte(s)
Moved GCC warning flags to CC_CHECK_CFLAGS macro, added attributes.m4 file from xine.sf.net
1 dnl Macros to check the presence of generic (non-typed) symbols.
2 dnl Copyright (c) 2006-2007 Diego Pettenò <flameeyes@gmail.com>
3 dnl Copyright (c) 2006-2007 xine project
4 dnl
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 2, or (at your option)
8 dnl any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 dnl 02110-1301, USA.
19 dnl
20 dnl As a special exception, the copyright owners of the
21 dnl macro gives unlimited permission to copy, distribute and modify the
22 dnl configure scripts that are the output of Autoconf when processing the
23 dnl Macro. You need not follow the terms of the GNU General Public
24 dnl License when using or distributing such scripts, even though portions
25 dnl of the text of the Macro appear in them. The GNU General Public
26 dnl License (GPL) does govern all other use of the material that
27 dnl constitutes the Autoconf Macro.
28 dnl
29 dnl This special exception to the GPL applies to versions of the
30 dnl Autoconf Macro released by this project. When you make and
31 dnl distribute a modified version of the Autoconf Macro, you may extend
32 dnl this special exception to the GPL to apply to your modified version as
33 dnl well.
34
35 AC_DEFUN([CC_CHECK_CFLAGS], [
36 AC_CACHE_CHECK([if $CC supports $1 flag],
37 AS_TR_SH([cc_cv_cflags_$1]),
38 [ac_save_CFLAGS="$CFLAGS"
39 CFLAGS="$CFLAGS $1"
40 AC_COMPILE_IFELSE([int a;],
41 [eval "AS_TR_SH([cc_cv_cflags_$1])='yes'"],
42 [eval "AS_TR_SH([cc_cv_cflags_$1])="])
43 CFLAGS="$ac_save_CFLAGS"
44 ])
45
46 if eval test [x$]AS_TR_SH([cc_cv_cflags_$1]) = xyes; then
47 ifelse([$2], , [:], [$2])
48 else
49 ifelse([$3], , [:], [$3])
50 fi
51 ])
52
53 dnl Check for a -Werror flag or equivalent. -Werror is the GCC
54 dnl and ICC flag that tells the compiler to treat all the warnings
55 dnl as fatal. We usually need this option to make sure that some
56 dnl constructs (like attributes) are not simply ignored.
57 dnl
58 dnl Other compilers don't support -Werror per se, but they support
59 dnl an equivalent flag:
60 dnl - Sun Studio compiler supports -errwarn=%all
61 AC_DEFUN([CC_CHECK_WERROR], [
62 AC_CACHE_VAL([cc_cv_werror],
63 [CC_CHECK_CFLAGS([-Werror], [cc_cv_werror=-Werror],
64 [CC_CHECK_CFLAGS([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
65 ])
66 ])
67
68 AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
69 AC_REQUIRE([CC_CHECK_WERROR])
70 ac_save_CFLAGS="$CFLAGS"
71 CFLAGS="$CFLAGS $cc_cv_werror"
72 AC_CACHE_CHECK([if compiler supports __attribute__((constructor))],
73 [cc_cv_attribute_constructor],
74 [AC_COMPILE_IFELSE([
75 void ctor() __attribute__((constructor));
76 void ctor() { int a; };
77 ],
78 [cc_cv_attribute_constructor=yes],
79 [cc_cv_attribute_constructor=no])
80 ])
81 CFLAGS="$ac_save_CFLAGS"
82
83 if test "x$cc_cv_attribute_constructor" = "xyes"; then
84 AC_DEFINE([SUPPORT_ATTRIBUTE_CONSTRUCTOR], 1, [Define this if the compiler supports the constructor attribute])
85 $1
86 else
87 true
88 $2
89 fi
90 ])
91
92 AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
93 AC_REQUIRE([CC_CHECK_WERROR])
94 ac_save_CFLAGS="$CFLAGS"
95 CFLAGS="$CFLAGS $cc_cv_werror"
96 AC_CACHE_CHECK([if compiler supports __attribute__((format(printf, n, n)))],
97 [cc_cv_attribute_format],
98 [AC_COMPILE_IFELSE([
99 void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }
100 ],
101 [cc_cv_attribute_format=yes],
102 [cc_cv_attribute_format=no])
103 ])
104 CFLAGS="$ac_save_CFLAGS"
105
106 if test "x$cc_cv_attribute_format" = "xyes"; then
107 AC_DEFINE([SUPPORT_ATTRIBUTE_FORMAT], 1, [Define this if the compiler supports the format attribute])
108 $1
109 else
110 true
111 $2
112 fi
113 ])
114
115 AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
116 AC_REQUIRE([CC_CHECK_WERROR])
117 ac_save_CFLAGS="$CFLAGS"
118 CFLAGS="$CFLAGS $cc_cv_werror"
119 AC_CACHE_CHECK([if compiler supports __attribute__((format_arg(printf)))],
120 [cc_cv_attribute_format_arg],
121 [AC_COMPILE_IFELSE([
122 void __attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }
123 ],
124 [cc_cv_attribute_format_arg=yes],
125 [cc_cv_attribute_format_arg=no])
126 ])
127 CFLAGS="$ac_save_CFLAGS"
128
129 if test "x$cc_cv_attribute_format_arg" = "xyes"; then
130 AC_DEFINE([SUPPORT_ATTRIBUTE_FORMAT_ARG], 1, [Define this if the compiler supports the format_arg attribute])
131 $1
132 else
133 true
134 $2
135 fi
136 ])
137
138 AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
139 AC_REQUIRE([CC_CHECK_WERROR])
140 AC_CACHE_CHECK([if $CC supports __attribute__((visibility("$1")))],
141 AS_TR_SH([cc_cv_attribute_visibility_$1]),
142 [ac_save_CFLAGS="$CFLAGS"
143 CFLAGS="$CFLAGS $cc_cv_werror"
144 AC_COMPILE_IFELSE([void __attribute__((visibility("$1"))) $1_function() { }],
145 [eval "AS_TR_SH([cc_cv_attribute_visibility_$1])='yes'"],
146 [eval "AS_TR_SH([cc_cv_attribute_visibility_$1])='no'"])
147 CFLAGS="$ac_save_CFLAGS"
148 ])
149
150 if eval test [x$]AS_TR_SH([cc_cv_attribute_visibility_$1]) = xyes; then
151 AC_DEFINE(AS_TR_CPP([SUPPORT_ATTRIBUTE_VISIBILITY_$1]), 1, [Define this if the compiler supports __attribute__((visibility("$1")))])
152 ifelse([$2], , [:], [$2])
153 else
154 ifelse([$3], , [:], [$3])
155 fi
156 ])
157
158 AC_DEFUN([CC_FLAG_VISIBILITY], [
159 AC_REQUIRE([CC_CHECK_WERROR])
160 ac_save_CFLAGS="$CFLAGS"
161 CFLAGS="$CFLAGS $cc_cv_werror"
162 AC_CACHE_CHECK([if compiler supports -fvisibility=hidden],
163 [cc_cv_flag_visibility],
164 [
165 save_CFLAGS=$CFLAGS
166 CFLAGS="$CFLAGS -fvisibility=hidden"
167 AC_COMPILE_IFELSE([int a;],
168 [cc_cv_flag_visibility=yes],
169 [cc_cv_flag_visibility=no])
170 CFLAGS="$save_CFLAGS"
171 ])
172 CFLAGS="$ac_save_CFLAGS"
173
174 if test "x$cc_cv_flag_visibility" = "xyes"; then
175 AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag])
176 $1
177 else
178 true
179 $2
180 fi
181 ])
182
183 AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
184 AC_REQUIRE([CC_CHECK_WERROR])
185 ac_save_CFLAGS="$CFLAGS"
186 CFLAGS="$CFLAGS $cc_cv_werror"
187 AC_CACHE_CHECK([if compiler supports __attribute__((nonnull()))],
188 [cc_cv_attribute_nonnull],
189 [AC_COMPILE_IFELSE([
190 void some_function(void *foo, void *bar) __attribute__((nonnull()));
191 void some_function(void *foo, void *bar) { foo = (void *)0; bar = (void *)0; }
192 ],
193 [cc_cv_attribute_nonnull=yes],
194 [cc_cv_attribute_nonnull=no])
195 ])
196 CFLAGS="$ac_save_CFLAGS"
197
198 if test "x$cc_cv_attribute_nonnull" = "xyes"; then
199 AC_DEFINE([SUPPORT_ATTRIBUTE_NONNULL], 1, [Define this if the compiler supports the nonnull attribute])
200 $1
201 else
202 true
203 $2
204 fi
205 ])
206
207 AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
208 AC_REQUIRE([CC_CHECK_WERROR])
209 ac_save_CFLAGS="$CFLAGS"
210 CFLAGS="$CFLAGS $cc_cv_werror"
211 AC_CACHE_CHECK([if compiler supports __attribute__((unused))],
212 [cc_cv_attribute_unused],
213 [AC_COMPILE_IFELSE([
214 void some_function(void *foo, __attribute__((unused)) void *bar);
215 ],
216 [cc_cv_attribute_unused=yes],
217 [cc_cv_attribute_unused=no])
218 ])
219 CFLAGS="$ac_save_CFLAGS"
220
221 if test "x$cc_cv_attribute_unused" = "xyes"; then
222 AC_DEFINE([SUPPORT_ATTRIBUTE_UNUSED], 1, [Define this if the compiler supports the unused attribute])
223 $1
224 else
225 true
226 $2
227 fi
228 ])
229
230 AC_DEFUN([CC_FUNC_EXPECT], [
231 AC_REQUIRE([CC_CHECK_WERROR])
232 ac_save_CFLAGS="$CFLAGS"
233 CFLAGS="$CFLAGS $cc_cv_werror"
234 AC_CACHE_CHECK([if compiler has __builtin_expect function],
235 [cc_cv_func_expect],
236 [AC_COMPILE_IFELSE([
237 int some_function()
238 {
239 int a = 3;
240 return (int)__builtin_expect(a, 3);
241 }
242 ],
243 [cc_cv_func_expect=yes],
244 [cc_cv_func_expect=no])
245 ])
246 CFLAGS="$ac_save_CFLAGS"
247
248 if test "x$cc_cv_func_expect" = "xyes"; then
249 AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function])
250 $1
251 else
252 true
253 $2
254 fi
255 ])
256
257 AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
258 AC_REQUIRE([CC_CHECK_WERROR])
259 ac_save_CFLAGS="$CFLAGS"
260 CFLAGS="$CFLAGS $cc_cv_werror"
261 AC_CACHE_CHECK([if compiler supports __attribute__((sentinel))],
262 [cc_cv_attribute_sentinel],
263 [AC_COMPILE_IFELSE([
264 void some_function(void *foo, ...) __attribute__((sentinel));
265 ],
266 [cc_cv_attribute_sentinel=yes],
267 [cc_cv_attribute_sentinel=no])
268 ])
269 CFLAGS="$ac_save_CFLAGS"
270
271 if test "x$cc_cv_attribute_sentinel" = "xyes"; then
272 AC_DEFINE([SUPPORT_ATTRIBUTE_SENTINEL], 1, [Define this if the compiler supports the sentinel attribute])
273 $1
274 else
275 true
276 $2
277 fi
278 ])
279
280 AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
281 AC_REQUIRE([CC_CHECK_WERROR])
282 ac_save_CFLAGS="$CFLAGS"
283 CFLAGS="$CFLAGS $cc_cv_werror"
284 AC_CACHE_CHECK([if compiler supports __attribute__((weak, alias))],
285 [cc_cv_attribute_alias],
286 [AC_COMPILE_IFELSE([
287 void other_function(void *foo) { }
288 void some_function(void *foo) __attribute__((weak, alias("other_function")));
289 ],
290 [cc_cv_attribute_alias=yes],
291 [cc_cv_attribute_alias=no])
292 ])
293 CFLAGS="$ac_save_CFLAGS"
294
295 if test "x$cc_cv_attribute_alias" = "xyes"; then
296 AC_DEFINE([SUPPORT_ATTRIBUTE_ALIAS], 1, [Define this if the compiler supports the alias attribute])
297 $1
298 else
299 true
300 $2
301 fi
302 ])
303
304 AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
305 AC_REQUIRE([CC_CHECK_WERROR])
306 AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
307 [cc_cv_attribute_aligned],
308 [ac_save_CFLAGS="$CFLAGS"
309 CFLAGS="$CFLAGS $cc_cv_werror"
310 for cc_attribute_align_try in 64 32 16 8 4 2; do
311 AC_COMPILE_IFELSE([
312 int main() {
313 static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
314 return c;
315 }], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
316 done
317 CFLAGS="$ac_save_CFLAGS"
318 ])
319
320 if test "x$cc_cv_attribute_aligned" != "x"; then
321 AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
322 [Define the highest alignment supported])
323 fi
324 ])

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28