aboutsummaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-05-08 00:07:21 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-05-08 02:02:49 +0700
commita8a5819155323be6fab2c874d4448c0c9510331e (patch)
tree94dbaf07f2b7bea22710ccf00347592c5b1164d2 /configure.ac
parent2c3066e5da54659f19799005eddb1d134c6d0166 (diff)
configure.ac: check for __builtin_cpu_supports call support
The '__builtin_cpu_supports' is a GCC's built-in function which returns a positive integer if the run-time CPU supports specified SIMD feature and returns 0 otherwise. It is required for further SSE optimization of Viterbi decoder. This change adds a new check, whether compiler supports this call. See /gcc/X86-Built-in-Functions.html at gcc.gnu.org for reference. Change-Id: I5d52cfb3e8fab3eedc0293a2842708cbee0f476a
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac27
1 files changed, 27 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 672a6dff..1dd5930e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,6 +242,33 @@ else
AM_CONDITIONAL(HAVE_SSE4_1, false)
fi
+dnl Check if the compiler supports specified GCC's built-in function
+AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
+ AC_CACHE_CHECK(
+ [whether ${CC} has $1 built-in],
+ [osmo_cv_cc_has_builtin], [
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([], [
+ __builtin_cpu_supports("sse");
+ ])
+ ],
+ [AS_VAR_SET([osmo_cv_cc_has_builtin], [yes])],
+ [AS_VAR_SET([osmo_cv_cc_has_builtin], [no])])
+ ]
+ )
+
+ AS_IF([test yes = AS_VAR_GET([osmo_cv_cc_has_builtin])], [
+ AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
+ [Define to 1 if compiler has the '$1' built-in function])
+ ], [
+ AC_MSG_WARN($2)
+ ])
+])
+
+dnl Check if the compiler supports runtime SIMD detection
+CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
+ [Runtime SIMD detection will be disabled])
+
AC_OUTPUT(
libosmocore.pc
libosmocodec.pc