From patchwork Tue Dec 1 13:27:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 57487 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2169974lbb; Tue, 1 Dec 2015 05:28:22 -0800 (PST) X-Received: by 10.55.23.30 with SMTP id i30mr78035845qkh.59.1448976502716; Tue, 01 Dec 2015 05:28:22 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b39si50183978qkh.75.2015.12.01.05.28.21; Tue, 01 Dec 2015 05:28:22 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 0BF6561D77; Tue, 1 Dec 2015 13:28:16 +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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 B8F9161D78; Tue, 1 Dec 2015 13:27:47 +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 090B161D76; Tue, 1 Dec 2015 13:27:42 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id D847761D71 for ; Tue, 1 Dec 2015 13:27:40 +0000 (UTC) Received: by lffu14 with SMTP id u14so7958074lff.1 for ; Tue, 01 Dec 2015 05:27:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J2nE1g1wCImw+Te+rhZkLvAs81l6Uw5ovnue/gp4txU=; b=0gy4USYawfiWBSeMpYOzywfHqBFnTnUwzhbgiiQSEoQ5EaBpTadBju563MnTop7NLL 08tC5lUfT6ro/MqNxZar/UjWlQ7HPqU9zYxkARqRHpCU0llNyVjm1Krw3ZusufmdgG++ Q4jtPvf8bF3Tei4QIIZuZqJkxf5wWZ3ZcOQhd16wt6eWn7I8Ab/kBde6f1k+sKvjT89n +PcGLNv+ORd2PmfysmWKKZoovSFZEFCFx1t7aFAjX7FG1nE8KU3SS6Whtd7QjdQMSMj7 HjLo2njiCRZLRz83NGeHaIsFRgaPGKDecv//rBAzV75UlHbJ+kF/orJ4J6ztRf3W1b1o vGMA== 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=J2nE1g1wCImw+Te+rhZkLvAs81l6Uw5ovnue/gp4txU=; b=J3QayEiPNcMqZCxH7N3DGovZae/ozBC5GJBXyfKXD05lfd1Ktm/CeoJPq6RLR9XsYW TB5jHI07rcYeQSgFLwUA635J3vYKK2OGDEL0QQeOl+dJvHSySgdiqN28xtetlyTnolwa 2Qy/5JPodcdtiNKyQcKeGRvLmX5PDTdDpKzP7pG9S1emNexnFlDcsJX4CcpiJVPPXpFI VAIy4P6bIAOvMebzdCtSSRbkPFAI3A3lW2t5v8Cs/m3tw7D9DDVadKv+zv8Y9Heva3bR virb4SogWEFqWYgZuMPIPiFDAuISitWT8c2smIaTnNIqVyUwmopI2AivRxMHkrzAbrC3 /QPw== X-Gm-Message-State: ALoCoQlez4p8OQcvBCrHFuY+r2SBWTP/8DvPSuMMsIrjr/OYkIiQvgWObd9Nyajs3cyH/Xo2fn2M X-Received: by 10.25.149.139 with SMTP id x133mr5014322lfd.57.1448976459708; Tue, 01 Dec 2015 05:27:39 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id qr6sm7276892lbb.19.2015.12.01.05.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Dec 2015 05:27:39 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 1 Dec 2015 16:27:31 +0300 Message-Id: <1448976452-10786-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448976452-10786-1-git-send-email-maxim.uvarov@linaro.org> References: <1448976452-10786-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 1/2] helper: strong types support 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add strong types support for helpers the same as we have for linux-generic. That should be useful for complex algorithms where type check is needed. Signed-off-by: Maxim Uvarov --- helper/Makefile.am | 1 + helper/include/odp/helper/strong_types.h | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 helper/include/odp/helper/strong_types.h diff --git a/helper/Makefile.am b/helper/Makefile.am index bed8683..1906ae2 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -15,6 +15,7 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/icmp.h\ $(srcdir)/include/odp/helper/ip.h\ $(srcdir)/include/odp/helper/ipsec.h\ + $(srcdir)/include/odp/helper/strong_types.h\ $(srcdir)/include/odp/helper/tcp.h\ $(srcdir)/include/odp/helper/table.h\ $(srcdir)/include/odp/helper/udp.h diff --git a/helper/include/odp/helper/strong_types.h b/helper/include/odp/helper/strong_types.h new file mode 100644 index 0000000..777e24d --- /dev/null +++ b/helper/include/odp/helper/strong_types.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Strong Types. Common macros for implementing strong typing + * for ODP abstract data types + */ + +#ifndef ODPH_STRONG_TYPES_H_ +#define ODPH_STRONG_TYPES_H_ + +/** Use strong typing for ODP types */ +#ifdef __cplusplus +#define ODPH_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +#else +#define odph_handle_t struct { uint8_t unused_dummy_var; } * +/** C/C++ helper macro for strong typing */ +#define ODPH_HANDLE_T(type) odph_handle_t type +#endif + +/** Internal macro to get value of an ODP handle */ +#define _odph_typeval(handle) ((uint32_t)(uintptr_t)(handle)) + +/** Internal macro to get printable value of an ODP handle */ +#define _odph_pri(handle) ((uint64_t)_odph_typeval(handle)) + +/** Internal macro to convert a scalar to a typed handle */ +#define _odph_cast_scalar(type, val) ((type)(uintptr_t)(val)) + +#endif