From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 630D8A04A7;
	Thu,  6 Aug 2020 20:44:17 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 17EAE2C28;
	Thu,  6 Aug 2020 20:44:16 +0200 (CEST)
Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com
 [209.85.218.68]) by dpdk.org (Postfix) with ESMTP id 3A56F2B87
 for <dev@dpdk.org>; Thu,  6 Aug 2020 20:44:14 +0200 (CEST)
Received: by mail-ej1-f68.google.com with SMTP id kq25so38463278ejb.3
 for <dev@dpdk.org>; Thu, 06 Aug 2020 11:44:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-transfer-encoding:content-language;
 bh=Tp6vBdcwB37ewC9mkY7+O1Vh+zJnLTIGvikf5c41io0=;
 b=GcpJ+vPsz3M2k3/j5G7WXHEyRCOlmtQoLUgfaUidCngLm7bXFjJ8TOPlcYKcnxueDt
 h5eRYyZLRPY0Opia2fq0wSqlovRkMd+06vbiOOZWYsVtncmXSmiKC+oWMw1nM+T4rl4b
 7MpJGXgkC2eedpvLRTOzpifv1FI6SgNoVqqG85XNbfJ/wc4q1ij72716OjDWaYeo3kTB
 gD8vFBp8fU5ij97/Sll25+yDEXYFnK5+PPnDATOBHvyy3bkNBMkJdxjPHwG1oSOnEfIM
 dFiiaGci0Yrie5pKwIaBpuzcbGBc9a/dSiYo0n3ojCJOFgPU4q2CkqaR5p+P7BFXnvHR
 lncw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:subject:to:cc:references:from:message-id:date
 :user-agent:mime-version:in-reply-to:content-transfer-encoding
 :content-language;
 bh=Tp6vBdcwB37ewC9mkY7+O1Vh+zJnLTIGvikf5c41io0=;
 b=GL7f6t67iUq+IZsj7sWYbEOe3Lw+BA/1JGClY1TiWuQCarSNV1HfvHKXLCfc726Mt6
 gcCH+2COJSoYOMyTDHJu50Whr0be4yWy2avQc//gllgr7ksXH/W3nWd1s7oObzZrYkIB
 rTrctKbz9gNYDfttW5fPpJdeC0MWg56Yz6pj2r/A8QNv52CvthDv2EbdWGc1Z+yBc82A
 kzXnK8jXpHOT4ylfYggHrAkNPgl+VXMhq4U2AiraEe337hT0tCM/8jlvIuidTYDeOzB0
 bsuNNaNkiG8SjAzFEpVSRBx0tVqXZC/EOkbwUQRQ8Ea7FSJWMKfLZO+YA9n2GXmTVvr1
 IQHQ==
X-Gm-Message-State: AOAM533LZHi9Jx3Z8G03Sj1KJHJ4jKX2iIY1cUNTkxAWK3obEAUh09Vs
 qHCnSvfBwpK3uircZDfmjN4=
X-Google-Smtp-Source: ABdhPJyVOedgtc0Y5k4BN8YQM5AkhTRGO/XCDivHmcjf3+k0CPJ4//Tx9MZ6nKDPDALUCTsJF/Oa+w==
X-Received: by 2002:a17:906:e218:: with SMTP id
 gf24mr5991405ejb.469.1596739453920; 
 Thu, 06 Aug 2020 11:44:13 -0700 (PDT)
Received: from [192.168.2.4] (user-164-127-148-95.play-internet.pl.
 [164.127.148.95])
 by smtp.googlemail.com with ESMTPSA id y14sm4119802ejr.35.2020.08.06.11.44.12
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 06 Aug 2020 11:44:13 -0700 (PDT)
To: Sunil Kumar Kori <skori@marvell.com>,
 Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Cc: dev <dev@dpdk.org>, David Marchand <david.marchand@redhat.com>
