X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseLib%2FSynchronization.c;h=225453149d30a476187250b076f0b53ffc19c520;hp=18812e242f32949f5d4400402e54bded7c3bf925;hb=46dd23b81ebe5041229608a851ed7af692863f3c;hpb=9710b9a67c7d949b339b5540b0eaa735d56e019b diff --git a/MdePkg/Library/BaseLib/Synchronization.c b/MdePkg/Library/BaseLib/Synchronization.c index 18812e242f..225453149d 100644 --- a/MdePkg/Library/BaseLib/Synchronization.c +++ b/MdePkg/Library/BaseLib/Synchronization.c @@ -14,95 +14,10 @@ **/ -#define SPIN_LOCK_RELEASED ((SPIN_LOCK)1) -#define SPIN_LOCK_ACQUIRED ((SPIN_LOCK)2) +#include "BaseLibInternals.h" -/** - 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 - ); - -/** - 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 - ); - -/** - Performs an atomic compare exchange operation on a 32-bit unsigned integer. - - Performs an atomic compare exchange operation on the 32-bit unsigned integer - specified by Value. If Value is equal to CompareValue, then Value is set to - ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue, - then Value is returned. The compare exchange operation must be performed using - MP safe mechanisms. - - @param Value A pointer to the 32-bit value for the compare exchange - operation. - @param CompareValue 32-bit value used in compare operation. - @param ExchangeValue 32-bit value used in exchange operation. - - @return The original *Value before exchange. - -**/ -UINT32 -EFIAPI -InternalSyncCompareExchange32 ( - IN volatile UINT32 *Value, - IN UINT32 CompareValue, - IN UINT32 ExchangeValue - ); - -/** - Performs an atomic compare exchange operation on a 64-bit unsigned integer. - - Performs an atomic compare exchange operation on the 64-bit unsigned integer specified - by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and - CompareValue is returned. If Value is not equal to CompareValue, then Value is returned. - The compare exchange operation must be performed using MP safe mechanisms. - - @param Value A pointer to the 64-bit value for the compare exchange - operation. - @param CompareValue 64-bit value used in compare operation. - @param ExchangeValue 64-bit value used in exchange operation. - - @return The original *Value before exchange. - -**/ -UINT64 -EFIAPI -InternalSyncCompareExchange64 ( - IN volatile UINT64 *Value, - IN UINT64 CompareValue, - IN UINT64 ExchangeValue - ); +#define SPIN_LOCK_RELEASED ((UINTN) 1) +#define SPIN_LOCK_ACQUIRED ((UINTN) 2) /** Retrieves the architecture specific spin lock alignment requirements for @@ -236,7 +151,7 @@ AcquireSpinLockOrFail ( IN OUT SPIN_LOCK *SpinLock ) { - volatile SPIN_LOCK LockValue; + SPIN_LOCK LockValue; ASSERT (SpinLock != NULL); @@ -272,7 +187,7 @@ ReleaseSpinLock ( IN OUT SPIN_LOCK *SpinLock ) { - volatile SPIN_LOCK LockValue; + SPIN_LOCK LockValue; ASSERT (SpinLock != NULL); @@ -419,7 +334,11 @@ InterlockedCompareExchangePointer ( IN VOID *ExchangeValue ) { - switch (sizeof (*Value)) { + UINT8 SizeOfValue; + + SizeOfValue = sizeof (*Value); + + switch (SizeOfValue) { case sizeof (UINT32): return (VOID*)(UINTN)InterlockedCompareExchange32 ( (UINT32*)Value,