wine-staging/patches/vcomp-Functions/0001-vcomp-Implement-32-bit-atomic-integer-functions.patch

167 lines
4.5 KiB
Diff

From 6f3f0538fc92bc42e942353a446df3afdb395a19 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 26 Jul 2015 01:53:56 +0200
Subject: vcomp: Implement 32-bit atomic integer functions.
---
dlls/vcomp/main.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
dlls/vcomp/vcomp.spec | 22 ++++++++---------
2 files changed, 76 insertions(+), 11 deletions(-)
diff --git a/dlls/vcomp/main.c b/dlls/vcomp/main.c
index ae5623b..6f0caf6 100644
--- a/dlls/vcomp/main.c
+++ b/dlls/vcomp/main.c
@@ -22,6 +22,7 @@
*/
#include "config.h"
+#include "wine/port.h"
#include <stdarg.h>
#include <assert.h>
@@ -221,6 +222,70 @@ static void vcomp_free_thread_data(void)
vcomp_set_thread_data(NULL);
}
+void CDECL _vcomp_atomic_add_i4(int *dest, int val)
+{
+ interlocked_xchg_add(dest, val);
+}
+
+void CDECL _vcomp_atomic_and_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old & val, old) != old);
+}
+
+void CDECL _vcomp_atomic_div_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old / val, old) != old);
+}
+
+void CDECL _vcomp_atomic_div_ui4(unsigned int *dest, unsigned int val)
+{
+ unsigned int old;
+ do old = *dest; while (interlocked_cmpxchg((int *)dest, old / val, old) != old);
+}
+
+void CDECL _vcomp_atomic_mul_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old * val, old) != old);
+}
+
+void CDECL _vcomp_atomic_or_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old | val, old) != old);
+}
+
+void CDECL _vcomp_atomic_shl_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old << val, old) != old);
+}
+
+void CDECL _vcomp_atomic_shr_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old >> val, old) != old);
+}
+
+void CDECL _vcomp_atomic_shr_ui4(unsigned int *dest, unsigned int val)
+{
+ unsigned int old;
+ do old = *dest; while (interlocked_cmpxchg((int *)dest, old >> val, old) != old);
+}
+
+void CDECL _vcomp_atomic_sub_i4(int *dest, int val)
+{
+ interlocked_xchg_add(dest, -val);
+}
+
+void CDECL _vcomp_atomic_xor_i4(int *dest, int val)
+{
+ int old;
+ do old = *dest; while (interlocked_cmpxchg(dest, old ^ val, old) != old);
+}
+
int CDECL omp_get_dynamic(void)
{
TRACE("stub\n");
diff --git a/dlls/vcomp/vcomp.spec b/dlls/vcomp/vcomp.spec
index 7083ce4..768daef 100644
--- a/dlls/vcomp/vcomp.spec
+++ b/dlls/vcomp/vcomp.spec
@@ -1,54 +1,54 @@
@ stub _vcomp_atomic_add_i1
@ stub _vcomp_atomic_add_i2
-@ stub _vcomp_atomic_add_i4
+@ cdecl _vcomp_atomic_add_i4(ptr long)
@ stub _vcomp_atomic_add_i8
@ stub _vcomp_atomic_add_r4
@ stub _vcomp_atomic_add_r8
@ stub _vcomp_atomic_and_i1
@ stub _vcomp_atomic_and_i2
-@ stub _vcomp_atomic_and_i4
+@ cdecl _vcomp_atomic_and_i4(ptr long)
@ stub _vcomp_atomic_and_i8
@ stub _vcomp_atomic_div_i1
@ stub _vcomp_atomic_div_i2
-@ stub _vcomp_atomic_div_i4
+@ cdecl _vcomp_atomic_div_i4(ptr long)
@ stub _vcomp_atomic_div_i8
@ stub _vcomp_atomic_div_r4
@ stub _vcomp_atomic_div_r8
@ stub _vcomp_atomic_div_ui1
@ stub _vcomp_atomic_div_ui2
-@ stub _vcomp_atomic_div_ui4
+@ cdecl _vcomp_atomic_div_ui4(ptr long)
@ stub _vcomp_atomic_div_ui8
@ stub _vcomp_atomic_mul_i1
@ stub _vcomp_atomic_mul_i2
-@ stub _vcomp_atomic_mul_i4
+@ cdecl _vcomp_atomic_mul_i4(ptr long)
@ stub _vcomp_atomic_mul_i8
@ stub _vcomp_atomic_mul_r4
@ stub _vcomp_atomic_mul_r8
@ stub _vcomp_atomic_or_i1
@ stub _vcomp_atomic_or_i2
-@ stub _vcomp_atomic_or_i4
+@ cdecl _vcomp_atomic_or_i4(ptr long)
@ stub _vcomp_atomic_or_i8
@ stub _vcomp_atomic_shl_i1
@ stub _vcomp_atomic_shl_i2
-@ stub _vcomp_atomic_shl_i4
+@ cdecl _vcomp_atomic_shl_i4(ptr long)
@ stub _vcomp_atomic_shl_i8
@ stub _vcomp_atomic_shr_i1
@ stub _vcomp_atomic_shr_i2
-@ stub _vcomp_atomic_shr_i4
+@ cdecl _vcomp_atomic_shr_i4(ptr long)
@ stub _vcomp_atomic_shr_i8
@ stub _vcomp_atomic_shr_ui1
@ stub _vcomp_atomic_shr_ui2
-@ stub _vcomp_atomic_shr_ui4
+@ cdecl _vcomp_atomic_shr_ui4(ptr long)
@ stub _vcomp_atomic_shr_ui8
@ stub _vcomp_atomic_sub_i1
@ stub _vcomp_atomic_sub_i2
-@ stub _vcomp_atomic_sub_i4
+@ cdecl _vcomp_atomic_sub_i4(ptr long)
@ stub _vcomp_atomic_sub_i8
@ stub _vcomp_atomic_sub_r4
@ stub _vcomp_atomic_sub_r8
@ stub _vcomp_atomic_xor_i1
@ stub _vcomp_atomic_xor_i2
-@ stub _vcomp_atomic_xor_i4
+@ cdecl _vcomp_atomic_xor_i4(ptr long)
@ stub _vcomp_atomic_xor_i8
@ cdecl _vcomp_barrier()
@ stub _vcomp_copyprivate_broadcast
--
2.4.5