MdePkg/SynchronizationLib: fix Interlocked[De|In]crement return value

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

Today's InterlockedIncrement()/InterlockedDecrement() guarantees to
perform atomic increment/decrement but doesn't guarantee the return
value equals to the new value.

The patch fixes the behavior to use "XADD" instruction to guarantee
the return value equals to the new value.

The patch calls intrinsic functions for MSVC tool chain, calls the
NASM implementation for INTEL tool chain and calls GCC inline
assembly implementation (GccInline.c) for GCC tool chain.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Ruiyu Ni
2018-09-07 17:26:14 +08:00
parent ca3e4f8ab8
commit 17634d026f
16 changed files with 56 additions and 152 deletions

View File

@@ -34,9 +34,9 @@
Ia32/InterlockedCompareExchange64.c | MSFT
Ia32/InterlockedCompareExchange32.c | MSFT
Ia32/InterlockedCompareExchange16.c | MSFT
Ia32/InterlockedDecrement.c | MSFT
Ia32/InterlockedIncrement.c | MSFT
SynchronizationMsc.c | MSFT
InterlockedIncrementMsc.c | MSFT
InterlockedDecrementMsc.c | MSFT
SynchronizationMsc.c | MSFT
Ia32/InterlockedCompareExchange64.nasm| INTEL
Ia32/InterlockedCompareExchange32.nasm| INTEL
@@ -54,17 +54,15 @@
X64/InterlockedCompareExchange64.c | MSFT
X64/InterlockedCompareExchange32.c | MSFT
X64/InterlockedCompareExchange16.c | MSFT
InterlockedIncrementMsc.c | MSFT
InterlockedDecrementMsc.c | MSFT
SynchronizationMsc.c | MSFT
X64/InterlockedCompareExchange64.nasm| INTEL
X64/InterlockedCompareExchange32.nasm| INTEL
X64/InterlockedCompareExchange16.nasm| INTEL
X64/InterlockedDecrement.c | MSFT
X64/InterlockedIncrement.c | MSFT
SynchronizationMsc.c | MSFT
X64/InterlockedDecrement.nasm| INTEL
X64/InterlockedIncrement.nasm| INTEL
X64/InterlockedDecrement.nasm | INTEL
X64/InterlockedIncrement.nasm | INTEL
Synchronization.c | INTEL
Ia32/InternalGetSpinLockProperties.c | GCC