From patchwork Fri Mar 20 22:16:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 46166 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 00138214BC for ; Fri, 20 Mar 2015 22:17:18 +0000 (UTC) Received: by wesk11 with SMTP id k11sf14713772wes.3 for ; Fri, 20 Mar 2015 15:17: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: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=Ry6wxv8r7kkYj+QYBdUiTR3AQoPO7REoo+67ZNUBRM0=; b=iXAN1G/bfpPCiibBbUJpG7gYp67GEV0chYnd3SNIjuuZZ9ON5EOXXuOBY5SwF/cqe4 61w5jAQkwdJUdhDXxlttkL0mjNRMe/3fGwFpQevJGAznXc3igTvttoXt8V8c2Jrzlaz3 beva1OXOCBlknlL+ANLDmNscygl86UkxxTDqJJdBpmDUla9yD/U1Cv4H4iZ68IiDAyZf 17Om+u99R+NkwKfzODyNoNTjW/hWvrQjFY96D0jGv/Lft8eyTpnFYSW19ljJSdwFeMc4 b3irzn2ZXy8vfFoUmmbGROFmMRdBvqOylqdM+PfloWSJTlm+ar/7cHABYpG+qiVGHCpN poMw== X-Gm-Message-State: ALoCoQnSSSixlzO+Joubz2nKTTT8jAzcYKuHWKevY+pkzn84YRJo0XC8jfywErDH8jEtcCwK8uiQ X-Received: by 10.112.148.10 with SMTP id to10mr8617024lbb.18.1426889838254; Fri, 20 Mar 2015 15:17:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.2 with SMTP id iq2ls486003lac.100.gmail; Fri, 20 Mar 2015 15:17:17 -0700 (PDT) X-Received: by 10.152.37.97 with SMTP id x1mr70729612laj.2.1426889837898; Fri, 20 Mar 2015 15:17:17 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id qm5si3992936lbb.81.2015.03.20.15.17.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Mar 2015 15:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbcgn8 with SMTP id gn8so84826465lbc.2 for ; Fri, 20 Mar 2015 15:17:17 -0700 (PDT) X-Received: by 10.112.130.39 with SMTP id ob7mr76906211lbb.32.1426889837784; Fri, 20 Mar 2015 15:17:17 -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.35.133 with SMTP id h5csp310638lbj; Fri, 20 Mar 2015 15:17:17 -0700 (PDT) X-Received: by 10.52.81.97 with SMTP id z1mr49959973vdx.22.1426889836269; Fri, 20 Mar 2015 15:17:16 -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 q16si4948152vds.58.2015.03.20.15.17.12 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 20 Mar 2015 15:17:16 -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 1YZ5E4-0005uc-IP; Fri, 20 Mar 2015 22:17:08 +0000 Received: from mail-lb0-f177.google.com ([209.85.217.177]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YZ5Dw-0005uU-Hp for lng-odp@lists.linaro.org; Fri, 20 Mar 2015 22:17:00 +0000 Received: by lbcgn8 with SMTP id gn8so84822139lbc.2 for ; Fri, 20 Mar 2015 15:16:54 -0700 (PDT) X-Received: by 10.152.21.8 with SMTP id r8mr54849720lae.98.1426889814837; Fri, 20 Mar 2015 15:16:54 -0700 (PDT) Received: from localhost.localdomain (78-82-118-95.tn.glocalnet.net. [78.82.118.95]) by mx.google.com with ESMTPSA id zr10sm1182476lbb.38.2015.03.20.15.16.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Mar 2015 15:16:54 -0700 (PDT) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Fri, 20 Mar 2015 23:16:50 +0100 Message-Id: <1426889810-29236-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] [PATCH] 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.177 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) 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 +++++- 10 files changed, 20 insertions(+), 16 deletions(-) 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..39bdea3 100644 --- a/platform/linux-generic/include/odp/plat/strong_types.h +++ b/platform/linux-generic/include/odp/plat/strong_types.h @@ -16,7 +16,11 @@ #define STRONG_TYPES_H_ /** Use strong typing for ODP types */ -#define odp_handle_t struct { uint8_t unused_dummy_var; } * +#ifdef __cplusplus +#define ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +#else +#define ODP_HANDLE_T(type) struct { } *type +#endif /** Internal macro to get value of an ODP handle */ #define _odp_typeval(handle) ((uint32_t)(uintptr_t)(handle))