From patchwork Thu Oct 5 18:00:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 114969 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp494968edb; Thu, 5 Oct 2017 11:06:40 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBkrGrQNswzEi+4YbOD6N/Gim+4+UK+3emXwcvu3HXOJ9SH6tWThvesCLNrm9e8B0FcD8jI X-Received: by 10.237.59.25 with SMTP id p25mr32474269qte.99.1507226799853; Thu, 05 Oct 2017 11:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507226799; cv=none; d=google.com; s=arc-20160816; b=zCLr58FefOEDZXVBBsGiG89MGP44ScewUbappbN2B4uNCM7vLEXaWF8TomegydFcd3 +SZ8PY0AwmMC5O74MnVy3svHpKh3IjPHD2ZCDrmDhVM5IvqKt0x85DBBH6bXwF+4WAzT jyYV12Y33ogZVH4kP91SPtGXw5a5nwRWqXz+rY68cK/i4kqgxDek5AwAiiRJQ4TgSRzg p5Z2biRZg1mgfGtPM2+cGYcOKv+x/9VErsrxAwDVZyt3ZUlQOTI2i6lsjig+8+omEjSb BaWpa4BWLMZhC0/Yq0PTF7+j208cPe3+OTsCGn9U5v/iIexN3A5dGx4H/5lkAG3ZQsCy ltLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=akmvAO0XuNAQbNObXYjw4sqHkWxui7WXUfQZwXrU8xk=; b=RRhLyyjn5WwxN/EiwsC+tM17RsLsV+aSfbJFwhMAMEFF5HhqEoXDPK9vzH5pfD2YSv vikOsE4zIT6t0N4AGmyfqDeby+wJk1fpZwzgQZuSZE7NS24wg4zKPo5MGUDCYT9gEuK5 XSQbZJY6dDzyH570b8J2ZA6qN1bzh3GEqeqJu8TE04jIOe64fa+NUQYRCcMpimusjgr+ Lbwj5ablclwK9KYDmBn+l1Rt8xj7f5wFL5nlH4APXmqSkFToM0sQ2QA3aeCR+FOleGph aepus1YRCwoarweDV+0Z5/CwLdK56HIG/Nd1Bl0Eppm6MGaFZrPU+relq68PYjPu8bII RylA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t123si640880qkh.188.2017.10.05.11.06.39; Thu, 05 Oct 2017 11:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 87B1A607CC; Thu, 5 Oct 2017 18:06:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id BE4D5644D2; Thu, 5 Oct 2017 18:02:23 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 57AAE644A0; Thu, 5 Oct 2017 18:02:10 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id B8F9560C4F for ; Thu, 5 Oct 2017 18:00:30 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 4C5F8408540A for ; Thu, 5 Oct 2017 21:00:29 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 8Mu7z0OYO9-0Tr4juK9; Thu, 05 Oct 2017 21:00:29 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id AZHOFl0KbL-0SW8j7EN; Thu, 05 Oct 2017 21:00:28 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 5 Oct 2017 21:00:00 +0300 Message-Id: <1507226415-26756-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507226415-26756-1-git-send-email-odpbot@yandex.ru> References: <1507226415-26756-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 213 Subject: [lng-odp] [PATCH v3 5/20] m4: move atomic checks to separate file X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov While we are at it, run 128bit atomic check only if __int128 is available for the target platform. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 213 (lumag:plat-def) ** https://github.com/Linaro/odp/pull/213 ** Patch: https://github.com/Linaro/odp/pull/213.patch ** Base sha: 52cfe7ba6d2541cf5ee464e46e91b2da5efe1497 ** Merge commit sha: 4157d06d3a16265d7d6152d7ae4918ec5623c10c **/ m4/odp_atomic.m4 | 95 ++++++++++++++++++++++++++++++++++ platform/linux-generic/m4/configure.m4 | 65 +---------------------- 2 files changed, 96 insertions(+), 64 deletions(-) create mode 100644 m4/odp_atomic.m4 diff --git a/m4/odp_atomic.m4 b/m4/odp_atomic.m4 new file mode 100644 index 000000000..413dcbda9 --- /dev/null +++ b/m4/odp_atomic.m4 @@ -0,0 +1,95 @@ +# ODP_ATOMIC +# ---------- +# Run different atomic-related checks +AC_DEFUN([ODP_ATOMIC], [dnl +ODP_ATOMIC_BUILTINS + +dnl Check whether -latomic is needed +use_libatomic=no + +ODP_ATOMIC_NEEDED_64BIT([use_libatomic=yes]) +AC_CHECK_TYPE([__int128], [ODP_ATOMIC_NEEDED_128BIT([use_libatomic=yes])]) + +if test "x$use_libatomic" = "xyes"; then + ATOMIC_LIBS="-latomic" +fi +AC_SUBST([ATOMIC_LIBS]) +]) # ODP_ATOMIC + +# ODP_ATOMIC_BUILTINS +# ------------------- +# +AC_DEFUN([ODP_ATOMIC_BUILTINS], [dnl +AC_CACHE_CHECK([for GCC atomic builtins], [odp_cv_atomic_builtins], [dnl +AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[int main() { + int v = 1; + __atomic_fetch_add(&v, 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&v, 1, __ATOMIC_RELAXED); + __atomic_store_n(&v, 1, __ATOMIC_RELAXED); + __atomic_load_n(&v, __ATOMIC_RELAXED); + return 0; + } + ]])], + [odp_cv_atomic_builtins=yes], + [odp_cv_atomic_builtins=no])]) + +if test "x$odp_cv_atomic_builtins" != "xyes" ; then + AC_MSG_FAILURE([GCC-style __atomic builtins not supported by the compiler, use gcc > 4.7.0]) +fi +]) # ODP_ATOMIC_BUILTINS + +# ODP_ATOMIC_NEEDED_64BIT([ACTION_IF_NEEDED]) +# ------------------------------------------- +# +AC_DEFUN([ODP_ATOMIC_NEEDED_64BIT], [dnl +AC_CACHE_CHECK([whether -latomic is needed for 64-bit atomic built-ins], + [odp_cv_atomic_needed_64bit], [dnl +AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ + #include + static uint64_t loc; + int main(void) + { + uint64_t prev = __atomic_exchange_n(&loc, 7, __ATOMIC_RELAXED); + return 0; + } + ]])], + [odp_cv_atomic_needed_64bit=no], + [odp_cv_atomic_needed_64bit=yes])]) + +if test "x$odp_cv_atomic_needed_64bit" = "xyes" ; then + AC_CHECK_LIB( + [atomic], [__atomic_exchange_8], + [m4_default([$1], [:])], + [AC_MSG_FAILURE([__atomic_exchange_8 is not available])]) +fi +]) # ODP_ATOMIC_NEEDED_64BIT + +# ODP_ATOMIC_NEEDED_128BIT([ACTION_IF_NEEDED]) +# ------------------------------------------- +# +AC_DEFUN([ODP_ATOMIC_NEEDED_128BIT], [dnl +AC_CACHE_CHECK([whether -latomic is needed for 128-bit atomic built-ins], + [odp_cv_atomic_needed_128bit], [dnl +AC_LINK_IFELSE( + [AC_LANG_SOURCE([[ + #include + static __int128 loc; + int main(void) + { + __int128 prev = __atomic_exchange_n(&loc, 7, __ATOMIC_RELAXED); + return 0; + } + ]])], + [odp_cv_atomic_needed_128bit=no], + [odp_cv_atomic_needed_128bit=yes])]) + +if test "x$odp_cv_atomic_needed_128bit" = "xyes" ; then + AC_CHECK_LIB( + [atomic], [__atomic_exchange_16], + [m4_default([$1], [:])], + [AC_MSG_FAILURE([__atomic_exchange_16 is not available])]) +fi +]) # ODP_ATOMIC_NEEDED_128BIT diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index 4e3ce6344..397c539b8 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -1,68 +1,5 @@ ODP_VISIBILITY - -AC_MSG_CHECKING(for GCC atomic builtins) -AC_LINK_IFELSE( - [AC_LANG_SOURCE( - [[int main() { - int v = 1; - __atomic_fetch_add(&v, 1, __ATOMIC_RELAXED); - __atomic_fetch_sub(&v, 1, __ATOMIC_RELAXED); - __atomic_store_n(&v, 1, __ATOMIC_RELAXED); - __atomic_load_n(&v, __ATOMIC_RELAXED); - return 0; - } - ]])], - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no) - echo "GCC-style __atomic builtins not supported by the compiler." - echo "Use newer version. For gcc > 4.7.0" - exit -1) - -dnl Check whether -latomic is needed -use_libatomic=no - -AC_MSG_CHECKING(whether -latomic is needed for 64-bit atomic built-ins) -AC_LINK_IFELSE( - [AC_LANG_SOURCE([[ - #include - static uint64_t loc; - int main(void) - { - uint64_t prev = __atomic_exchange_n(&loc, 7, __ATOMIC_RELAXED); - return 0; - } - ]])], - [AC_MSG_RESULT(no)], - [AC_MSG_RESULT(yes) - AC_CHECK_LIB( - [atomic], [__atomic_exchange_8], - [use_libatomic=yes], - [AC_MSG_FAILURE([__atomic_exchange_8 is not available])]) - ]) - -AC_MSG_CHECKING(whether -latomic is needed for 128-bit atomic built-ins) -AC_LINK_IFELSE( - [AC_LANG_SOURCE([[ - static __int128 loc; - int main(void) - { - __int128 prev; - prev = __atomic_exchange_n(&loc, 7, __ATOMIC_RELAXED); - return 0; - } - ]])], - [AC_MSG_RESULT(no)], - [AC_MSG_RESULT(yes) - AC_CHECK_LIB( - [atomic], [__atomic_exchange_16], - [use_libatomic=yes], - [AC_MSG_CHECKING([cannot detect support for 128-bit atomics])]) - ]) - -if test "x$use_libatomic" = "xyes"; then - ATOMIC_LIBS="-latomic" -fi -AC_SUBST([ATOMIC_LIBS]) +ODP_ATOMIC m4_include([platform/linux-generic/m4/odp_pthread.m4]) ODP_TIMER