1dnl CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>) 2AC_DEFUN([CACHED_TRY_COMPILE],[ 3 AC_MSG_CHECKING($1) 4 AC_CACHE_VAL($2,[ 5 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],[$2=yes],[$2=no]) 6 ]) 7 if test "x$$2" = xyes; then 8 true 9 $5 10 else 11 true 12 $6 13 fi 14]) 15 16dnl GCC_ATTRIBUTE(<short-label>,<cachevar>,<func-params>,<attribute>,<HAVE>,<desc>,[<true-cmds>],[<false-cmds>]) 17AC_DEFUN([GCC_ATTRIBUTE],[ 18 CACHED_TRY_COMPILE(__attribute__(($1)),gcc_cv_c_gcc_attribute_$2,, 19 [extern int testfunction($3) __attribute__(($4))], 20 AC_MSG_RESULT(yes) 21 AC_DEFINE(HAVE_GNUC25_$5,,$6) 22 $7, 23 AC_MSG_RESULT(no) 24 $8) 25]) 26 27 28AC_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. */ 31#ifndef FUNCATTR 32#ifdef HAVE_GNUC25_ATTRIB 33#define FUNCATTR(x) __attribute__(x) 34#else 35#define FUNCATTR(x) 36#endif 37#endif]) 38 39]) 40AC_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. */ 44#ifndef ATTRCONST 45#ifdef HAVE_GNUC25_CONST 46#define ATTRCONST const 47#else 48#define ATTRCONST 49#endif 50#endif 51#ifndef CONSTANT 52#define CONSTANT FUNCATTR((ATTRCONST)) 53#endif]) 54]) 55AC_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. */ 59#ifndef ATTRNORETURN 60#ifdef HAVE_GNUC25_NORETURN 61#define ATTRNORETURN noreturn 62#else /* ! HAVE_GNUC25_NORETURN */ 63#define ATTRNORETURN 64#endif /* HAVE_GNUC25_NORETURN */ 65#endif /* ATTRNORETURN */ 66#ifndef NONRETURNING 67#define NONRETURNING FUNCATTR((ATTRNORETURN)) 68#endif /* NONRETURNING */]) 69]) 70AC_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. */ 74#ifndef ATTRUNUSED 75#ifdef HAVE_GNUC25_UNUSED 76#define ATTRUNUSED unused 77#else 78#define ATTRUNUSED 79#endif 80#endif 81#ifndef UNUSED 82#define UNUSED FUNCATTR((ATTRUNUSED)) 83#endif]) 84]) 85AC_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. */ 89#ifndef ATTRPRINTF 90#ifdef HAVE_GNUC25_PRINTFFORMAT 91#define ATTRPRINTF(si,tc) format(printf,si,tc) 92#else 93#define ATTRPRINTF(si,tc) 94#endif 95#endif 96#ifndef PRINTFFORMAT 97#define PRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc))) 98#endif 99 100#ifndef NONRETURNPRINTFFORMAT 101#define NONRETURNPRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc),ATTRNORETURN)) 102#endif]) 103]) 104AC_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 111#else 112#define ATTRALWAYS_INLINE 113#endif 114#endif 115#ifndef ALWAYS_INLINE 116#define ALWAYS_INLINE FUNCATTR((ATTRALWAYS_INLINE)) 117#endif]) 118]) 119AC_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. */ 123#ifndef ATTRPACKED 124#ifdef HAVE_GNUC25_PACKED 125#define ATTRPACKED packed 126#else 127#define ATTRPACKED 128#endif 129#endif 130#ifndef PACKED 131#define PACKED FUNCATTR((ATTRPACKED)) 132#endif]) 133]) 134