]> granicus.if.org Git - libatomic_ops/commitdiff
2008-01-08 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Joerg Wagner)
authorhboehm <hboehm>
Tue, 8 Jan 2008 01:51:12 +0000 (01:51 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 25 Jul 2011 12:03:24 +0000 (16:03 +0400)
* src/atomic_ops/sysdeps/msftc/x86.h: Conditionally add
compare_double_and_swap_double.

ChangeLog
src/atomic_ops/sysdeps/msftc/x86.h

index 043b4844cd497e0390727d1c797900c3213b8b29..55c7ec090e72ed01cbfa24d6b62c434c8d8cdb24 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-01-08 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Joerg Wagner)
+       * src/atomic_ops/sysdeps/msftc/x86.h: Conditionally add
+       compare_double_and_swap_double.
+
 2008-01-06 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Joerg Wagner)
        * src/atomic_ops/generalize.h: Add test_and_set generalizations,
        Add AO_double_compare_and_swap generalizations.
index 57a03e46bae978d7f0bf34c93a335cb2ca2c7418..81c67a115932fb717e083fa5e3c26c30d5a83ca1 100644 (file)
  * SOFTWARE. 
  */
 
-/* The following really assume we have a 486 or better. */
+/* The following really assume we have a 486 or better.                */
 /* If ASSUME_WINDOWS98 is defined, we assume Windows 98 or newer.      */
+/* If ASSUME_VISTA is defined, we assume Windows Server 2003, Vista    */
+/* or later.                                                           */
 
 #include "../all_aligned_atomic_load_store.h"
 
@@ -160,4 +162,36 @@ AO_compare_and_swap_full(volatile AO_t *addr,
 #  error wrong architecture
 #endif
 
+#ifdef ASSUME_VISTA
+/* NEC LE-IT: whenever we run on a pentium class machine we have that
+ * certain function */
+
+#include "../standard_ao_double_t.h"
+#pragma intrinsic (_InterlockedCompareExchange64)
+/* Returns nonzero if the comparison succeeded. */
+AO_INLINE int
+AO_compare_double_and_swap_double_full(volatile AO_double_t *addr,
+                                      AO_t old_val1, AO_t old_val2,
+                                              AO_t new_val1, AO_t new_val2) 
+{
+    __int64 oldv = (__int64)old_val2 | ((__int64)old_val1 << 32);
+    __int64 newv = (__int64)new_val2 | ((__int64)new_val1 << 32);
+    return _InterlockedCompareExchange64((__int64 volatile *)addr,
+                                       newv, oldv) == oldv;
+}
+#define AO_HAVE_compare_double_and_swap_double_full
+
+#ifdef __cplusplus
+AO_INLINE int
+AO_compare_double_and_swap_double_full(volatile AO_double_t *addr,
+                                      AO_double_t old_val,
+                                      AO_double_t new_val) 
+{
+    return _InterlockedCompareExchange64((__int64 volatile *)addr,
+               new_val.AO_whole, old_val.AO_whole) == old_val.AO_whole;
+}
+#define AO_HAVE_double_compare_and_swap_full
+#endif // __cplusplus
+#endif /* ASSUME_VISTA */
+
 #include "../ao_t_is_int.h"