From patchwork Wed Mar 22 14:48:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 95724 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp224409obz; Wed, 22 Mar 2017 06:49:26 -0700 (PDT) X-Received: by 10.200.47.47 with SMTP id j44mr32601791qta.244.1490190566656; Wed, 22 Mar 2017 06:49:26 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z47si1120627qta.254.2017.03.22.06.49.26; Wed, 22 Mar 2017 06:49:26 -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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2DC26642C5; Wed, 22 Mar 2017 13:49:26 +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, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 BF7B6642B5; Wed, 22 Mar 2017 13:49:20 +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 D5AB662DC6; Wed, 22 Mar 2017 13:49:17 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by lists.linaro.org (Postfix) with ESMTPS id CF1E962DC6 for ; Wed, 22 Mar 2017 13:49:15 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id t189so38376061wmt.1 for ; Wed, 22 Mar 2017 06:49:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aQNQcLKglV4cnYzH/g9PoUh8f2G0F/V28rBpUv8EBAA=; b=DB+Jn5LwpTXQMdVsY/Dpn8rd2M3FhlTRornRF6dvBjoCinyAE6rngz+ww8NSqw1Kbr BMztPaQisKcNSrBzmciSUudGUeJ6zWPuy5+JNRViWB7o0qHHQXO3XXQABfLjOQwy62qW 0mkxVg3dUti05VM6LwXWgsZe3JoZo67f2QdoT51BAB1hTmtFTEK3/AvWhi04RMVw09qv nfLc1wAmb+RJCJd/XvgAyA/0TMQmxmUpm2iG9MgmKqAdtbyd7UPPeO6wzBUWUyGWhsQ6 5qJsqPtrRfVuhzrT0F27Bg3PmnDBpJ4R7y5wPH0UX0BDuENVJDy6VluOygYsz/wUMkHu gKeA== X-Gm-Message-State: AFeK/H2YpD8y4OCwUuH9bDEEcEWH1ZZMdyZfW/QJuUOc1fx0DjjbGQyc94i9A7hP9ixdDjwNmK3nPDjk X-Received: by 10.25.196.207 with SMTP id u198mr12170846lff.88.1490190554701; Wed, 22 Mar 2017 06:49:14 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id l23sm522305lfk.27.2017.03.22.06.49.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Mar 2017 06:49:14 -0700 (PDT) From: Christophe Milard To: yi.he@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Wed, 22 Mar 2017 15:48:08 +0100 Message-Id: <1490194110-40168-2-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490194110-40168-1-git-send-email-christophe.milard@linaro.org> References: <1490194110-40168-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv2 01/23] drv: adding compiler hints in the driver interface 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" Largely inspired from its north api counterpart, the drv/spec/hint.h file is added. Also includes the __constructor__ attributes that many driver interface items will need. Signed-off-by: Christophe Milard --- include/odp/drv/spec/hints.h | 119 +++++++++++++++++++++++++++++++++++++++++++ platform/Makefile.inc | 1 + 2 files changed, 120 insertions(+) create mode 100644 include/odp/drv/spec/hints.h -- 2.7.4 diff --git a/include/odp/drv/spec/hints.h b/include/odp/drv/spec/hints.h new file mode 100644 index 0000000..ddae22e --- /dev/null +++ b/include/odp/drv/spec/hints.h @@ -0,0 +1,119 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODPDRV compiler hints + */ + +#ifndef ODPDRV_API_HINTS_H_ +#define ODPDRV_API_HINTS_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** @addtogroup odpdrv_compiler_optim + * Macros that will give hints to the compiler. + * @{ + */ + +#ifdef __GNUC__ + +/** Define a function that should be run at early init (constructor) + */ +#define ODPDRV_CONSTRUCTOR __attribute__((__constructor__)) + +/** Define a function that does not return + */ +#define ODPDRV_NORETURN __attribute__((__noreturn__)) + +/** Define a weak symbol + * This is primarily useful in defining library functions that can be + * overridden in user code. + */ +#define ODPDRV_WEAK_SYMBOL __attribute__((__weak__)) + +/** + * Hot code section + */ +#define ODPDRV_HOT_CODE __attribute__((__hot__)) + +/** + * Cold code section + */ +#define ODPDRV_COLD_CODE __attribute__((__cold__)) + +/** + * Printf format attribute + */ +#define ODPDRV_PRINTF_FORMAT(x, y) __attribute__((format(printf, (x), (y)))) + +/** + * Indicate deprecated variables, functions or types + */ +#define ODPDRV_DEPRECATED __attribute__((__deprecated__)) + +/** + * Intentionally unused variables of functions + */ +#define ODPDRV_UNUSED __attribute__((__unused__)) + +/** + * Branch likely taken + */ +#define odpdrv_likely(x) __builtin_expect((x), 1) + +/** + * Branch unlikely taken + */ +#define odpdrv_unlikely(x) __builtin_expect((x), 0) + +/* + * __builtin_prefetch (const void *addr, rw, locality) + * + * rw 0..1 (0: read, 1: write) + * locality 0..3 (0: don't leave to cache, 3: leave on all cache levels) + */ + +/** + * Cache prefetch address + */ +#define odpdrv_prefetch(x) __builtin_prefetch((x), 0, 3) + +/** + * Cache prefetch address for storing + */ +#define odpdrv_prefetch_store(x) __builtin_prefetch((x), 1, 3) + +#else + +#define ODPDRV_CONSTRUCTOR +#define ODPDRV_NORETURN +#define ODPDRV_WEAK_SYMBOL +#define ODPDRV_HOT_CODE +#define ODPDRV_COLD_CODE +#define ODPDRV_DEPRECATED +#define ODPDRV_UNUSED +#define odpdrv_likely(x) +#define odpdrv_unlikely(x) +#define odpdrv_prefetch(x) +#define odpdrv_prefetch_store(x) + +#endif + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#include +#endif diff --git a/platform/Makefile.inc b/platform/Makefile.inc index 874cf88..e439e3c 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -69,6 +69,7 @@ odpdrvspecinclude_HEADERS = \ $(top_srcdir)/include/odp/drv/spec/byteorder.h \ $(top_srcdir)/include/odp/drv/spec/compiler.h \ $(top_srcdir)/include/odp/drv/spec/driver.h \ + $(top_srcdir)/include/odp/drv/spec/hints.h \ $(top_srcdir)/include/odp/drv/spec/shm.h \ $(top_srcdir)/include/odp/drv/spec/spinlock.h \ $(top_srcdir)/include/odp/drv/spec/std_types.h \