From patchwork Sat Aug 20 07:45:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 74361 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp659810qga; Sat, 20 Aug 2016 00:49:15 -0700 (PDT) X-Received: by 10.237.51.162 with SMTP id v31mr12829377qtd.1.1471679355795; Sat, 20 Aug 2016 00:49:15 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m21si7195066qki.127.2016.08.20.00.49.15; Sat, 20 Aug 2016 00:49:15 -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 7299C617F1; Sat, 20 Aug 2016 07:49:15 +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 E059461D80; Sat, 20 Aug 2016 07:46:29 +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 46194617C7; Sat, 20 Aug 2016 07:46:21 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 85BAA61705 for ; Sat, 20 Aug 2016 07:46:18 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id l89so46698679lfi.1 for ; Sat, 20 Aug 2016 00:46:18 -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=Laj7DRK3H+arKU8a38GQ+WMYQRK0rxZEdJffeSep3HFe6wv9XSMnwMeJgCLLvCTEf/ 4ihTkI1Q9ZENIL7YQjSTtU6ihM8i65d77Xabw83XQ7p/OjC6lPV6hM9UZ6/VwjkChrk6 PA0kw1ck9cB0rKBItXJ8Ex0J0mcahiSVDFqyZnA9s89r89PE+XOXyQoaPpOlQ7LobreX m82fhI6NJzNZ5HPKZ726LAJu9QdRwPpIuL+Z7Wqdo8Pm9HzJ3aAaCctHSYUq3dxWl9Fu SPmV+h+mWxFUdoswDt73sNDdRoE0MIY5XzwiY2TgyAAJg8thdGoJ8P3qXl8vfE3/QdOE 9XGw== X-Gm-Message-State: AEkoouuWLzNiPx8zY5VAkQ4yhJ1/We5qvfwGbGKG6KLh15AQXVbfM0D6/2opZNHUgeisxJ6pOsA= X-Received: by 10.46.0.220 with SMTP id e89mr3051031lji.58.1471679177259; Sat, 20 Aug 2016 00:46:17 -0700 (PDT) Received: from localhost.localdomain (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id 17sm1854092ljj.49.2016.08.20.00.46.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Aug 2016 00:46:16 -0700 (PDT) From: Christophe Milard To: bill.fischofer@linaro.org, mike.holmes@linaro.org, lng-odp@lists.linaro.org Date: Sat, 20 Aug 2016 09:45:54 +0200 Message-Id: <1471679163-17240-5-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471679163-17240-1-git-send-email-christophe.milard@linaro.org> References: <1471679163-17240-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 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