From patchwork Sat Jan 31 20:50:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 44095 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0C1A62359E for ; Sat, 31 Jan 2015 20:51:16 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id s18sf13551484lam.2 for ; Sat, 31 Jan 2015 12:51:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Abq0FVruHgKXUpvrN4Ga74FA6QA8b/DRgD6tThB1Yow=; b=Sbnzqx8x2kftwTZAPrDSwmxkcaREe6SUjQS7AQ7kS9jg6AgYtVJEsbWs+89Zebyxkd 9uW8wyU3X/ErRK0evJTPu5NX5JYoiCxOd+UbamRWAHcmSoycsEjkINytbVzz+hVbCXUs uJ4ZrQW0rB3e/E2GrHlKoUfmv0kcspHhmvttffPsGYPxxtH3Jj9qqoyDofwH/e+8B7Qn EVNOLNu/C80hEmtvckFhDk/PQEQhRDNyXYHwm5J3IMzcNPHXbBQJBGhCISX4QGwAMDG2 YXDc/k1zjQYnAm6/A10odiwzUZZypKkoj+v+RprpS5GzD+1M13ZdLTbBU4QDFCSyH0sX y56g== X-Gm-Message-State: ALoCoQnzyzGm6Kz+lct51ODYc5MY04Ya4eD0CRDk/s2ssYl6mte1ejs1lTf+V7+gGqdsi66JMJje X-Received: by 10.112.213.72 with SMTP id nq8mr1579689lbc.18.1422737475132; Sat, 31 Jan 2015 12:51:15 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.129 with SMTP id wq1ls503175lac.56.gmail; Sat, 31 Jan 2015 12:51:15 -0800 (PST) X-Received: by 10.152.9.41 with SMTP id w9mr12162742laa.17.1422737474978; Sat, 31 Jan 2015 12:51:14 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id oa1si13083884lbb.100.2015.01.31.12.51.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 12:51:14 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id pv20so30485544lab.7 for ; Sat, 31 Jan 2015 12:51:14 -0800 (PST) X-Received: by 10.112.188.227 with SMTP id gd3mr12373050lbc.22.1422737474879; Sat, 31 Jan 2015 12:51:14 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp450242lbj; Sat, 31 Jan 2015 12:51:14 -0800 (PST) X-Received: by 10.224.37.138 with SMTP id x10mr26546365qad.4.1422737473580; Sat, 31 Jan 2015 12:51:13 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id c13si19272643qaw.34.2015.01.31.12.51.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 31 Jan 2015 12:51:13 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHf0X-0000ub-OA; Sat, 31 Jan 2015 20:51:09 +0000 Received: from mail-oi0-f54.google.com ([209.85.218.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YHf0O-0000tt-UX for lng-odp@lists.linaro.org; Sat, 31 Jan 2015 20:51:01 +0000 Received: by mail-oi0-f54.google.com with SMTP id v63so39406355oia.13 for ; Sat, 31 Jan 2015 12:50:55 -0800 (PST) X-Received: by 10.60.244.196 with SMTP id xi4mr7709915oec.32.1422737455581; Sat, 31 Jan 2015 12:50:55 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id uv10sm7202439obc.27.2015.01.31.12.50.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Jan 2015 12:50:55 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sat, 31 Jan 2015 14:50:41 -0600 Message-Id: <1422737449-11540-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1422737449-11540-1-git-send-email-bill.fischofer@linaro.org> References: <1422737449-11540-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 1/9] api: add base macros for strong typing support X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Bill Fischofer --- platform/linux-generic/Makefile.am | 1 + .../linux-generic/include/odp/plat/strong_types.h | 38 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 platform/linux-generic/include/odp/plat/strong_types.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index addb5ec..81245b1 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -57,6 +57,7 @@ odpplatinclude_HEADERS = \ $(top_srcdir)/platform/linux-generic/include/odp/plat/queue_types.h \ $(top_srcdir)/platform/linux-generic/include/odp/plat/schedule_types.h \ $(top_srcdir)/platform/linux-generic/include/odp/plat/shared_memory_types.h \ + $(top_srcdir)/platform/linux-generic/include/odp/plat/strong_types.h \ $(top_srcdir)/platform/linux-generic/include/odp/plat/version_types.h odpapiincludedir= $(includedir)/odp/api diff --git a/platform/linux-generic/include/odp/plat/strong_types.h b/platform/linux-generic/include/odp/plat/strong_types.h new file mode 100644 index 0000000..a5449ac --- /dev/null +++ b/platform/linux-generic/include/odp/plat/strong_types.h @@ -0,0 +1,38 @@ +/* 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 STRONG_TYPES_H_ +#define STRONG_TYPES_H_ + +/** Use strong typing for ODP types */ +#define odp_handle_t struct {} * + +/** Internal typedefs for ODP strong type manipulation */ +typedef odp_handle_t _odp_handle_t; + +typedef union { + _odp_handle_t hdl; + uint32_t val; +} _odp_handle_u; + +/** Internal macro to get value of an ODP handle */ +#define _odp_typeval(handle) (((_odp_handle_u)(_odp_handle_t)handle).val) + +/** Internal macro to get printable value of an ODP handle */ +#define _odp_pri(handle) ((uint64_t)_odp_typeval(handle)) + +/** Internal macro to convert a scalar to a typed handle */ +#define _odp_cast_scalar(type, val) ((type)(size_t)(val)) + +#endif