32-bit x86 kernel32.dll provides 6 Interlocked functions:
InterlockedDecrement@4
InterlockedExchange@8
InterlockedIncrement@4
InterlockedCompareExchange@12
InterlockedExchangeAdd@8
InterlockedCompareExchange64@20
WinSDK provides functions for these symbol in kernel32.lib import library
as direct reference of import symbols.
These 6 stdcall functions are currently missing in the 32-bit x86 mingw-w64
libkernel32.a library. mingw-w64 libkernel32.a library provides functions
with same functionality but prefixed by underscore and with cdec calling
convention. They are implemened as wrappers around gcc __sync_ builtin
functions.
So provide missing stdcall functions in 32-bit x86 libkernel32.a library
via intrin.h and update corresponding comments in lib32/kernel32.def.
---
mingw-w64-crt/Makefile.am | 4 +++-
mingw-w64-crt/intrincs/ilockcxch64_i386.c | 8 ++++++++
mingw-w64-crt/intrincs/ilockcxch_i386.c | 8 ++++++++
mingw-w64-crt/intrincs/ilockdec_i386.c | 8 ++++++++
mingw-w64-crt/intrincs/ilockexch_i386.c | 8 ++++++++
mingw-w64-crt/intrincs/ilockexchadd_i386.c | 8 ++++++++
mingw-w64-crt/intrincs/ilockinc_i386.c | 8 ++++++++
mingw-w64-crt/lib32/kernel32.def | 12 ++++++------
8 files changed, 57 insertions(+), 7 deletions(-)
create mode 100644 mingw-w64-crt/intrincs/ilockcxch64_i386.c
create mode 100644 mingw-w64-crt/intrincs/ilockcxch_i386.c
create mode 100644 mingw-w64-crt/intrincs/ilockdec_i386.c
create mode 100644 mingw-w64-crt/intrincs/ilockexch_i386.c
create mode 100644 mingw-w64-crt/intrincs/ilockexchadd_i386.c
create mode 100644 mingw-w64-crt/intrincs/ilockinc_i386.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index afb8aa10ed73..d031fe48e2c7 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -1271,7 +1271,9 @@ src_intrincs64=\
# these only go into the 32 bit version:
src_intrincs32=\
intrincs/rdtsc.c intrincs/readfsbyte.c intrincs/readfsword.c
intrincs/readfsdword.c \
- intrincs/writefsbyte.c intrincs/writefsword.c intrincs/writefsdword.c
+ intrincs/writefsbyte.c intrincs/writefsword.c intrincs/writefsdword.c \
+ intrincs/ilockinc_i386.c intrincs/ilockdec_i386.c intrincs/ilockexch_i386.c \
+ intrincs/ilockcxch_i386.c intrincs/ilockexchadd_i386.c
intrincs/ilockcxch64_i386.c
# these only go into the ARM32 version:
src_intrincsarm32=
diff --git a/mingw-w64-crt/intrincs/ilockcxch64_i386.c
b/mingw-w64-crt/intrincs/ilockcxch64_i386.c
new file mode 100644
index 000000000000..6369b185fcd7
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockcxch64_i386.c
@@ -0,0 +1,8 @@
+#include <intrin.h>
+
+/* Replace i386 kernel32.dll stdcall InterlockedCompareExchange64 function by
_InterlockedCompareExchange64 intrinsic */
+__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
__int64 ExChange, __int64 Comperand);
+__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
__int64 ExChange, __int64 Comperand)
+{
+ return _InterlockedCompareExchange64(Destination, ExChange, Comperand);
+}
diff --git a/mingw-w64-crt/intrincs/ilockcxch_i386.c
b/mingw-w64-crt/intrincs/ilockcxch_i386.c
new file mode 100644
index 000000000000..58818348b97a
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockcxch_i386.c
@@ -0,0 +1,8 @@
+#include <intrin.h>
+
+/* Replace i386 kernel32.dll stdcall InterlockedCompareExchange function by
_InterlockedCompareExchange intrinsic */
+long __stdcall InterlockedCompareExchange(long volatile *Destination, long
ExChange, long Comperand);
+long __stdcall InterlockedCompareExchange(long volatile *Destination, long
ExChange, long Comperand)
+{
+ return _InterlockedCompareExchange(Destination, ExChange, Comperand);
+}
diff --git a/mingw-w64-crt/intrincs/ilockdec_i386.c
b/mingw-w64-crt/intrincs/ilockdec_i386.c
new file mode 100644
index 000000000000..dbf1e6e8ae7c
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockdec_i386.c
@@ -0,0 +1,8 @@
+#include <intrin.h>
+
+/* Replace i386 kernel32.dll stdcall InterlockedDecrement function by
_InterlockedDecrement intrinsic */
+long __stdcall InterlockedDecrement(long volatile *Addend);
+long __stdcall InterlockedDecrement(long volatile *Addend)
+{
+ return _InterlockedDecrement(Addend);
+}
diff --git a/mingw-w64-crt/intrincs/ilockexch_i386.c
b/mingw-w64-crt/intrincs/ilockexch_i386.c
new file mode 100644
index 000000000000..cbf4ab686648
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockexch_i386.c
@@ -0,0 +1,8 @@
+#include <intrin.h>
+
+/* Replace i386 kernel32.dll stdcall InterlockedExchange function by
_InterlockedExchange intrinsic */
+long __stdcall InterlockedExchange(long volatile *Target, long Value);
+long __stdcall InterlockedExchange(long volatile *Target, long Value)
+{
+ return _InterlockedExchange(Target, Value);
+}
diff --git a/mingw-w64-crt/intrincs/ilockexchadd_i386.c
b/mingw-w64-crt/intrincs/ilockexchadd_i386.c
new file mode 100644
index 000000000000..0be152006c64
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockexchadd_i386.c
@@ -0,0 +1,8 @@
+#include <intrin.h>
+
+/* Replace i386 kernel32.dll stdcall InterlockedExchangeAdd function by
_InterlockedExchangeAdd intrinsic */
+long __stdcall InterlockedExchangeAdd(long volatile *Addend, long Value);
+long __stdcall InterlockedExchangeAdd(long volatile *Addend, long Value)
+{
+ return _InterlockedExchangeAdd(Addend, Value);
+}
diff --git a/mingw-w64-crt/intrincs/ilockinc_i386.c
b/mingw-w64-crt/intrincs/ilockinc_i386.c
new file mode 100644
index 000000000000..872075bc7478
--- /dev/null
+++ b/mingw-w64-crt/intrincs/ilockinc_i386.c
@@ -0,0 +1,8 @@
+#include <intrin.h>
+
+/* Replace i386 kernel32.dll stdcall InterlockedIncrement function by
_InterlockedIncrement intrinsic */
+long __stdcall InterlockedIncrement(long volatile *Addend);
+long __stdcall InterlockedIncrement(long volatile *Addend)
+{
+ return _InterlockedIncrement(Addend);
+}
diff --git a/mingw-w64-crt/lib32/kernel32.def b/mingw-w64-crt/lib32/kernel32.def
index 996235d91410..1ea294ac9690 100644
--- a/mingw-w64-crt/lib32/kernel32.def
+++ b/mingw-w64-crt/lib32/kernel32.def
@@ -271,9 +271,9 @@ HeapReAlloc@16
HeapSize@12
InitAtomTable@4
InitializeCriticalSection@4
-InterlockedDecrement@4 DATA ; FIXME: why is decorated stdcall function symbol
disabled?
-InterlockedExchange@8 DATA ; FIXME: why is decorated stdcall function symbol
disabled?
-InterlockedIncrement@4 DATA ; FIXME: why is decorated stdcall function symbol
disabled?
+InterlockedDecrement@4 DATA ; function is replaced by builtin
__sync_sub_and_fetch in import library
+InterlockedExchange@8 DATA ; function is replaced by builtin
__sync_lock_test_and_set in import library
+InterlockedIncrement@4 DATA ; function is replaced by builtin
__sync_add_and_fetch in import library
IsBadCodePtr@4
IsBadHugeReadPtr@8
IsBadHugeWritePtr@8
@@ -762,8 +762,8 @@ GetFileAttributesExA@12
GetFileAttributesExW@12
GetProcessPriorityBoost@8
GetThreadPriorityBoost@8
-InterlockedCompareExchange@12 DATA ; FIXME: why is decorated stdcall function
symbol disabled?
-InterlockedExchangeAdd@8 DATA ; FIXME: why is decorated stdcall function
symbol disabled?
+InterlockedCompareExchange@12 DATA ; function is replaced by builtin
__sync_val_compare_and_swap in import library
+InterlockedExchangeAdd@8 DATA ; function is replaced by builtin
__sync_fetch_and_add in import library
IsProcessorFeaturePresent@4
OpenWaitableTimerA@12
OpenWaitableTimerW@12
@@ -1364,7 +1364,7 @@ GetNLSVersion@12
GetProcessIdOfThread@4
GetProcessWorkingSetSizeEx@16
GetThreadId@4
-InterlockedCompareExchange64@20 DATA ; FIXME: why is decorated stdcall
function symbol disabled?
+InterlockedCompareExchange64@20 DATA ; function is replaced by builtin
__sync_val_compare_and_swap in import library
IsNLSDefinedString@20
IsTimeZoneRedirectionEnabled@0 ; removed in Windows 8
NeedCurrentDirectoryForExePathA@4
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public