[MERGED] osmo-trx[master]: buildenv: check for __builtin_cpu_supports call support

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Tom Tsou gerrit-no-reply at lists.osmocom.org
Thu Jun 8 18:32:30 UTC 2017


Tom Tsou has submitted this change and it was merged.

Change subject: buildenv: check for __builtin_cpu_supports call support
......................................................................


buildenv: 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.

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: I797f638573e8c3aae39c28abb157ce2ac419f3f7
---
M configure.ac
1 file changed, 27 insertions(+), 0 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Harald Welte: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/configure.ac b/configure.ac
index 7c3c76f..8ddd07d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,33 @@
     AM_CONDITIONAL(HAVE_SSE4_1, false)
 ])
 
+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])
+
 AM_CONDITIONAL(USRP1, [test "x$with_usrp1" = "xyes"])
 AM_CONDITIONAL(ARCH_ARM, [test "x$with_neon" = "xyes" || test "x$with_neon_vfpv4" = "xyes"])
 AM_CONDITIONAL(ARCH_ARM_A15, [test "x$with_neon_vfpv4" = "xyes"])

-- 
To view, visit https://gerrit.osmocom.org/2689
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I797f638573e8c3aae39c28abb157ce2ac419f3f7
Gerrit-PatchSet: 2
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Tom Tsou <tom at tsou.cc>



More information about the gerrit-log mailing list