Debian Codegraph @

m4/ax_gcc_type_attribute.m4

raw
1 #
2 # SYNOPSIS
3 #
4 # AX_GCC_TYPE_ATTRIBUTE(ATTRIBUTE)
5 #
6 # DESCRIPTION
7 #
8 # This macro checks if the compiler supports one of GCC's type
9 # attributes; many other compilers also provide type attributes with
10 # the same syntax. Compiler warnings are used to detect supported
11 # attributes as unsupported ones are ignored by default so quieting
12 # warnings when using this macro will yield false positives.
13 #
14 # The ATTRIBUTE parameter holds the name of the attribute to be checked.
15 #
16 # If ATTRIBUTE is supported define HAVE_TYPE_ATTRIBUTE_<ATTRIBUTE>.
17 #
18 # The macro caches its result in the ax_cv_have_type_attribute_<attribute>
19 # variable.
20 #
21 # The macro currently supports the following type attributes:
22 #
23 # transparent_union
24 #
25 # Unsupported type attributes will cause an error.
26 #
27 # LICENSE
28 #
29 # AX_GCC_TYPE_ATTRIBUTE is nearly identical to the AX_GCC_VAR_ATTRIBUTE
30 # macro, by Gabriele Svelto:
31 #
32 # Copyright (c) 2013 Gabriele Svelto <[email protected]>
33 #
34 # Copying and distribution of this file, with or without modification, are
35 # permitted in any medium without royalty provided the copyright notice
36 # and this notice are preserved. This file is offered as-is, without any
37 # warranty.
38 #
39 # Modified by Marvin Scholz <[email protected]>
40
41 #serial 5
42
43 AC_DEFUN([AX_GCC_TYPE_ATTRIBUTE], [
44 AS_VAR_PUSHDEF([ac_var], [ax_cv_have_type_attribute_$1])
45
46 AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
47 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
48 m4_case([$1],
49 [transparent_union], [
50 union __attribute__((__$1__)) { void *vp; } tu;
51 ],
52 [
53 m4_fatal([Unsupported attribute $1])
54 ]
55 )], [])
56 ],
57 dnl GCC doesn't exit with an error if an unknown attribute is
58 dnl provided but only outputs a warning, so accept the attribute
59 dnl only if no warning were issued.
60 [AS_IF([test -s conftest.err],
61 [AS_VAR_SET([ac_var], [no])],
62 [AS_VAR_SET([ac_var], [yes])])],
63 [AS_VAR_SET([ac_var], [no])])
64 ])
65
66 AS_IF([test yes = AS_VAR_GET([ac_var])],
67 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_TYPE_ATTRIBUTE_$1), 1,
68 [Define to 1 if the system has the `$1' type attribute])], [])
69
70 AS_VAR_POPDEF([ac_var])
71 ])