From patchwork Fri Aug 19 15:48:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 74266 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp353219qga; Fri, 19 Aug 2016 07:52:37 -0700 (PDT) X-Received: by 10.55.100.21 with SMTP id y21mr8825450qkb.274.1471618357842; Fri, 19 Aug 2016 07:52:37 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a64si4762792qkg.206.2016.08.19.07.52.35; Fri, 19 Aug 2016 07:52:37 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 521B36065E; Fri, 19 Aug 2016 14:52:35 +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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 591EE616F6; Fri, 19 Aug 2016 14:50:08 +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 94A1860F46; Fri, 19 Aug 2016 14:49:40 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 1982060F46 for ; Fri, 19 Aug 2016 14:49:38 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id g62so34553049lfe.3 for ; Fri, 19 Aug 2016 07:49:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VcORsAGR8fLBQZx89dP5q8Wb1xTiwyNXW6X/xXJPHq0=; b=bjXQrBNBKsdQjTBNVmoTBxFQfGa16KaobzInxCnFeboaby9KAuCy4HTy767nne7Jl7 v+aBs0R2Os5zo70cPIpWC0Fpgp7j/HTeDUArY5wJV+UMaMbS2tM0KMicYB1EikifhgQ1 RdK5aaXXRURrpCiOWyfn3GgmHzL6pdAKPaao6j8bme5QF14H3AiObqbJXMxZ3v+UEaIC zm3vRHsvcCsIibC4VEMKKVQyRfAOjcXeiOVV3/X19eLyuyg67hHWhTweugNV5Yi/NOZy muojd4Jxqd8OnUji27ZbXxvIxFB/KDNa6o2ApCDdQ+kWzAXdYnb7JqhrGfCZ/M1lGAhX OC/w== X-Gm-Message-State: AEkoouvbAi5SZulwn0IxIpva6Ukhghk0dwi1atY7HeJIcRPSEoyY6onHQB1MkPFYnU4QYww0Gfg= X-Received: by 10.46.9.23 with SMTP id 23mr2239340ljj.11.1471618176812; Fri, 19 Aug 2016 07:49:36 -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 l10sm1277648lfd.19.2016.08.19.07.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Aug 2016 07:49:36 -0700 (PDT) From: Christophe Milard To: lng-odp@lists.linaro.org, mike.holmes@linaro.org, bill.fischofer@linaro.org Date: Fri, 19 Aug 2016 17:48:35 +0200 Message-Id: <1471621724-8485-5-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471621724-8485-1-git-send-email-christophe.milard@linaro.org> References: <1471621724-8485-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 04/13] linux-generic: drv: strong typing 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" Mirrored from its couterpart on the api interface, the drv interface gets its strong typing file. Signed-off-by: Christophe Milard --- platform/linux-generic/Makefile.am | 3 +- .../include/odp/drv/plat/strong_types.h | 35 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 platform/linux-generic/include/odp/drv/plat/strong_types.h -- 2.7.4 diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 42e9996..271f5b5 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -108,7 +108,8 @@ odpdrvplatinclude_HEADERS = \ $(srcdir)/include/odp/drv/plat/atomic_types.h \ $(srcdir)/include/odp/drv/plat/barrier_types.h \ $(srcdir)/include/odp/drv/plat/byteorder_types.h \ - $(srcdir)/include/odp/drv/plat/spinlock_types.h + $(srcdir)/include/odp/drv/plat/spinlock_types.h \ + $(srcdir)/include/odp/drv/plat/strong_types.h noinst_HEADERS = \ ${srcdir}/include/odp_align_internal.h \ diff --git a/platform/linux-generic/include/odp/drv/plat/strong_types.h b/platform/linux-generic/include/odp/drv/plat/strong_types.h new file mode 100644 index 0000000..a9c48ef --- /dev/null +++ b/platform/linux-generic/include/odp/drv/plat/strong_types.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODPDRV Strong Types. Common macros for implementing strong typing + * for ODPDRV abstract data types + */ + +#ifndef ODPDRV_STRONG_TYPES_H_ +#define ODPDRV_STRONG_TYPES_H_ + +/** Use strong typing for ODPDRV types */ +#ifdef __cplusplus +#define ODPDRV_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +#else +#define odpdrv_handle_t struct { uint8_t unused_dummy_var; } * +/** C/C++ helper macro for strong typing */ +#define ODPDRV_HANDLE_T(type) odpdrv_handle_t type +#endif + +/** Internal macro to get value of an ODPDRV handle */ +#define _odpdrv_typeval(handle) ((uint32_t)(uintptr_t)(handle)) + +/** Internal macro to get printable value of an ODPDRV handle */ +#define _odpdrv_pri(handle) ((uint64_t)_odpdrv_typeval(handle)) + +/** Internal macro to convert a scalar to a typed handle */ +#define _odpdrv_cast_scalar(type, val) ((type)(uintptr_t)(val)) + +#endif