From patchwork Fri Aug 19 17:29:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 74298 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp401457qga; Fri, 19 Aug 2016 09:36:18 -0700 (PDT) X-Received: by 10.55.98.85 with SMTP id w82mr9818888qkb.29.1471624578850; Fri, 19 Aug 2016 09:36:18 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s31si3233623qtb.18.2016.08.19.09.36.18; Fri, 19 Aug 2016 09:36:18 -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 7FBBA6170D; Fri, 19 Aug 2016 16:36:18 +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 2639361705; Fri, 19 Aug 2016 16:33:44 +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 793556168E; Fri, 19 Aug 2016 16:32:44 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 4378A6171E for ; Fri, 19 Aug 2016 16:30:52 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id f93so36598617lfi.2 for ; Fri, 19 Aug 2016 09:30:52 -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=lw9Ozd4h7Nj9oEzsdjViDluyzvnKTWH7toYnBzwk1qlR6U3NUxYUrTbG2CZffV3gPB UpOrynVy6sflJ3otRhtxGpFMRaS2mrL2se1B4I8reJ1Xgkc/BynhXh9ZxYzfh4Xt7qky K8ltU4dRhyITVssNN5uoOSZLc0vB4zjtKPLHQRgnVO7IDdCJwoNqU9mkqPBl1a6UZs2g eli+zkz5LsEaw467l6NeAfVAjsiSJh+x0n0WHpj7PNDypCXbEglRqrp+gF/laoOMMenF 07ChtaL310V2oBAj1DU/ZZ+qoRJ9ipth2B8FLhnldttm47zjKqbvKk3BC7kJjtU4ViJ9 igTA== X-Gm-Message-State: AEkoousMQAkAC18Zvfa6NgG3dS1U8cLdLAE9Y0Zz21Nz6ZmwboDfxMKQ5kTYFOGyF91bjxdOZik= X-Received: by 10.25.91.149 with SMTP id p143mr1974198lfb.39.1471624251007; Fri, 19 Aug 2016 09:30:51 -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 f4sm1363952lji.41.2016.08.19.09.30.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Aug 2016 09:30:50 -0700 (PDT) From: Christophe Milard To: lng-odp@lists.linaro.org, mike.holmes@linaro.org, bill.fischofer@linaro.org Date: Fri, 19 Aug 2016 19:29:49 +0200 Message-Id: <1471627798-47281-5-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471627798-47281-1-git-send-email-christophe.milard@linaro.org> References: <1471627798-47281-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