References: <20200804175138.18543-1-pawelwod@gmail.com>
 <CAJFAV8x6TS9rgOLtYz4Ph0mEO7pY9HFkB5rUB9m699Zw45+G6g@mail.gmail.com>
 <CY4PR18MB1622618EB69CB1B0DE54A270B4480@CY4PR18MB1622.namprd18.prod.outlook.com>
From: Pawel Wodkowski <pawelwod@gmail.com>
Message-ID: <47184d9f-88b5-7167-ab2b-ccb3b30c214a@gmail.com>
Date: Thu, 6 Aug 2020 20:44:12 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
 Thunderbird/68.4.1
MIME-Version: 1.0
In-Reply-To: <CY4PR18MB1622618EB69CB1B0DE54A270B4480@CY4PR18MB1622.namprd18.prod.outlook.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH] tracepoint: fix compilation with
	C++
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

On 06.08.2020 08:44, Sunil Kumar Kori wrote:
> Hello Pawel,
>
> See answers inline.
>
> Regards
> Sunil Kumar Kori
>
>> -----Original Message-----
>> From: David Marchand <david.marchand@redhat.com>
>> Sent: Wednesday, August 5, 2020 1:30 PM
>> To: Pawel Wodkowski <pawelwod@gmail.com>
>> Cc: dev <dev@dpdk.org>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
>> Sunil Kumar Kori <skori@marvell.com>
>> Subject: [EXT] Re: [dpdk-dev] [PATCH] tracepoint: fix compilation with C++
>>
>> External Email
>>
>> ----------------------------------------------------------------------
>> Hello Pawel,
>>
>> Thanks for contributing to DPDK.
>>
>>
>> On Tue, Aug 4, 2020 at 7:52 PM Pawel Wodkowski <pawelwod@gmail.com>
>> wrote:
>>> trace_mem is declared as 'void *' which triggers following error:
>>> '...invalid conversion from ‘void*’ to ‘__rte_trace_header*’
>>> [-fpermissive]...'
>>>
>>> Fix this by changing void to struct __rte_trace_header
> trace_mem is intentionally kept as void * so that it can not be accessed by application directly as it part of global header.
But this structure is well defined in this file anyway. It can be casted 
to 'struct __rte_trace_header *' and used.
Isn't the double underscore prefix good enough warning that it is 
internal datatype?

But anyway, I'm not here to discuss the architecture of DPDK so lets go 
to the next point.

> If I understood the problem correctly, it is because of using trace_mem without typecasting and GCC does not report it as error
> due to implicit typecast and G++ reports it as error as it does not do implicit typecasting.
Actually it is because in C++ implicit cast from void pointer is not 
allowed. So when it is used like this

      struct __rte_trace_header *trace = RTE_PER_LCORE(trace_mem);

it triggers this type of error:

include/rte_trace_point.h: In function ‘void* 
__rte_trace_mem_get(uint64_t)’:
include/rte_per_lcore.h:44:46: error: invalid conversion from ‘void*’ to 
‘__rte_trace_header*’ [-fpermissive]
  #define RTE_PER_LCORE(name) (per_lcore_##name)
                                         ^
nclude/rte_trace_point.h:303:37: note: in expansion of macro ‘RTE_PER_LCORE’
   struct __rte_trace_header *trace = RTE_PER_LCORE(trace_mem);
                                                           ^

One can add '-fpermisive' to allow this type of casting but it is only a 
workaround in C++ code. As you mentioned,
other solution is typecast to __rte_trace_header but this is not needed 
in C and it have "__" prefix this why I decided
to change 'void *' into 'struct __rte_trace_header *'.

>   
>
> If this is the case then, I think it is better to typecast the trace_mem where ever it is being used. Anyways that will be safe for both GCC and G++.
> @Jerin Jacob Kollanukkaran Please suggest. If you have some thing mind.

I'm fine any solution that make this code compile with C++. Please let 
me know what is the decision then I can make V2.

Paweł
>   
>
> [snippet]
> --
>