public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Michael Kinney <michael.d.kinney@intel.com>, edk2-devel@ml01.01.org
Cc: Liming Gao <liming.gao@intel.com>, Andrew Fish <afish@apple.com>,
	Jeff Fan <jeff.fan@intel.com>
Subject: Re: [Patch 1/2] MdePkg/Include: Add volatile to SynchronizationLib parameters
Date: Thu, 17 Nov 2016 09:51:35 +0100	[thread overview]
Message-ID: <c3e185d5-7bf9-ee4d-b75f-5b19026ffe3b@redhat.com> (raw)
In-Reply-To: <1479358424-17096-2-git-send-email-michael.d.kinney@intel.com>

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 <liming.gao@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Andrew Fish <afish@apple.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
> ---
>  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.<BR>
> +Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
>  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


  reply	other threads:[~2016-11-17  8:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17  4:53 [Patch 0/2] MdePkg/BaseSynchronizationLib: Add volatile Michael Kinney
2016-11-17  4:53 ` [Patch 1/2] MdePkg/Include: Add volatile to SynchronizationLib parameters Michael Kinney
2016-11-17  8:51   ` Laszlo Ersek [this message]
2016-11-17  4:53 ` [Patch 2/2] MdePkg/BaseSynchronizationLib: Add volatile Interlocked*() APIs Michael Kinney
2016-11-17  9:21   ` Laszlo Ersek
2016-11-17 15:55     ` Kinney, Michael D
2016-11-17 16:02       ` Laszlo Ersek
2016-11-17 16:08         ` Kinney, Michael D

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3e185d5-7bf9-ee4d-b75f-5b19026ffe3b@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox