summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c')
-rw-r--r--MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c
index 5224dd063f..4c4d6e3fc7 100644
--- a/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c
+++ b/MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c
@@ -15,14 +15,12 @@
-
/**
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,9 +36,10 @@ InternalSyncIncrement (
UINT32 Result;
__asm__ __volatile__ (
+ "movl $1, %%eax \n\t"
"lock \n\t"
- "incl %2 \n\t"
- "mov %2, %%eax "
+ "xadd %%eax, %2 \n\t"
+ "inc %%eax "
: "=a" (Result), // %0
"=m" (*Value) // %1
: "m" (*Value) // %2
@@ -57,8 +56,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.
@@ -74,9 +72,10 @@ InternalSyncDecrement (
UINT32 Result;
__asm__ __volatile__ (
- "lock \n\t"
- "decl %2 \n\t"
- "mov %2, %%eax "
+ "movl $-1, %%eax \n\t"
+ "lock \n\t"
+ "xadd %%eax, %2 \n\t"
+ "dec %%eax "
: "=a" (Result), // %0
"=m" (*Value) // %1
: "m" (*Value) // %2