From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 53A14A00C5; Mon, 19 Dec 2022 17:30:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1F5C40A7A; Mon, 19 Dec 2022 17:30:13 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 1D42A40685 for ; Mon, 19 Dec 2022 17:30:12 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2A5E920C32D4; Mon, 19 Dec 2022 08:30:11 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2A5E920C32D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1671467411; bh=Olv8CoNzfvO29MrEWZHc+Ye2W+8AE2obz5COAye+IA4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fVHdUmGNJxOcD0jE3eqKtr8q65fgEHR46XI0uJjbHQOBixpwpwyOD5lHYi6cwZLGt e/yw7w1kRpoULBIE5d3MPWDipV+w9TdlFQnC1fFJM3AL1wH3ZMQPpkghgPdmpn/sG8 83YdThv6O9bbpt2Qoxh2/+m4DJlqta4iclv2HhQI= Date: Mon, 19 Dec 2022 08:30:11 -0800 From: Tyler Retzlaff To: "Zhou, Xiangyun" Cc: "dev@dpdk.org" , "Xu, Bowen" Subject: Re: C++20 report error at file rte_spinlock.h Message-ID: <20221219163011.GA18921@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, Dec 13, 2022 at 06:11:06AM +0000, Zhou, Xiangyun wrote: > Dear dpdk dev, > > I'm using dpdk 21.11 LTS, when compile my program with CPP flag "-std=c++20", the compiler report below errors. After checking file rte_spinlock.h, I think the error report by compiler is valid, there should be a potential issue when using functions rte_spinlock_recursive_lock, rte_spinlock_recursive_unlock and rte_spinlock_recursive_trylock in multi-thread, we could either remove "volatile" definition to ask users to handle the multi-thread issue, or using atomic operatings instead of self-increment and self-decrement. > > > /home/dpdk/lib/eal/include/generic/rte_spinlock.h:221:12: error: increment of object of volatile-qualified type 'volatile int' is deprecated [-Werror,-Wdeprecated-volatile] > slr->count++; > ^ > /home/dpdk/lib/eal/include/generic/rte_spinlock.h:231:6: error: decrement of object of volatile-qualified type 'volatile int' is deprecated [-Werror,-Wdeprecated-volatile] > if (--(slr->count) == 0) { > ^ > /home/dpdk/lib/eal/include/generic/rte_spinlock.h:255:12: error: increment of object of volatile-qualified type 'volatile int' is deprecated [-Werror,-Wdeprecated-volatile] > slr->count++; > i have work in progress to optionally use standard atomics but in the meantime the correct thing to do here is to use the gcc builtins that match the requirements of the c++11 memory model. the code should be converted to use __atomic_fetch_{add,sub} or __atomic_{add,sub}_fetch as appropriate. ty.