MdePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:05 -08:00
committed by mergify[bot]
parent 1436aea4d5
commit 2f88bd3a12
975 changed files with 55681 additions and 57790 deletions

View File

@@ -31,10 +31,9 @@
UINT32
EFIAPI
InternalSyncIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
);
/**
Performs an atomic decrement of an 32-bit unsigned integer.
@@ -50,10 +49,9 @@ InternalSyncIncrement (
UINT32
EFIAPI
InternalSyncDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
);
/**
Performs an atomic compare exchange operation on a 16-bit unsigned integer.
@@ -74,12 +72,11 @@ InternalSyncDecrement (
UINT16
EFIAPI
InternalSyncCompareExchange16 (
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
);
/**
Performs an atomic compare exchange operation on a 32-bit unsigned integer.
@@ -100,12 +97,11 @@ InternalSyncCompareExchange16 (
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
);
/**
Performs an atomic compare exchange operation on a 64-bit unsigned integer.
@@ -125,9 +121,9 @@ InternalSyncCompareExchange32 (
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
);
/**

View File

@@ -28,13 +28,13 @@
UINT16
EFIAPI
InternalSyncCompareExchange16 (
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
return *Value != CompareValue ? *Value :
((*Value = ExchangeValue), CompareValue);
((*Value = ExchangeValue), CompareValue);
}
/**
@@ -59,13 +59,13 @@ InternalSyncCompareExchange16 (
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
return *Value != CompareValue ? *Value :
((*Value = ExchangeValue), CompareValue);
((*Value = ExchangeValue), CompareValue);
}
/**
@@ -87,13 +87,13 @@ InternalSyncCompareExchange32 (
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
return *Value != CompareValue ? *Value :
((*Value = ExchangeValue), CompareValue);
((*Value = ExchangeValue), CompareValue);
}
/**
@@ -112,7 +112,7 @@ InternalSyncCompareExchange64 (
UINT32
EFIAPI
InternalSyncIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
return ++*Value;
@@ -134,7 +134,7 @@ InternalSyncIncrement (
UINT32
EFIAPI
InternalSyncDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
return --*Value;

View File

@@ -7,8 +7,6 @@
**/
/**
Performs an atomic increment of an 32-bit unsigned integer.
@@ -24,7 +22,7 @@
UINT32
EFIAPI
InternalSyncIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
UINT32 Result;
@@ -39,12 +37,11 @@ InternalSyncIncrement (
: // no inputs that aren't also outputs
: "memory",
"cc"
);
);
return Result;
}
/**
Performs an atomic decrement of an 32-bit unsigned integer.
@@ -60,10 +57,10 @@ InternalSyncIncrement (
UINT32
EFIAPI
InternalSyncDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
UINT32 Result;
UINT32 Result;
__asm__ __volatile__ (
"movl $-1, %%eax \n\t"
@@ -75,12 +72,11 @@ InternalSyncDecrement (
: // no inputs that aren't also outputs
: "memory",
"cc"
);
);
return Result;
}
/**
Performs an atomic compare exchange operation on a 16-bit unsigned integer.
@@ -102,9 +98,9 @@ InternalSyncDecrement (
UINT16
EFIAPI
InternalSyncCompareExchange16 (
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
__asm__ __volatile__ (
@@ -115,12 +111,11 @@ InternalSyncCompareExchange16 (
: "q" (ExchangeValue) // %2
: "memory",
"cc"
);
);
return CompareValue;
}
/**
Performs an atomic compare exchange operation on a 32-bit unsigned integer.
@@ -142,9 +137,9 @@ InternalSyncCompareExchange16 (
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
__asm__ __volatile__ (
@@ -155,12 +150,11 @@ InternalSyncCompareExchange32 (
: "q" (ExchangeValue) // %2
: "memory",
"cc"
);
);
return CompareValue;
}
/**
Performs an atomic compare exchange operation on a 64-bit unsigned integer.
@@ -181,9 +175,9 @@ InternalSyncCompareExchange32 (
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
__asm__ __volatile__ (
@@ -195,7 +189,7 @@ InternalSyncCompareExchange64 (
"c" ((UINT32) (ExchangeValue >> 32)) // %3
: "memory",
"cc"
);
);
return CompareValue;
}

View File

@@ -7,9 +7,6 @@
**/
/**
Performs an atomic compare exchange operation on a 16-bit unsigned integer.
@@ -30,9 +27,9 @@
UINT16
EFIAPI
InternalSyncCompareExchange16 (
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
_asm {
@@ -42,4 +39,3 @@ InternalSyncCompareExchange16 (
lock cmpxchg [ecx], dx
}
}

View File

@@ -6,9 +6,6 @@
**/
/**
Performs an atomic compare exchange operation on a 32-bit unsigned integer.
@@ -29,9 +26,9 @@
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
_asm {
@@ -41,4 +38,3 @@ InternalSyncCompareExchange32 (
lock cmpxchg [ecx], edx
}
}

View File

@@ -6,9 +6,6 @@
**/
/**
Performs an atomic compare exchange operation on a 64-bit unsigned integer.
@@ -28,9 +25,9 @@
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
_asm {

View File

@@ -44,7 +44,7 @@ InternalGetSpinLockProperties (
// In processors based on Intel NetBurst microarchitecture, use two cache lines
//
ModelId = ModelId | ((RegEax >> 12) & 0xf0);
if (ModelId <= 0x04 || ModelId == 0x06) {
if ((ModelId <= 0x04) || (ModelId == 0x06)) {
CacheLineSize *= 2;
}
}
@@ -55,4 +55,3 @@ InternalGetSpinLockProperties (
return CacheLineSize;
}

View File

@@ -10,9 +10,10 @@
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
**/
long _InterlockedDecrement(
long * lpAddend
);
long
_InterlockedDecrement (
long *lpAddend
);
#pragma intrinsic(_InterlockedDecrement)
@@ -32,9 +33,8 @@ long _InterlockedDecrement(
UINT32
EFIAPI
InternalSyncDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
return _InterlockedDecrement ((long *)(Value));
}

