From patchwork Mon Mar 23 20:56:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 46218 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0AED920D10 for ; Mon, 23 Mar 2015 20:56:50 +0000 (UTC) Received: by labgq15 with SMTP id gq15sf29243430lab.0 for ; Mon, 23 Mar 2015 13:56:48 -0700 (PDT) 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 :mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=vK4katjDvgmo+VwWaU8u8I5NTo9x/Se+jU8gB1AFLRo=; b=fWjpTofuF/af+C4DDNzLW97tGQpSSIFEFJu9Z0d1kg3/Wdc6YOThcQFnGgDNqhrmZP ZDh6lmQfo6Ugc+5pIWQvY3hd73KMJ7xQBuXH6UIIgYpALMNwtWVi72Lx8MUNrYa8nFGU WzEBTPQPz4QAAlB975z9nRl2/CBmnj/jZ5hG+9mnx5ORhSlm7BmSK3C8DStsZ8Wl5g5u DPGiWddXkkGNwDc6g+5WFJX3kUE+kQWS2o19ht2uU0BLKY3hXIdUCXw2cJUAS3E836lt eUa/ub9m4MYZu92BV4ylqfGIlELmrWZqt7f6UczerLUsYnH2oL1b1U/Q4k0+bR8wQhM0 uI3A== X-Gm-Message-State: ALoCoQmANa62NzxHT/I/HD2nKNd3ppNJRVd1F4RGmyoy8cDPvYzNs+ASogKIE71lHa4LtiTK4vFA X-Received: by 10.180.150.115 with SMTP id uh19mr2414050wib.7.1427144208952; Mon, 23 Mar 2015 13:56:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.135 with SMTP id 7ls152853lam.8.gmail; Mon, 23 Mar 2015 13:56:48 -0700 (PDT) X-Received: by 10.112.73.65 with SMTP id j1mr766615lbv.87.1427144208611; Mon, 23 Mar 2015 13:56:48 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id f2si1391961lbc.134.2015.03.23.13.56.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Mar 2015 13:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbcgn8 with SMTP id gn8so127336938lbc.2 for ; Mon, 23 Mar 2015 13:56:48 -0700 (PDT) X-Received: by 10.112.55.103 with SMTP id r7mr813584lbp.29.1427144208299; Mon, 23 Mar 2015 13:56:48 -0700 (PDT) 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.57.201 with SMTP id k9csp1070199lbq; Mon, 23 Mar 2015 13:56:47 -0700 (PDT) X-Received: by 10.55.26.209 with SMTP id l78mr2418944qkh.60.1427144207150; Mon, 23 Mar 2015 13:56:47 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id p20si1863119qgd.117.2015.03.23.13.56.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 23 Mar 2015 13:56:47 -0700 (PDT) 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 1Ya9Ot-0000GO-8a; Mon, 23 Mar 2015 20:56:43 +0000 Received: from mail-lb0-f178.google.com ([209.85.217.178]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Ya9On-0000GJ-Gs for lng-odp@lists.linaro.org; Mon, 23 Mar 2015 20:56:37 +0000 Received: by lbcgn8 with SMTP id gn8so127332385lbc.2 for ; Mon, 23 Mar 2015 13:56:31 -0700 (PDT) X-Received: by 10.152.244.161 with SMTP id xh1mr732883lac.119.1427144191773; Mon, 23 Mar 2015 13:56:31 -0700 (PDT) Received: from localhost.localdomain (78-82-118-95.tn.glocalnet.net. [78.82.118.95]) by mx.google.com with ESMTPSA id dq7sm419843lac.25.2015.03.23.13.56.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Mar 2015 13:56:30 -0700 (PDT) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Mon, 23 Mar 2015 21:56:26 +0100 Message-Id: <1427144186-29550-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Topics: patch Subject: [lng-odp] [PATCHv2] linux-generic: strongtypes: use named structs for C++ 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: , 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: ola.liljedahl@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.217.173 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 Typedefs to anonymous structs creates problems for C++ programs: GCC: warning: ‘odp_crypto_op_params’ has a field ‘odp_crypto_op_params::pkt’ whose type uses the anonymous namespace error: anonymous type with no linkage used to declare function ‘* ppp_packet::get_queue() const’ with linkage CLANG: extern odp_pool_t tmo_pool; warning: variable 'tmo_pool' has internal linkage but is not defined When linking: undefined reference to `tmo_pool' The solution is to add a (unique) name to all structs used by the strong typing typedefs. Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) v2: Restored doxygen support. doc/doxygen.cfg | 3 ++- platform/linux-generic/include/odp/plat/buffer_types.h | 4 ++-- platform/linux-generic/include/odp/plat/classification_types.h | 8 ++++---- platform/linux-generic/include/odp/plat/crypto_types.h | 2 +- platform/linux-generic/include/odp/plat/event_types.h | 2 +- platform/linux-generic/include/odp/plat/packet_io_types.h | 2 +- platform/linux-generic/include/odp/plat/packet_types.h | 4 ++-- platform/linux-generic/include/odp/plat/pool_types.h | 2 +- platform/linux-generic/include/odp/plat/queue_types.h | 4 ++-- platform/linux-generic/include/odp/plat/shared_memory_types.h | 2 +- platform/linux-generic/include/odp/plat/strong_types.h | 6 ++++++ 11 files changed, 23 insertions(+), 16 deletions(-) diff --git a/doc/doxygen.cfg b/doc/doxygen.cfg index 2d45a76..52c83a9 100644 --- a/doc/doxygen.cfg +++ b/doc/doxygen.cfg @@ -38,5 +38,6 @@ PREDEFINED = __GNUC__ \ __BIG_ENDIAN_BITFIELD \ __LITTLE_ENDIAN_BITFIELD \ __x86_64__ \ - ODP_PACKED + ODP_PACKED \ + "ODP_HANDLE_T(type)=odp_handle_t type" INTERNAL_DOCS = YES diff --git a/platform/linux-generic/include/odp/plat/buffer_types.h b/platform/linux-generic/include/odp/plat/buffer_types.h index 3e7070e..0c017ae 100644 --- a/platform/linux-generic/include/odp/plat/buffer_types.h +++ b/platform/linux-generic/include/odp/plat/buffer_types.h @@ -26,13 +26,13 @@ extern "C" { */ /** ODP buffer */ -typedef odp_handle_t odp_buffer_t; +typedef ODP_HANDLE_T(odp_buffer_t); /** Invalid buffer */ #define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0xffffffff) /** ODP buffer segment */ -typedef odp_handle_t odp_buffer_seg_t; +typedef ODP_HANDLE_T(odp_buffer_seg_t); /** Invalid segment */ #define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)ODP_BUFFER_INVALID) diff --git a/platform/linux-generic/include/odp/plat/classification_types.h b/platform/linux-generic/include/odp/plat/classification_types.h index 042d8c8..767da7d 100644 --- a/platform/linux-generic/include/odp/plat/classification_types.h +++ b/platform/linux-generic/include/odp/plat/classification_types.h @@ -23,18 +23,18 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_cos_t; -typedef odp_handle_t odp_flowsig_t; +typedef ODP_HANDLE_T(odp_cos_t); +typedef ODP_HANDLE_T(odp_flowsig_t); #define ODP_COS_INVALID _odp_cast_scalar(odp_cos_t, ~0) #define ODP_COS_NAME_LEN 32 typedef uint16_t odp_cos_flow_set_t; -typedef odp_handle_t odp_pmr_t; +typedef ODP_HANDLE_T(odp_pmr_t); #define ODP_PMR_INVAL _odp_cast_scalar(odp_pmr_t, ~0) -typedef odp_handle_t odp_pmr_set_t; +typedef ODP_HANDLE_T(odp_pmr_set_t); #define ODP_PMR_SET_INVAL _odp_cast_scalar(odp_pmr_set_t, ~0) /** Get printable format of odp_cos_t */ diff --git a/platform/linux-generic/include/odp/plat/crypto_types.h b/platform/linux-generic/include/odp/plat/crypto_types.h index 1b10a5d..a91d88e 100644 --- a/platform/linux-generic/include/odp/plat/crypto_types.h +++ b/platform/linux-generic/include/odp/plat/crypto_types.h @@ -25,7 +25,7 @@ extern "C" { #define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL) typedef uint64_t odp_crypto_session_t; -typedef odp_handle_t odp_crypto_compl_t; +typedef ODP_HANDLE_T(odp_crypto_compl_t); enum odp_crypto_op_mode { ODP_CRYPTO_SYNC, diff --git a/platform/linux-generic/include/odp/plat/event_types.h b/platform/linux-generic/include/odp/plat/event_types.h index 24be22f..d91937d 100644 --- a/platform/linux-generic/include/odp/plat/event_types.h +++ b/platform/linux-generic/include/odp/plat/event_types.h @@ -26,7 +26,7 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_event_t; +typedef ODP_HANDLE_T(odp_event_t); #define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0xffffffff) diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h b/platform/linux-generic/include/odp/plat/packet_io_types.h index 60592e3..3cc64c6 100644 --- a/platform/linux-generic/include/odp/plat/packet_io_types.h +++ b/platform/linux-generic/include/odp/plat/packet_io_types.h @@ -26,7 +26,7 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_pktio_t; +typedef ODP_HANDLE_T(odp_pktio_t); #define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0) diff --git a/platform/linux-generic/include/odp/plat/packet_types.h b/platform/linux-generic/include/odp/plat/packet_types.h index 57e9662..45cb801 100644 --- a/platform/linux-generic/include/odp/plat/packet_types.h +++ b/platform/linux-generic/include/odp/plat/packet_types.h @@ -26,13 +26,13 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_packet_t; +typedef ODP_HANDLE_T(odp_packet_t); #define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0xffffffff) #define ODP_PACKET_OFFSET_INVALID (0x0fffffff) -typedef odp_handle_t odp_packet_seg_t; +typedef ODP_HANDLE_T(odp_packet_seg_t); #define ODP_PACKET_SEG_INVALID _odp_cast_scalar(odp_packet_seg_t, 0xffffffff) diff --git a/platform/linux-generic/include/odp/plat/pool_types.h b/platform/linux-generic/include/odp/plat/pool_types.h index 71c7783..568556f 100644 --- a/platform/linux-generic/include/odp/plat/pool_types.h +++ b/platform/linux-generic/include/odp/plat/pool_types.h @@ -25,7 +25,7 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_pool_t; +typedef ODP_HANDLE_T(odp_pool_t); #define ODP_POOL_INVALID _odp_cast_scalar(odp_pool_t, 0xffffffff) diff --git a/platform/linux-generic/include/odp/plat/queue_types.h b/platform/linux-generic/include/odp/plat/queue_types.h index 04a0be9..1cecc90 100644 --- a/platform/linux-generic/include/odp/plat/queue_types.h +++ b/platform/linux-generic/include/odp/plat/queue_types.h @@ -25,9 +25,9 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_queue_t; +typedef ODP_HANDLE_T(odp_queue_t); -typedef odp_handle_t odp_queue_group_t; +typedef ODP_HANDLE_T(odp_queue_group_t); #define ODP_QUEUE_INVALID _odp_cast_scalar(odp_queue_t, 0) diff --git a/platform/linux-generic/include/odp/plat/shared_memory_types.h b/platform/linux-generic/include/odp/plat/shared_memory_types.h index d2e92cf..4be7356 100644 --- a/platform/linux-generic/include/odp/plat/shared_memory_types.h +++ b/platform/linux-generic/include/odp/plat/shared_memory_types.h @@ -26,7 +26,7 @@ extern "C" { * @{ */ -typedef odp_handle_t odp_shm_t; +typedef ODP_HANDLE_T(odp_shm_t); #define ODP_SHM_INVALID _odp_cast_scalar(odp_shm_t, 0) #define ODP_SHM_NULL ODP_SHM_INVALID diff --git a/platform/linux-generic/include/odp/plat/strong_types.h b/platform/linux-generic/include/odp/plat/strong_types.h index cd15853..a53d763 100644 --- a/platform/linux-generic/include/odp/plat/strong_types.h +++ b/platform/linux-generic/include/odp/plat/strong_types.h @@ -16,7 +16,13 @@ #define STRONG_TYPES_H_ /** Use strong typing for ODP types */ +#ifdef __cplusplus +#define ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +#else #define odp_handle_t struct { uint8_t unused_dummy_var; } * +/** C/C++ helper macro for strong typing */ +#define ODP_HANDLE_T(type) odp_handle_t type +#endif /** Internal macro to get value of an ODP handle */ #define _odp_typeval(handle) ((uint32_t)(uintptr_t)(handle))