inline.m4 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # inline.m4 serial 4
  2. dnl Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl Test for the 'inline' keyword or equivalent.
  7. dnl Define 'inline' to a supported equivalent, or to nothing if not supported,
  8. dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an
  9. dnl equivalent is effectively supported, i.e. if the compiler is likely to
  10. dnl drop unused 'static inline' functions.
  11. AC_DEFUN([gl_INLINE],
  12. [
  13. AC_REQUIRE([AC_C_INLINE])
  14. AC_CACHE_CHECK([whether the compiler generally respects inline],
  15. [gl_cv_c_inline_effective],
  16. [if test $ac_cv_c_inline = no; then
  17. gl_cv_c_inline_effective=no
  18. else
  19. dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
  20. dnl specified.
  21. dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
  22. dnl depends on optimization flags, which can be in CFLAGS.
  23. dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
  24. AC_COMPILE_IFELSE(
  25. [AC_LANG_PROGRAM([[]],
  26. [[#ifdef __NO_INLINE__
  27. #error "inline is not effective"
  28. #endif]])],
  29. [gl_cv_c_inline_effective=yes],
  30. [gl_cv_c_inline_effective=no])
  31. fi
  32. ])
  33. if test $gl_cv_c_inline_effective = yes; then
  34. AC_DEFINE([HAVE_INLINE], [1],
  35. [Define to 1 if the compiler supports one of the keywords
  36. 'inline', '__inline__', '__inline' and effectively inlines
  37. functions marked as such.])
  38. fi
  39. ])