From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7090F81F20 for ; Thu, 17 Nov 2016 00:51:33 -0800 (PST) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 321A23B714; Thu, 17 Nov 2016 08:51:38 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-6.phx2.redhat.com [10.3.116.6]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAH8panP029848; Thu, 17 Nov 2016 03:51:36 -0500 To: Michael Kinney , edk2-devel@ml01.01.org References: <1479358424-17096-1-git-send-email-michael.d.kinney@intel.com> <1479358424-17096-2-git-send-email-michael.d.kinney@intel.com> Cc: Liming Gao , Andrew Fish , Jeff Fan From: Laszlo Ersek Message-ID: Date: Thu, 17 Nov 2016 09:51:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1479358424-17096-2-git-send-email-michael.d.kinney@intel.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 17 Nov 2016 08:51:38 +0000 (UTC) Subject: Re: [Patch 1/2] MdePkg/Include: Add volatile to SynchronizationLib parameters X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Nov 2016 08:51:33 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 11/17/16 05:53, Michael Kinney wrote: > The SpinLock functions in the SynchronicationLib use volatile > parameters to keep compiler from optimizing these functions > too much. The volatile keyword is missing from the Interlocked*() > functions in this same library class. Update the library class > to consistently use volatile on all functions in this class. > > Cc: Liming Gao > Cc: Laszlo Ersek > Cc: Andrew Fish > Cc: Jeff Fan > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Michael Kinney > --- > MdePkg/Include/Library/SynchronizationLib.h | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/MdePkg/Include/Library/SynchronizationLib.h b/MdePkg/Include/Library/SynchronizationLib.h > index 7b97683..4f405e2 100644 > --- a/MdePkg/Include/Library/SynchronizationLib.h > +++ b/MdePkg/Include/Library/SynchronizationLib.h > @@ -1,7 +1,7 @@ > /** @file > Provides synchronization functions. > > -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD License > which accompanies this distribution. The full text of the license may be found at > @@ -157,7 +157,7 @@ ReleaseSpinLock ( > UINT32 > EFIAPI > InterlockedIncrement ( > - IN UINT32 *Value > + IN volatile UINT32 *Value > ); > > > @@ -179,7 +179,7 @@ InterlockedIncrement ( > UINT32 > EFIAPI > InterlockedDecrement ( > - IN UINT32 *Value > + IN volatile UINT32 *Value > ); > > > @@ -204,7 +204,7 @@ InterlockedDecrement ( > UINT16 > EFIAPI > InterlockedCompareExchange16 ( > - IN OUT UINT16 *Value, > + IN OUT volatile UINT16 *Value, > IN UINT16 CompareValue, > IN UINT16 ExchangeValue > ); > @@ -231,7 +231,7 @@ InterlockedCompareExchange16 ( > UINT32 > EFIAPI > InterlockedCompareExchange32 ( > - IN OUT UINT32 *Value, > + IN OUT volatile UINT32 *Value, > IN UINT32 CompareValue, > IN UINT32 ExchangeValue > ); > @@ -258,7 +258,7 @@ InterlockedCompareExchange32 ( > UINT64 > EFIAPI > InterlockedCompareExchange64 ( > - IN OUT UINT64 *Value, > + IN OUT volatile UINT64 *Value, > IN UINT64 CompareValue, > IN UINT64 ExchangeValue > ); > @@ -285,7 +285,7 @@ InterlockedCompareExchange64 ( > VOID * > EFIAPI > InterlockedCompareExchangePointer ( > - IN OUT VOID **Value, > + IN OUT volatile VOID **Value, > IN VOID *CompareValue, > IN VOID *ExchangeValue > ); > In the last prototype, the changed parameter should be: IN OUT VOID * volatile * Value The object that is pointed-to by Value ((which happens to be a pointer) needs to get the volatile qualification, not the object that the pointer being exchanged points to. volatile +----------------+ +-------------+ Value --------> | *Value | -------------> | **Value | +----------------+ +-------------+ Thanks! Laszlo