]> git.proxmox.com Git - mirror_edk2.git/commit
MdePkg/SynchronizationLib: fix Interlocked[De|In]crement return value
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 7 Sep 2018 09:26:14 +0000 (17:26 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 25 Sep 2018 02:02:53 +0000 (10:02 +0800)
commit17634d026f968c404b039a8d8431b6389dd396ea
tree765dfedfdd01cba576b4065560fa02ceb0547e9f
parentca3e4f8ab82485edff2cfa7eeb87f71b4be38966
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>
18 files changed:
MdePkg/Include/Library/SynchronizationLib.h
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLibInternals.h
MdePkg/Library/BaseSynchronizationLib/Ia32/GccInline.c
MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedDecrement.c [deleted file]
MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedDecrement.nasm
MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedIncrement.c [deleted file]
MdePkg/Library/BaseSynchronizationLib/Ia32/InterlockedIncrement.nasm
MdePkg/Library/BaseSynchronizationLib/InterlockedDecrementMsc.c [new file with mode: 0644]
MdePkg/Library/BaseSynchronizationLib/InterlockedIncrementMsc.c [new file with mode: 0644]
MdePkg/Library/BaseSynchronizationLib/Synchronization.c
MdePkg/Library/BaseSynchronizationLib/SynchronizationGcc.c
MdePkg/Library/BaseSynchronizationLib/SynchronizationMsc.c
MdePkg/Library/BaseSynchronizationLib/X64/GccInline.c
MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.c [deleted file]
MdePkg/Library/BaseSynchronizationLib/X64/InterlockedDecrement.nasm
MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.c [deleted file]
MdePkg/Library/BaseSynchronizationLib/X64/InterlockedIncrement.nasm