From patchwork Fri Oct 6 19: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: 115119 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp2132448qgn; Fri, 6 Oct 2017 12:07:50 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCtxDRQ48pJB5TfXSAf0zlXdS8LzFgvLwdHZvdBnjVkulsLLwcnKAoYJv6eEOJYnpjjn1v/ X-Received: by 10.107.8.30 with SMTP id 30mr3648275ioi.83.1507316870150; Fri, 06 Oct 2017 12:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507316870; cv=none; d=google.com; s=arc-20160816; b=iUz8hgI/eSMUPcdc3HeEVsHJhKRopAJfxfEKWPzftyN3/qZV6XwYG72F7IgLpHdT0A prF8vzPz1b1+Zl2KmdeFpW5qSJHuZ3B4eOYiVM+86uFt9uGIRgOxyXGn6rm5xTuth9OD r0h+Frh7u4NN8f4mfre9/OdF9s/HGAhx/g33nHwKGuB3WDJBC2BYXJr1K4mKkUeU+rSW S0ABzYC1V0cbfR9EQraPOMUQZOkrMfsLZRVvhgtJ+S0j2NZxkJSo6qHZA624GkKXIsog 8UcLQ7ySyxseuqLtuVCBYD1S9A+CsJgETHlQnfrGfyyombrodLBiSaRPuUH+1AzEh17m YoNQ== 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=WBVZslf0o43dTdKBeT/jvcIpOYyUvZ4JyKfxDrFQan0=; b=A4DqO6Z1oGLpZCPL7QQBmM29GCEe5Nqb6lGBqOxYVaebOG0KXV/d9yh8F8GUY+1JK3 XqwkacGYgAjGM6PVAISTQCVSGVbZrTTs3QqNFlVIoSRJXjMI/TAo5R6UJ3uOtCRWpEOd 3biP3+kh7ghEShtNE6FTgGI1fZXshDh19E4xa1tvhxYgDSbUwchVbmIHryLJCD2vwSd4 F2gRO4V008OmSnQl4SL8asGQDnJ/1aQCa4BdXu5IVfx6O4FboAxiYkFPZ235r+o5tDls wqIJVP5avojQNUMOFLgZpWJkqm2h56aBvvfQsoRzxtOjxBk4/k9bAujVH4e7wxzsy75J 3GUg== 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 j95si1591566iod.232.2017.10.06.12.07.49; Fri, 06 Oct 2017 12:07:50 -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 A451860A38; Fri, 6 Oct 2017 19:07:49 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 A1D2065BE4; Fri, 6 Oct 2017 19:02:12 +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 70127608E4; Fri, 6 Oct 2017 19:02:05 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id 71C5C65BCA for ; Fri, 6 Oct 2017 19:00:37 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward101j.mail.yandex.net (Yandex) with ESMTP id C9E0D1243B66 for ; Fri, 6 Oct 2017 22:00:35 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id M1IQTcK7k2-0Zkqbm8E; Fri, 06 Oct 2017 22:00:35 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id d2nf8B3eVo-0ZtShndi; Fri, 06 Oct 2017 22:00:35 +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: Fri, 6 Oct 2017 22:00:00 +0300 Message-Id: <1507316415-2144-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507316415-2144-1-git-send-email-odpbot@yandex.ru> References: <1507316415-2144-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 213 Subject: [lng-odp] [PATCH v4 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: a63f25ff2994b2df78c24f1f8b63d0e06628eb68 ** Merge commit sha: d50e2e291ff11c1319e66c699d2f82260d59c383 **/ 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