+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
* 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. */
#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)
{
#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