diff options
Diffstat (limited to 'MdePkg/Library/BaseSynchronizationLib/X64')
16 files changed, 51 insertions, 412 deletions
diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c index 5b1635a98043..ee9d6a4a32fc 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c +++ b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c @@ -1,28 +1,20 @@ /** @file GCC inline implementation of BaseSynchronizationLib processor specific functions. - - Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> - Portions copyright (c) 2008 - 2009, Apple Inc. 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 - http://opensource.org/licenses/bsd-license.php. - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> + Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ - /** Performs an atomic increment of an 32-bit unsigned integer. Performs an atomic increment of the 32-bit unsigned integer specified by Value and returns the incremented value. The increment operation must be - performed using MP safe mechanisms. The state of the return value is not - guaranteed to be MP safe. + performed using MP safe mechanisms. @param Value A pointer to the 32-bit value to increment. @@ -38,17 +30,18 @@ InternalSyncIncrement ( UINT32 Result; __asm__ __volatile__ ( + "movl $1, %%eax \n\t" "lock \n\t" - "incl %2 \n\t" - "mov %2, %%eax " - : "=a" (Result), // %0 - "=m" (*Value) // %1 - : "m" (*Value) // %2 + "xadd %%eax, %1 \n\t" + "inc %%eax \n\t" + : "=&a" (Result), // %0 + "+m" (*Value) // %1 + : // no inputs that aren't also outputs : "memory", "cc" ); - - return Result; + + return Result; } @@ -57,8 +50,7 @@ InternalSyncIncrement ( Performs an atomic decrement of the 32-bit unsigned integer specified by Value and returns the decremented value. The decrement operation must be - performed using MP safe mechanisms. The state of the return value is not - guaranteed to be MP safe. + performed using MP safe mechanisms. @param Value A pointer to the 32-bit value to decrement. @@ -72,18 +64,19 @@ InternalSyncDecrement ( ) { UINT32 Result; - + __asm__ __volatile__ ( - "lock \n\t" - "decl %2 \n\t" - "mov %2, %%eax " - : "=a" (Result), // %0 - "=m" (*Value) // %1 - : "m" (*Value) // %2 + "movl $-1, %%eax \n\t" + "lock \n\t" + "xadd %%eax, %1 \n\t" + "dec %%eax \n\t" + : "=&a" (Result), // %0 + "+m" (*Value) // %1 + : // no inputs that aren't also outputs : "memory", "cc" ); - + return Result; } @@ -114,16 +107,12 @@ InternalSyncCompareExchange16 ( IN UINT16 ExchangeValue ) { - - __asm__ __volatile__ ( "lock \n\t" - "cmpxchgw %3, %1 " - : "=a" (CompareValue), - "=m" (*Value) - : "a" (CompareValue), - "r" (ExchangeValue), - "m" (*Value) + "cmpxchgw %2, %1 \n\t" + : "+a" (CompareValue), // %0 + "+m" (*Value) // %1 + : "r" (ExchangeValue) // %2 : "memory", "cc" ); @@ -158,20 +147,16 @@ InternalSyncCompareExchange32 ( IN UINT32 ExchangeValue ) { - - __asm__ __volatile__ ( "lock \n\t" - "cmpxchgl %3, %1 " - : "=a" (CompareValue), // %0 - "=m" (*Value) // %1 - : "a" (CompareValue), // %2 - "r" (ExchangeValue), // %3 - "m" (*Value) + "cmpxchgl %2, %1 \n\t" + : "+a" (CompareValue), // %0 + "+m" (*Value) // %1 + : "r" (ExchangeValue) // %2 : "memory", "cc" ); - + return CompareValue; } @@ -201,20 +186,15 @@ InternalSyncCompareExchange64 ( IN UINT64 ExchangeValue ) { - __asm__ __volatile__ ( "lock \n\t" - "cmpxchgq %3, %1 " - : "=a" (CompareValue), // %0 - "=m" (*Value) // %1 - : "a" (CompareValue), // %2 - "r" (ExchangeValue), // %3 - "m" (*Value) + "cmpxchgq %2, %1 \n\t" + : "+a" (CompareValue), // %0 + "+m" (*Value) // %1 + : "r" (ExchangeValue) // %2 : "memory", "cc" ); - + return CompareValue; } - - diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm deleted file mode 100644 index 219527d585c1..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.asm +++ /dev/null @@ -1,42 +0,0 @@ -;------------------------------------------------------------------------------ -; -; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> -; Copyright (c) 2015, Linaro Ltd. 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; InterlockedCompareExchange16.Asm -; -; Abstract: -; -; InterlockedCompareExchange16 function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT16 -; EFIAPI -; InternalSyncCompareExchange16 ( -; IN volatile UINT16 *Value, -; IN UINT16 CompareValue, -; IN UINT16 ExchangeValue -; ); -;------------------------------------------------------------------------------ -InternalSyncCompareExchange16 PROC - mov ax, dx - lock cmpxchg [rcx], r8w - ret -InternalSyncCompareExchange16 ENDP - - END diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.c b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.c index d51d6e361061..ab8e5031fadd 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.c +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.c @@ -3,13 +3,7 @@ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015, Linaro Ltd. 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 - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm index b9ef3d4f9def..6c00f62ca9f1 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange16.nasm @@ -2,13 +2,7 @@ ; ; Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR> ; Copyright (c) 2015, Linaro Ltd. 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm deleted file mode 100644 index 86a3c2ad0f93..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.asm +++ /dev/null @@ -1,41 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; InterlockedCompareExchange32.Asm -; -; Abstract: -; -; InterlockedCompareExchange32 function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; InternalSyncCompareExchange32 ( -; IN volatile UINT32 *Value, -; IN UINT32 CompareValue, -; IN UINT32 ExchangeValue -; ); -;------------------------------------------------------------------------------ -InternalSyncCompareExchange32 PROC - mov eax, edx - lock cmpxchg [rcx], r8d - ret -InternalSyncCompareExchange32 ENDP - - END diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.c b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.c index b275d679c055..0b7212cabe40 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.c +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.c @@ -2,13 +2,7 @@ InterlockedCompareExchange32 function 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 - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm index e199ef95fe8c..b659fa6fdfd1 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange32.nasm @@ -1,13 +1,7 @@ ;------------------------------------------------------------------------------ ; ; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm deleted file mode 100644 index e3a85d6fa76f..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.asm +++ /dev/null @@ -1,41 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; InterlockedCompareExchange64.Asm -; -; Abstract: -; -; InterlockedCompareExchange64 function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT64 -; EFIAPI -; InternalSyncCompareExchange64 ( -; IN volatile UINT64 *Value, -; IN UINT64 CompareValue, -; IN UINT64 ExchangeValue -; ); -;------------------------------------------------------------------------------ -InternalSyncCompareExchange64 PROC - mov rax, rdx - lock cmpxchg [rcx], r8 - ret -InternalSyncCompareExchange64 ENDP - - END diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.c b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.c index c7b6daac9315..f737b63028f5 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.c +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.c @@ -2,13 +2,7 @@ InterlockedCompareExchange64 function 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 - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm index e78de535d965..91194da2d810 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedCompareExchange64.nasm @@ -1,13 +1,7 @@ ;------------------------------------------------------------------------------ ; ; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.asm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.asm deleted file mode 100644 index 7d6f02c63b0c..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.asm +++ /dev/null @@ -1,39 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; InterlockedDecrement.Asm -; -; Abstract: -; -; InterlockedDecrement function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; InternalSyncDecrement ( -; IN volatile UINT32 *Value -; ); -;------------------------------------------------------------------------------ -InternalSyncDecrement PROC - lock dec dword ptr [rcx] - mov eax, [rcx] - ret -InternalSyncDecrement ENDP - - END diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.c b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.c deleted file mode 100644 index af0193cb6321..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.c +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - InterlockedDecrement function - - 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 - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics. -**/ - -long _InterlockedDecrement( - long * lpAddend -); - -#pragma intrinsic(_InterlockedDecrement) - -/** - Performs an atomic decrement of an 32-bit unsigned integer. - - Performs an atomic decrement of the 32-bit unsigned integer specified by - Value and returns the decrement value. The decrement operation must be - performed using MP safe mechanisms. The state of the return value is not - guaranteed to be MP safe. - - @param Value A pointer to the 32-bit value to decrement. - - @return The decrement value. - -**/ -UINT32 -EFIAPI -InternalSyncDecrement ( - IN volatile UINT32 *Value - ) -{ - return _InterlockedDecrement ((long *)(UINTN)(Value)); -} - diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.nasm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.nasm index 0325fdf93e90..d36d9b0073b7 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.nasm +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.nasm @@ -1,13 +1,7 @@ ;------------------------------------------------------------------------------ ; -; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR> +; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; @@ -33,7 +27,7 @@ ;------------------------------------------------------------------------------ global ASM_PFX(InternalSyncDecrement) ASM_PFX(InternalSyncDecrement): - lock dec dword [rcx] - mov eax, [rcx] + mov eax, 0FFFFFFFFh + lock xadd dword [rcx], eax + dec eax ret - diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.asm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.asm deleted file mode 100644 index bbbc95df0c36..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.asm +++ /dev/null @@ -1,39 +0,0 @@ -;------------------------------------------------------------------------------ -; -; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -; -; Module Name: -; -; InterlockedIncrement.Asm -; -; Abstract: -; -; InterlockedIncrement function -; -; Notes: -; -;------------------------------------------------------------------------------ - - .code - -;------------------------------------------------------------------------------ -; UINT32 -; EFIAPI -; InternalSyncIncrement ( -; IN volatile UINT32 *Value -; ); -;------------------------------------------------------------------------------ -InternalSyncIncrement PROC - lock inc dword ptr [rcx] - mov eax, [rcx] - ret -InternalSyncIncrement ENDP - - END diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.c b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.c deleted file mode 100644 index 2a3498a585ab..000000000000 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.c +++ /dev/null @@ -1,46 +0,0 @@ -/** @file - InterLockedIncrement function - - 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 - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -/** - Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics. -**/ - -long _InterlockedIncrement( - long * lpAddend -); - -#pragma intrinsic(_InterlockedIncrement) - -/** - Performs an atomic increment of an 32-bit unsigned integer. - - Performs an atomic increment of the 32-bit unsigned integer specified by - Value and returns the incremented value. The increment operation must be - performed using MP safe mechanisms. The state of the return value is not - guaranteed to be MP safe. - - @param Value A pointer to the 32-bit value to increment. - - @return The incremented value. - -**/ -UINT32 -EFIAPI -InternalSyncIncrement ( - IN volatile UINT32 *Value - ) -{ - return _InterlockedIncrement ((long *)(UINTN)(Value)); -} - diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.nasm b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.nasm index c960cb451196..fd046958b9ff 100644 --- a/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.nasm +++ b/MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.nasm @@ -1,13 +1,7 @@ ;------------------------------------------------------------------------------ ; ; 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 -; http://opensource.org/licenses/bsd-license.php. -; -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; @@ -33,7 +27,8 @@ ;------------------------------------------------------------------------------ global ASM_PFX(InternalSyncIncrement) ASM_PFX(InternalSyncIncrement): - lock inc dword [rcx] - mov eax, [rcx] + mov eax, 1 + lock xadd dword [rcx], eax + inc eax ret |