]> granicus.if.org Git - libatomic_ops/commitdiff
2009-09-10 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Thu, 10 Sep 2009 15:09:01 +0000 (15:09 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 25 Jul 2011 12:03:24 +0000 (16:03 +0400)
(diff110)
* src/atomic_ops/sysdeps/msftc/arm.h: New file (initial support
for ARM family).
* src/atomic_ops/sysdeps/msftc/common32_defs.h: New file.
* src/atomic_ops/sysdeps/msftc/arm.h (AO_ASSUME_ARM_ARCH6): New
macro.
* src/atomic_ops/sysdeps/msftc/common32_defs.h
(AO_USE_INTERLOCKED_INTRINSICS): Ditto.
* src/atomic_ops/sysdeps/msftc/x86.h: Move "Interlocked"
declarations to common32_defs.h.
* src/atomic_ops/sysdeps/msftc/common32_defs.h
(AO_INTERLOCKED_VOLATILE): New macro defined (used by
Interlocked-based primitives) for compatibility with older VC++.
* src/atomic_ops/sysdeps/msftc/common32_defs.h: Don't include
missing <intrin.h> if WinCE target.
* src/atomic_ops/sysdeps/msftc/x86.h: Include common32_defs.h
(define AO_USE_INTERLOCKED_INTRINSICS unconditionally).
* src/atomic_ops/sysdeps/msftc/x86.h (AO_fetch_and_add_full,
AO_fetch_and_add1_full, AO_fetch_and_sub1_full,
AO_compare_and_swap_full): Move arch-independent primitives to
common32_defs.h.
* src/atomic_ops/sysdeps/msftc/x86.h: Remove comment about i486 or
better CPU (since Interlocked Add and Xchg primitives are available
on any 32-bit CPU).
* src/atomic_ops.h: Include msftc/x86.h even if _M_IX86 is less than
400 (for i80386).
* src/atomic_ops.h: Include msftc/x86.h if "x86" defined (for WinCE
on x86).
* src/atomic_ops.h: Include msftc/arm.h if ARM target (for WinCE).

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

index 07728c047671ba159314f07729b5e45cd76a5aec..54d153d0f94072a8816cf297b860f9e3ecfff0e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2009-09-10 Ivan Maidanski <ivmai@mail.ru>
+       (diff110)
+       * src/atomic_ops/sysdeps/msftc/arm.h: New file (initial support
+       for ARM family).
+       * src/atomic_ops/sysdeps/msftc/common32_defs.h: New file.
+       * src/atomic_ops/sysdeps/msftc/arm.h (AO_ASSUME_ARM_ARCH6): New
+       macro.
+       * src/atomic_ops/sysdeps/msftc/common32_defs.h
+       (AO_USE_INTERLOCKED_INTRINSICS): Ditto.
+       * src/atomic_ops/sysdeps/msftc/x86.h: Move "Interlocked"
+       declarations to common32_defs.h.
+       * src/atomic_ops/sysdeps/msftc/common32_defs.h
+       (AO_INTERLOCKED_VOLATILE): New macro defined (used by
+       Interlocked-based primitives) for compatibility with older VC++.
+       * src/atomic_ops/sysdeps/msftc/common32_defs.h: Don't include
+       missing <intrin.h> if WinCE target.
+       * src/atomic_ops/sysdeps/msftc/x86.h: Include common32_defs.h
+       (define AO_USE_INTERLOCKED_INTRINSICS unconditionally).
+       * src/atomic_ops/sysdeps/msftc/x86.h (AO_fetch_and_add_full,
+       AO_fetch_and_add1_full, AO_fetch_and_sub1_full,
+       AO_compare_and_swap_full): Move arch-independent primitives to
+       common32_defs.h.
+       * src/atomic_ops/sysdeps/msftc/x86.h: Remove comment about i486 or
+       better CPU (since Interlocked Add and Xchg primitives are available
+       on any 32-bit CPU).
+       * src/atomic_ops.h: Include msftc/x86.h even if _M_IX86 is less than
+       400 (for i80386).
+       * src/atomic_ops.h: Include msftc/x86.h if "x86" defined (for WinCE
+       on x86).
+       * src/atomic_ops.h: Include msftc/arm.h if ARM target (for WinCE).
+
 2009-09-10 Ivan Maidanski <ivmai@mail.ru>
        (diff109_cvs)
        * src/atomic_ops/sysdeps/msftc/x86.h: Fix comments (prefix
index 006d51d201a61af823678b7dcb411c9ff652efd9..d2a3399aafe0157a3562b702e21508c0e6dcfca9 100755 (executable)
        || (defined(__WATCOMC__) && defined(__NT__))
 # if defined(_AMD64_)
 #   include "atomic_ops/sysdeps/msftc/x86_64.h"
-# elif _M_IX86 >= 400
+# elif defined(_M_IX86) || defined(x86)
 #   include "atomic_ops/sysdeps/msftc/x86.h"
+# elif defined(_M_ARM) || defined(ARM) || defined(_ARM_)
+#   include "atomic_ops/sysdeps/msftc/arm.h"
 # endif
 #endif
 
index e5d08f0fa7c99ae07d1bea2696f264d88003852e..28b1424b25e2d343667593f7112aade57d8783e0 100644 (file)
@@ -20,7 +20,6 @@
  * SOFTWARE. 
  */
 
-/* The following really assume we have a 486 or better.                */
 /* If AO_ASSUME_WINDOWS98 is defined, we assume Windows 98 or newer.   */
 /* If AO_ASSUME_VISTA is defined, we assume Windows Server 2003, Vista */
 /* or later.                                                           */
 
 #include "../test_and_set_t_is_char.h"
 
-#include <windows.h>
-       /* Seems like over-kill, but that's what MSDN recommends.       */
-       /* And apparently winbase.h is not always self-contained.       */
-
-#if _MSC_VER < 1310
-
-#define _InterlockedIncrement       InterlockedIncrement
-#define _InterlockedDecrement       InterlockedDecrement
-#define _InterlockedExchange        InterlockedExchange 
-#define _InterlockedExchangeAdd     InterlockedExchangeAdd
-#define _InterlockedCompareExchange InterlockedCompareExchange
-
-#else
-
-#if _MSC_VER >= 1400
-#include <intrin.h>
-
-#pragma intrinsic (_ReadWriteBarrier)
-
-#else
-#ifdef __cplusplus
-extern "C" {
+#ifndef AO_USE_INTERLOCKED_INTRINSICS
+  /* _Interlocked primitives (Inc, Dec, Xchg, Add) are always available        */
+# define AO_USE_INTERLOCKED_INTRINSICS
 #endif
-
-LONG __cdecl _InterlockedIncrement(LONG volatile *Addend);
-LONG __cdecl _InterlockedDecrement(LONG volatile *Addend);
-LONG __cdecl _InterlockedExchangeAdd(LONG volatile* Target, LONG Addend);
-LONG __cdecl _InterlockedExchange(LONG volatile* Target, LONG Value);
-LONG __cdecl _InterlockedCompareExchange(LONG volatile* Dest,
-                                         LONG Exchange, LONG Comp);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* _MSC_VER >= 1400 */
-
-#pragma intrinsic (_InterlockedIncrement)
-#pragma intrinsic (_InterlockedDecrement)
-#pragma intrinsic (_InterlockedExchange)
-#pragma intrinsic (_InterlockedExchangeAdd)
-#pragma intrinsic (_InterlockedCompareExchange)
-
-#endif /* _MSC_VER < 1310 */
+#include "common32_defs.h"
 
 /* As far as we can tell, the lfence and sfence instructions are not   */
 /* currently needed or useful for cached memory accesses.              */
@@ -107,30 +68,6 @@ AO_nop_full(void)
 
 #endif
 
-AO_INLINE AO_t
-AO_fetch_and_add_full (volatile AO_t *p, AO_t incr)
-{
-  return _InterlockedExchangeAdd((LONG volatile*)p, (LONG)incr);
-}
-
-#define AO_HAVE_fetch_and_add_full
-
-AO_INLINE AO_t
-AO_fetch_and_add1_full (volatile AO_t *p)
-{
-  return _InterlockedIncrement((LONG volatile *)p) - 1;
-}
-
-#define AO_HAVE_fetch_and_add1_full
-
-AO_INLINE AO_t
-AO_fetch_and_sub1_full (volatile AO_t *p)
-{
-  return _InterlockedDecrement((LONG volatile *)p) + 1;
-}
-
-#define AO_HAVE_fetch_and_sub1_full
-
 AO_INLINE AO_TS_VAL_t
 AO_test_and_set_full(volatile AO_TS_t *addr)
 {
@@ -145,26 +82,6 @@ AO_test_and_set_full(volatile AO_TS_t *addr)
 
 #define AO_HAVE_test_and_set_full
 
-#ifdef AO_ASSUME_WINDOWS98
-/* Returns nonzero if the comparison succeeded. */
-AO_INLINE int
-AO_compare_and_swap_full(volatile AO_t *addr,
-                        AO_t old, AO_t new_val) 
-{
-# ifdef AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE
-    return _InterlockedCompareExchange((PVOID volatile *)addr,
-                                       (PVOID)new_val, (PVOID)old)
-          == (PVOID)old;
-# else
-    return _InterlockedCompareExchange((LONG volatile *)addr,
-                                       (LONG)new_val, (LONG)old)
-          == (LONG)old;
-# endif
-}
-
-#define AO_HAVE_compare_and_swap_full
-#endif /* AO_ASSUME_WINDOWS98 */
-
 #ifdef _WIN64
 #  error wrong architecture
 #endif