diff --git a/CMakeLists.txt b/CMakeLists.txt index 39c76406..3fb19be1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -829,6 +829,10 @@ calculation if supported by the system" ON) endif() endif() +# Check for __attribute__((__always_inline__)) support. +tuklib_check_func_attribute_always_inline(HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE) +tuklib_add_definition_if(liblzma HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE) + # Symbol visibility support: # # The C_VISIBILITY_PRESET property takes care of adding the compiler diff --git a/cmake/tuklib_gnu_c_attributes.cmake b/cmake/tuklib_gnu_c_attributes.cmake index 2cfcddeb..690449bc 100644 --- a/cmake/tuklib_gnu_c_attributes.cmake +++ b/cmake/tuklib_gnu_c_attributes.cmake @@ -39,6 +39,14 @@ function(tuklib_check_attribute CODE RESULT) ": unknown attribute") endfunction() +function(tuklib_check_func_attribute_always_inline RESULT) + tuklib_check_attribute(" + __attribute__((__always_inline__)) + static inline int my_inline_func(int x) { return x + 1; } + void my_func(void) { return my_inline_func(123); } + " "${RESULT}") +endfunction() + function(tuklib_check_func_attribute_constructor RESULT) tuklib_check_attribute(" __attribute__((__constructor__)) diff --git a/configure.ac b/configure.ac index 065b725c..8117b259 100644 --- a/configure.ac +++ b/configure.ac @@ -844,6 +844,11 @@ AC_ARG_ENABLE([ifunc], [AS_HELP_STRING([--disable-ifunc], [], [enable_ifunc=yes]) AS_IF([test "x$enable_ifunc" = xyes], [AX_GCC_FUNC_ATTRIBUTE([ifunc])]) +# GCC >= 3.2 and Clang support the attribute always_inline but a few other +# compilers support it too. So it's better to check for the support here +# instead of just checking if __GNUC__ or __clang__ is defined. +AX_GCC_FUNC_ATTRIBUTE([always_inline]) + ############################################################################### # Checks for library functions.