From: ivmai Date: Thu, 10 Sep 2009 15:09:01 +0000 (+0000) Subject: 2009-09-10 Ivan Maidanski X-Git-Tag: libatomic_ops-7_2alpha4~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9aa3fca5ec90d4f823bbb52c66bd6ffb4ede9d9;p=libatomic_ops 2009-09-10 Ivan Maidanski (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 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). --- diff --git a/ChangeLog b/ChangeLog index 07728c0..54d153d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2009-09-10 Ivan Maidanski + (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 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 (diff109_cvs) * src/atomic_ops/sysdeps/msftc/x86.h: Fix comments (prefix diff --git a/src/atomic_ops.h b/src/atomic_ops.h index 006d51d..d2a3399 100755 --- a/src/atomic_ops.h +++ b/src/atomic_ops.h @@ -280,8 +280,10 @@ || (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 diff --git a/src/atomic_ops/sysdeps/msftc/x86.h b/src/atomic_ops/sysdeps/msftc/x86.h index e5d08f0..28b1424 100644 --- a/src/atomic_ops/sysdeps/msftc/x86.h +++ b/src/atomic_ops/sysdeps/msftc/x86.h @@ -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. */ @@ -38,49 +37,11 @@ #include "../test_and_set_t_is_char.h" -#include - /* 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 - -#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