[kaffe] basic support for gcc __attributes__

Adam Heath doogie at debian.org
Sun Mar 28 18:14:02 PST 2004


Attached you will find files to enable checking of __attribute__ in configure.
Apply to cvs.

I'll be sending more patches to actually make use of these macros next.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: configure.ac.diff
Url: http://kaffe.org/pipermail/kaffe/attachments/20040328/8f9c4544/attachment-0002.txt 
-------------- next part --------------
dnl CACHED_TRY_COMPILE(<description>,<cachevar>,<include>,<program>,<ifyes>,<ifno>)
AC_DEFUN([CACHED_TRY_COMPILE],[
 AC_MSG_CHECKING($1)
 AC_CACHE_VAL($2,[
  AC_TRY_COMPILE([$3],[$4],[$2=yes],[$2=no])
 ])
 if test "x$$2" = xyes; then
  true
  $5
 else
  true
  $6
 fi
])

dnl GCC_ATTRIBUTE(<short-label>,<cachevar>,<func-params>,<attribute>,<HAVE>,<desc>,[<true-cmds>],[<false-cmds>])
AC_DEFUN([GCC_ATTRIBUTE],[
  CACHED_TRY_COMPILE(__attribute__(($1)),cv_c_gcc_attribute_$2,,
   [extern int testfunction($3) __attribute__(($4))],
   AC_MSG_RESULT(yes)
   AC_DEFINE(HAVE_GNUC25_$5,,$6)
   $7,
   AC_MSG_RESULT(no)
   $8)
])


AC_DEFUN([GCC_ATTRIBUTE_SUPPORTED],[
 GCC_ATTRIBUTE([,,],supported,[int x],[,,],ATTRIB,[Define if function attributes a la GCC 2.5 and higher are available.])
 AH_BOTTOM([/* GNU C attributes. */
#ifndef FUNCATTR
#ifdef HAVE_GNUC25_ATTRIB
#define FUNCATTR(x) __attribute__(x)
#else
#define FUNCATTR(x)
#endif
#endif])

])
AC_DEFUN([GCC_ATTRIBUTE_CONST],[
 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
 GCC_ATTRIBUTE(const,const,[int x],const,CONST,[Define if constant functions a la GCC 2.5 and higher are available.])
 AH_BOTTOM([/* GNU C constant functions, or null. */
#ifndef ATTRCONST
#ifdef HAVE_GNUC25_CONST
#define ATTRCONST const
#else
#define ATTRCONST
#endif
#endif
#ifndef CONSTANT
#define CONSTANT FUNCATTR((ATTRCONST))
#endif])
])
AC_DEFUN([GCC_ATTRIBUTE_NORETURN],[
 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
 GCC_ATTRIBUTE(noreturn,noreturn,[int x],noreturn,NORETURN,[Define if nonreturning functions a la GCC 2.5 and higher are available.])
 AH_BOTTOM([/* GNU C nonreturning functions, or null. */
#ifndef ATTRNORETURN
#ifdef HAVE_GNUC25_NORETURN
#define ATTRNORETURN noreturn
#else /* ! HAVE_GNUC25_NORETURN */
#define ATTRNORETURN
#endif /* HAVE_GNUC25_NORETURN */
#endif /* ATTRNORETURN */
#ifndef NONRETURNING
#define NONRETURNING FUNCATTR((ATTRNORETURN))
#endif /* NONRETURNING */])
])
AC_DEFUN([GCC_ATTRIBUTE_UNUSED],[
 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
 GCC_ATTRIBUTE(unused,unused,[int x],unused,UNUSED,[Define if unused variables la GCC 2.5 and higher are available.])
 AH_BOTTOM([/* GNU C unused functions, or null. */
#ifndef ATTRUNUSED
#ifdef HAVE_GNUC25_UNUSED
#define ATTRUNUSED
#else
#define ATTRUNUSED
#endif
#endif
#ifndef UNUSED
#define UNUSED FUNCATTR((ATTRUNUSED))
#endif])
])
AC_DEFUN([GCC_ATTRIBUTE_FORMAT],[
 AC_REQUIRE([GCC_ATTRIBUTE_SUPPORTED])
 GCC_ATTRIBUTE(format...,format,[char *y, ...],[format(printf,1,2)],PRINTFFORMAT,[Define if printf-format argument lists a la GCC are available.])
 AH_BOTTOM([/* GNU C printf formats, or null. */
#ifndef ATTRPRINTF
#ifdef HAVE_GNUC25_PRINTFFORMAT
#define ATTRPRINTF(si,tc) format(printf,si,tc)
#else
#define ATTRPRINTF(si,tc)
#endif
#endif
#ifndef PRINTFFORMAT
#define PRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc)))
#endif

#ifndef NONRETURNPRINTFFORMAT
#define NONRETURNPRINTFFORMAT(si,tc) FUNCATTR((ATTRPRINTF(si,tc),ATTRNORETURN))
#endif])
])


More information about the kaffe mailing list