View File

@@ -10,9 +10,10 @@
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
**/
long _InterlockedIncrement(
long * lpAddend
);
long
_InterlockedIncrement (
long *lpAddend
);
#pragma intrinsic(_InterlockedIncrement)
@@ -32,9 +33,8 @@ long _InterlockedIncrement(
UINT32
EFIAPI
InternalSyncIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
return _InterlockedIncrement ((long *)(Value));
}

View File

@@ -8,8 +8,8 @@
#include "BaseSynchronizationLibInternals.h"
#define SPIN_LOCK_RELEASED ((UINTN) 1)
#define SPIN_LOCK_ACQUIRED ((UINTN) 2)
#define SPIN_LOCK_RELEASED ((UINTN) 1)
#define SPIN_LOCK_ACQUIRED ((UINTN) 2)
/**
Retrieves the architecture specific spin lock alignment requirements for
@@ -55,7 +55,7 @@ GetSpinLockProperties (
SPIN_LOCK *
EFIAPI
InitializeSpinLock (
OUT SPIN_LOCK *SpinLock
OUT SPIN_LOCK *SpinLock
)
{
ASSERT (SpinLock != NULL);
@@ -86,7 +86,7 @@ InitializeSpinLock (
SPIN_LOCK *
EFIAPI
AcquireSpinLock (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
UINT64 Current;
@@ -106,7 +106,7 @@ AcquireSpinLock (
//
// Get the current timer value
//
Current = GetPerformanceCounter();
Current = GetPerformanceCounter ();
//
// Initialize local variables
@@ -130,23 +130,27 @@ AcquireSpinLock (
if (Cycle < 0) {
Cycle = -Cycle;
}
Cycle++;
while (!AcquireSpinLockOrFail (SpinLock)) {
CpuPause ();
Previous = Current;
Current = GetPerformanceCounter();
Delta = (INT64) (Current - Previous);
Current = GetPerformanceCounter ();
Delta = (INT64)(Current - Previous);
if (Start > End) {
Delta = -Delta;
}
if (Delta < 0) {
Delta += Cycle;
}
Total += Delta;
ASSERT (Total < Timeout);
}
}
return SpinLock;
}
@@ -170,10 +174,10 @@ AcquireSpinLock (
BOOLEAN
EFIAPI
AcquireSpinLockOrFail (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
SPIN_LOCK LockValue;
SPIN_LOCK LockValue;
ASSERT (SpinLock != NULL);
@@ -181,12 +185,12 @@ AcquireSpinLockOrFail (
ASSERT (SPIN_LOCK_ACQUIRED == LockValue || SPIN_LOCK_RELEASED == LockValue);
return (BOOLEAN)(
InterlockedCompareExchangePointer (
(VOID**)SpinLock,
(VOID*)SPIN_LOCK_RELEASED,
(VOID*)SPIN_LOCK_ACQUIRED
) == (VOID*)SPIN_LOCK_RELEASED
);
InterlockedCompareExchangePointer (
(VOID **)SpinLock,
(VOID *)SPIN_LOCK_RELEASED,
(VOID *)SPIN_LOCK_ACQUIRED
) == (VOID *)SPIN_LOCK_RELEASED
);
}
/**
@@ -206,10 +210,10 @@ AcquireSpinLockOrFail (
SPIN_LOCK *
EFIAPI
ReleaseSpinLock (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
SPIN_LOCK LockValue;
SPIN_LOCK LockValue;
ASSERT (SpinLock != NULL);
@@ -237,7 +241,7 @@ ReleaseSpinLock (
UINT32
EFIAPI
InterlockedIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
ASSERT (Value != NULL);
@@ -261,7 +265,7 @@ InterlockedIncrement (
UINT32
EFIAPI
InterlockedDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
ASSERT (Value != NULL);
@@ -290,9 +294,9 @@ InterlockedDecrement (
UINT16
EFIAPI
InterlockedCompareExchange16 (
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -321,9 +325,9 @@ InterlockedCompareExchange16 (
UINT32
EFIAPI
InterlockedCompareExchange32 (
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -351,9 +355,9 @@ InterlockedCompareExchange32 (
UINT64
EFIAPI
InterlockedCompareExchange64 (
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -381,9 +385,9 @@ InterlockedCompareExchange64 (
VOID *
EFIAPI
InterlockedCompareExchangePointer (
IN OUT VOID * volatile *Value,
IN VOID *CompareValue,
IN VOID *ExchangeValue
IN OUT VOID *volatile *Value,
IN VOID *CompareValue,
IN VOID *ExchangeValue
)
{
UINT8 SizeOfValue;
@@ -392,17 +396,17 @@ InterlockedCompareExchangePointer (
switch (SizeOfValue) {
case sizeof (UINT32):
return (VOID*)(UINTN)InterlockedCompareExchange32 (
(volatile UINT32 *)Value,
(UINT32)(UINTN)CompareValue,
(UINT32)(UINTN)ExchangeValue
);
return (VOID *)(UINTN)InterlockedCompareExchange32 (
(volatile UINT32 *)Value,
(UINT32)(UINTN)CompareValue,
(UINT32)(UINTN)ExchangeValue
);
case sizeof (UINT64):
return (VOID*)(UINTN)InterlockedCompareExchange64 (
(volatile UINT64 *)Value,
(UINT64)(UINTN)CompareValue,
(UINT64)(UINTN)ExchangeValue
);
return (VOID *)(UINTN)InterlockedCompareExchange64 (
(volatile UINT64 *)Value,
(UINT64)(UINTN)CompareValue,
(UINT64)(UINTN)ExchangeValue
);
default:
ASSERT (FALSE);
return NULL;

View File

@@ -12,10 +12,10 @@
//
// GCC inline assembly for Read Write Barrier
//
#define _ReadWriteBarrier() do { __asm__ __volatile__ ("": : : "memory"); } while(0)
#define _ReadWriteBarrier() do { __asm__ __volatile__ ("": : : "memory"); } while(0)
#define SPIN_LOCK_RELEASED ((UINTN) 1)
#define SPIN_LOCK_ACQUIRED ((UINTN) 2)
#define SPIN_LOCK_RELEASED ((UINTN) 1)
#define SPIN_LOCK_ACQUIRED ((UINTN) 2)
/**
Retrieves the architecture specific spin lock alignment requirements for
@@ -61,14 +61,14 @@ GetSpinLockProperties (
SPIN_LOCK *
EFIAPI
InitializeSpinLock (
OUT SPIN_LOCK *SpinLock
OUT SPIN_LOCK *SpinLock
)
{
ASSERT (SpinLock != NULL);
_ReadWriteBarrier();
_ReadWriteBarrier ();
*SpinLock = SPIN_LOCK_RELEASED;
_ReadWriteBarrier();
_ReadWriteBarrier ();
return SpinLock;
}
@@ -96,7 +96,7 @@ InitializeSpinLock (
SPIN_LOCK *
EFIAPI
AcquireSpinLock (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
UINT64 Current;
@@ -116,7 +116,7 @@ AcquireSpinLock (
//
// Get the current timer value
//
Current = GetPerformanceCounter();
Current = GetPerformanceCounter ();
//
// Initialize local variables
@@ -140,23 +140,27 @@ AcquireSpinLock (
if (Cycle < 0) {
Cycle = -Cycle;
}
Cycle++;
while (!AcquireSpinLockOrFail (SpinLock)) {
CpuPause ();
Previous = Current;
Current = GetPerformanceCounter();
Delta = (INT64) (Current - Previous);
Current = GetPerformanceCounter ();
Delta = (INT64)(Current - Previous);
if (Start > End) {
Delta = -Delta;
}
if (Delta < 0) {
Delta += Cycle;
}
Total += Delta;
ASSERT (Total < Timeout);
}
}
return SpinLock;
}
@@ -180,11 +184,11 @@ AcquireSpinLock (
BOOLEAN
EFIAPI
AcquireSpinLockOrFail (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
SPIN_LOCK LockValue;
VOID *Result;
SPIN_LOCK LockValue;
VOID *Result;
ASSERT (SpinLock != NULL);
@@ -193,13 +197,13 @@ AcquireSpinLockOrFail (
_ReadWriteBarrier ();
Result = InterlockedCompareExchangePointer (
(VOID**)SpinLock,
(VOID*)SPIN_LOCK_RELEASED,
(VOID*)SPIN_LOCK_ACQUIRED
);
(VOID **)SpinLock,
(VOID *)SPIN_LOCK_RELEASED,
(VOID *)SPIN_LOCK_ACQUIRED
);
_ReadWriteBarrier ();
return (BOOLEAN) (Result == (VOID*) SPIN_LOCK_RELEASED);
return (BOOLEAN)(Result == (VOID *)SPIN_LOCK_RELEASED);
}
/**
@@ -219,10 +223,10 @@ AcquireSpinLockOrFail (
SPIN_LOCK *
EFIAPI
ReleaseSpinLock (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
SPIN_LOCK LockValue;
SPIN_LOCK LockValue;
ASSERT (SpinLock != NULL);
@@ -253,7 +257,7 @@ ReleaseSpinLock (
UINT32
EFIAPI
InterlockedIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
ASSERT (Value != NULL);
@@ -277,7 +281,7 @@ InterlockedIncrement (
UINT32
EFIAPI
InterlockedDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
ASSERT (Value != NULL);
@@ -306,9 +310,9 @@ InterlockedDecrement (
UINT16
EFIAPI
InterlockedCompareExchange16 (
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -337,9 +341,9 @@ InterlockedCompareExchange16 (
UINT32
EFIAPI
InterlockedCompareExchange32 (
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -367,9 +371,9 @@ InterlockedCompareExchange32 (
UINT64
EFIAPI
InterlockedCompareExchange64 (
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -397,9 +401,9 @@ InterlockedCompareExchange64 (
VOID *
EFIAPI
InterlockedCompareExchangePointer (
IN OUT VOID * volatile *Value,
IN VOID *CompareValue,
IN VOID *ExchangeValue
IN OUT VOID *volatile *Value,
IN VOID *CompareValue,
IN VOID *ExchangeValue
)
{
UINT8 SizeOfValue;
@@ -408,17 +412,17 @@ InterlockedCompareExchangePointer (
switch (SizeOfValue) {
case sizeof (UINT32):
return (VOID*)(UINTN)InterlockedCompareExchange32 (
(volatile UINT32 *)Value,
(UINT32)(UINTN)CompareValue,
(UINT32)(UINTN)ExchangeValue
);
return (VOID *)(UINTN)InterlockedCompareExchange32 (
(volatile UINT32 *)Value,
(UINT32)(UINTN)CompareValue,
(UINT32)(UINTN)ExchangeValue
);
case sizeof (UINT64):
return (VOID*)(UINTN)InterlockedCompareExchange64 (
(volatile UINT64 *)Value,
(UINT64)(UINTN)CompareValue,
(UINT64)(UINTN)ExchangeValue
);
return (VOID *)(UINTN)InterlockedCompareExchange64 (
(volatile UINT64 *)Value,
(UINT64)(UINTN)CompareValue,
(UINT64)(UINTN)ExchangeValue
);
default:
ASSERT (FALSE);
return NULL;

View File

@@ -12,12 +12,15 @@
Microsoft Visual Studio 7.1 Function Prototypes for read write barrier Intrinsics.
**/
void _ReadWriteBarrier (void);
void
_ReadWriteBarrier (
void
);
#pragma intrinsic(_ReadWriteBarrier)
#define SPIN_LOCK_RELEASED ((UINTN) 1)
#define SPIN_LOCK_ACQUIRED ((UINTN) 2)
#define SPIN_LOCK_RELEASED ((UINTN) 1)
#define SPIN_LOCK_ACQUIRED ((UINTN) 2)
/**
Retrieves the architecture specific spin lock alignment requirements for
@@ -63,14 +66,14 @@ GetSpinLockProperties (
SPIN_LOCK *
EFIAPI
InitializeSpinLock (
OUT SPIN_LOCK *SpinLock
OUT SPIN_LOCK *SpinLock
)
{
ASSERT (SpinLock != NULL);
_ReadWriteBarrier();
_ReadWriteBarrier ();
*SpinLock = SPIN_LOCK_RELEASED;
_ReadWriteBarrier();
_ReadWriteBarrier ();
return SpinLock;
}
@@ -98,7 +101,7 @@ InitializeSpinLock (
SPIN_LOCK *
EFIAPI
AcquireSpinLock (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
UINT64 Current;
@@ -118,7 +121,7 @@ AcquireSpinLock (
//
// Get the current timer value
//
Current = GetPerformanceCounter();
Current = GetPerformanceCounter ();
//
// Initialize local variables
@@ -142,23 +145,27 @@ AcquireSpinLock (
if (Cycle < 0) {
Cycle = -Cycle;
}
Cycle++;
while (!AcquireSpinLockOrFail (SpinLock)) {
CpuPause ();
Previous = Current;
Current = GetPerformanceCounter();
Delta = (INT64) (Current - Previous);
Current = GetPerformanceCounter ();
Delta = (INT64)(Current - Previous);
if (Start > End) {
Delta = -Delta;
}
if (Delta < 0) {
Delta += Cycle;
}
Total += Delta;
ASSERT (Total < Timeout);
}
}
return SpinLock;
}
@@ -182,11 +189,11 @@ AcquireSpinLock (
BOOLEAN
EFIAPI
AcquireSpinLockOrFail (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
SPIN_LOCK LockValue;
VOID *Result;
SPIN_LOCK LockValue;
VOID *Result;
ASSERT (SpinLock != NULL);
@@ -195,13 +202,13 @@ AcquireSpinLockOrFail (
_ReadWriteBarrier ();
Result = InterlockedCompareExchangePointer (
(VOID**)SpinLock,
(VOID*)SPIN_LOCK_RELEASED,
(VOID*)SPIN_LOCK_ACQUIRED
);
(VOID **)SpinLock,
(VOID *)SPIN_LOCK_RELEASED,
(VOID *)SPIN_LOCK_ACQUIRED
);
_ReadWriteBarrier ();
return (BOOLEAN) (Result == (VOID*) SPIN_LOCK_RELEASED);
return (BOOLEAN)(Result == (VOID *)SPIN_LOCK_RELEASED);
}
/**
@@ -221,10 +228,10 @@ AcquireSpinLockOrFail (
SPIN_LOCK *
EFIAPI
ReleaseSpinLock (
IN OUT SPIN_LOCK *SpinLock
IN OUT SPIN_LOCK *SpinLock
)
{
SPIN_LOCK LockValue;
SPIN_LOCK LockValue;
ASSERT (SpinLock != NULL);
@@ -255,7 +262,7 @@ ReleaseSpinLock (
UINT32
EFIAPI
InterlockedIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
ASSERT (Value != NULL);
@@ -279,7 +286,7 @@ InterlockedIncrement (
UINT32
EFIAPI
InterlockedDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
ASSERT (Value != NULL);
@@ -308,9 +315,9 @@ InterlockedDecrement (
UINT16
EFIAPI
InterlockedCompareExchange16 (
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -339,9 +346,9 @@ InterlockedCompareExchange16 (
UINT32
EFIAPI
InterlockedCompareExchange32 (
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -369,9 +376,9 @@ InterlockedCompareExchange32 (
UINT64
EFIAPI
InterlockedCompareExchange64 (
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
ASSERT (Value != NULL);
@@ -399,28 +406,28 @@ InterlockedCompareExchange64 (
VOID *
EFIAPI
InterlockedCompareExchangePointer (
IN OUT VOID * volatile *Value,
IN VOID *CompareValue,
IN VOID *ExchangeValue
IN OUT VOID *volatile *Value,
IN VOID *CompareValue,
IN VOID *ExchangeValue
)
{
UINT8 SizeOfValue;
SizeOfValue = (UINT8) sizeof (*Value);
SizeOfValue = (UINT8)sizeof (*Value);
switch (SizeOfValue) {
case sizeof (UINT32):
return (VOID*)(UINTN)InterlockedCompareExchange32 (
(volatile UINT32*)Value,
(UINT32)(UINTN)CompareValue,
(UINT32)(UINTN)ExchangeValue
);
return (VOID *)(UINTN)InterlockedCompareExchange32 (
(volatile UINT32 *)Value,
(UINT32)(UINTN)CompareValue,
(UINT32)(UINTN)ExchangeValue
);
case sizeof (UINT64):
return (VOID*)(UINTN)InterlockedCompareExchange64 (
(volatile UINT64*)Value,
(UINT64)(UINTN)CompareValue,
(UINT64)(UINTN)ExchangeValue
);
return (VOID *)(UINTN)InterlockedCompareExchange64 (
(volatile UINT64 *)Value,
(UINT64)(UINTN)CompareValue,
(UINT64)(UINTN)ExchangeValue
);
default:
ASSERT (FALSE);
return NULL;

View File

@@ -7,8 +7,6 @@
**/
/**
Performs an atomic increment of an 32-bit unsigned integer.
@@ -24,7 +22,7 @@
UINT32
EFIAPI
InternalSyncIncrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
UINT32 Result;
@@ -39,12 +37,11 @@ InternalSyncIncrement (
: // no inputs that aren't also outputs
: "memory",
"cc"
);
);
return Result;
}
/**
Performs an atomic decrement of an 32-bit unsigned integer.
@@ -60,10 +57,10 @@ InternalSyncIncrement (
UINT32
EFIAPI
InternalSyncDecrement (
IN volatile UINT32 *Value
IN volatile UINT32 *Value
)
{
UINT32 Result;
UINT32 Result;
__asm__ __volatile__ (
"movl $-1, %%eax \n\t"
@@ -75,12 +72,11 @@ InternalSyncDecrement (
: // no inputs that aren't also outputs
: "memory",
"cc"
);
);
return Result;
}
/**
Performs an atomic compare exchange operation on a 16-bit unsigned integer.
@@ -102,9 +98,9 @@ InternalSyncDecrement (
UINT16
EFIAPI
InternalSyncCompareExchange16 (
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN OUT volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
__asm__ __volatile__ (
@@ -115,12 +111,11 @@ InternalSyncCompareExchange16 (
: "r" (ExchangeValue) // %2
: "memory",
"cc"
);
);
return CompareValue;
}
/**
Performs an atomic compare exchange operation on a 32-bit unsigned integer.
@@ -142,9 +137,9 @@ InternalSyncCompareExchange16 (
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN OUT volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
__asm__ __volatile__ (
@@ -155,12 +150,11 @@ InternalSyncCompareExchange32 (
: "r" (ExchangeValue) // %2
: "memory",
"cc"
);
);
return CompareValue;
}
/**
Performs an atomic compare exchange operation on a 64-bit unsigned integer.
@@ -181,9 +175,9 @@ InternalSyncCompareExchange32 (
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN OUT volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
__asm__ __volatile__ (
@@ -194,7 +188,7 @@ InternalSyncCompareExchange64 (
: "r" (ExchangeValue) // %2
: "memory",
"cc"
);
);
return CompareValue;
}

View File

@@ -11,11 +11,12 @@
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
**/
__int16 _InterlockedCompareExchange16(
__int16 volatile * Destination,
__int16 Exchange,
__int16 Comperand
);
__int16
_InterlockedCompareExchange16 (
__int16 volatile *Destination,
__int16 Exchange,
__int16 Comperand
);
#pragma intrinsic(_InterlockedCompareExchange16)
@@ -38,11 +39,10 @@ __int16 _InterlockedCompareExchange16(
UINT16
EFIAPI
InternalSyncCompareExchange16 (
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
IN volatile UINT16 *Value,
IN UINT16 CompareValue,
IN UINT16 ExchangeValue
)
{
return _InterlockedCompareExchange16 (Value, ExchangeValue, CompareValue);
}

View File

@@ -10,11 +10,12 @@
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
**/
long _InterlockedCompareExchange(
long volatile * Destination,
long Exchange,
long Comperand
);
long
_InterlockedCompareExchange (
long volatile *Destination,
long Exchange,
long Comperand
);
#pragma intrinsic(_InterlockedCompareExchange)
@@ -38,11 +39,10 @@ long _InterlockedCompareExchange(
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
IN volatile UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
return _InterlockedCompareExchange (Value, ExchangeValue, CompareValue);
}

View File

@@ -10,11 +10,12 @@
Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics.
**/
__int64 _InterlockedCompareExchange64(
__int64 volatile * Destination,
__int64 Exchange,
__int64 Comperand
);
__int64
_InterlockedCompareExchange64 (
__int64 volatile *Destination,
__int64 Exchange,
__int64 Comperand
);
#pragma intrinsic(_InterlockedCompareExchange64)
@@ -37,11 +38,10 @@ __int64 _InterlockedCompareExchange64(
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
IN volatile UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
return _InterlockedCompareExchange64 (Value, ExchangeValue, CompareValue);
}