1 dnl CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
2 AC_DEFUN([CACHED_TRY_COMPILE],[
5 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],[$2=yes],[$2=no])
7 if test "x$$2" = xyes; then
16 dnl GCC_ATTRIBUTE(<short-label>,<cachevar>,<func-params>,<attribute>,<HAVE>,<desc>,[<true-cmds>],[<false-cmds>])
17 AC_DEFUN([GCC_ATTRIBUTE],[
18 CACHED_TRY_COMPILE(__attribute__(($1)),gcc_cv_c_gcc_attribute_$2,,
19 [extern int testfunction($3) __attribute__(($4))],
21 AC_DEFINE(HAVE_GNUC25_$5,,$6)
28 AC_DEFUN([GCC_ATTRIBUTE_SUPPORTED],[
29 GCC_ATTRIBUTE([,,],supported,[int x],[,,],ATTRIB,[Define if function attributes a la GCC 2.5 and higher are available.])
30 AH_BOTTOM([/* GNU C attributes. */
32 #ifdef HAVE_GNUC25_ATTRIB
33 #define FUNCATTR(x) __attribute__(x)
40 AC_DEFUN([GCC_ATTRIBUTE_CONST],[
41 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
42 GCC_ATTRIBUTE(const,const,[int x],const,CONST,[Define if constant functions a la GCC 2.5 and higher are available.])
43 AH_BOTTOM([/* GNU C constant functions, or null. */
45 #ifdef HAVE_GNUC25_CONST
46 #define ATTRCONST const
52 #define CONSTANT FUNCATTR((ATTRCONST))
55 AC_DEFUN([GCC_ATTRIBUTE_NORETURN],[
56 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
57 GCC_ATTRIBUTE(noreturn,noreturn,[int x],noreturn,NORETURN,[Define if nonreturning functions a la GCC 2.5 and higher are available.])
58 AH_BOTTOM([/* GNU C nonreturning functions, or null. */
60 #ifdef HAVE_GNUC25_NORETURN
61 #define ATTRNORETURN noreturn
62 #else /* ! HAVE_GNUC25_NORETURN */
64 #endif /* HAVE_GNUC25_NORETURN */
65 #endif /* ATTRNORETURN */
67 #define NONRETURNING FUNCATTR((ATTRNORETURN))
68 #endif /* NONRETURNING */])
70 AC_DEFUN([GCC_ATTRIBUTE_UNUSED],[
71 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
72 GCC_ATTRIBUTE(unused,unused,[int x],unused,UNUSED,[Define if unused variables la GCC 2.5 and higher are available.])
73 AH_BOTTOM([/* GNU C unused functions, or null. */
75 #ifdef HAVE_GNUC25_UNUSED
76 #define ATTRUNUSED unused
82 #define UNUSED FUNCATTR((ATTRUNUSED))
85 AC_DEFUN([GCC_ATTRIBUTE_FORMAT],[
86 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
87 GCC_ATTRIBUTE(format...,format,[char *y, ...],[format(printf,1,2)],PRINTFFORMAT,[Define if printf-format argument lists a la GCC are available.])
88 AH_BOTTOM([/* GNU C printf formats, or null. */
90 #ifdef HAVE_GNUC25_PRINTFFORMAT
91 #define ATTRPRINTF(si,tc) format(printf,si,tc)
93 #define ATTRPRINTF(si,tc)
97 #define PRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc)))
100 #ifndef NONRETURNPRINTFFORMAT
101 #define NONRETURNPRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc),ATTRNORETURN))
104 AC_DEFUN([GCC_ATTRIBUTE_ALWAYS_INLINE],[
105 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
106 GCC_ATTRIBUTE(always_inline,always_inline,[int x],always_inline,ALWAYS_INLINE,[Define if unconditional inlining of functions a la GCC 3.1 and higher are available.])
107 AH_BOTTOM([/* GNU C constant functions, or null. */
108 #ifndef ATTRALWAYS_INLINE
109 #ifdef HAVE_GNUC25_ALWAYS_INLINE
110 #define ATTRALWAYS_INLINE always_inline
112 #define ATTRALWAYS_INLINE
115 #ifndef ALWAYS_INLINE
116 #define ALWAYS_INLINE FUNCATTR((ATTRALWAYS_INLINE))
119 AC_DEFUN([GCC_ATTRIBUTE_PACKED],[
120 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
121 GCC_ATTRIBUTE(packed,packed,[int x],packed,PACKED,[Define if packing of struct members a la GCC 2.5 and higher is available.])
122 AH_BOTTOM([/* GNU C constant functions, or null. */
124 #ifdef HAVE_GNUC25_PACKED
125 #define ATTRPACKED packed
131 #define PACKED FUNCATTR((ATTRPACKED))