From: ivmai Date: Thu, 10 Sep 2009 15:01:14 +0000 (+0000) Subject: 2009-09-10 Ivan Maidanski X-Git-Tag: libatomic_ops-7_2alpha4~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e534238d86a7030745847cd11726763ee58d0ae;p=libatomic_ops 2009-09-10 Ivan Maidanski (diff109_cvs) * src/atomic_ops/sysdeps/msftc/x86.h: Fix comments (prefix ASSUME_WINDOWS98 with "AO_"). * src/atomic_ops/sysdeps/msftc/x86.h: Prefix ASSUME_VISTA macro with "AO_". * src/atomic_ops/sysdeps/msftc/x86.h (AO_nop_full): Replace K&R-style function definition with ANSI C one. * src/atomic_ops/sysdeps/msftc/x86.h (AO_test_and_set_full): Replace AO_TS_SET with its value 0xff (some compilers does not like C enum consts inside inline assembler). * src/atomic_ops/sysdeps/msftc/x86.h (AO_test_and_set_full): Add comment about "missing return value" warning. * src/atomic_ops/sysdeps/msftc/x86.h (AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE): New macro. * src/atomic_ops/sysdeps/msftc/x86.h (AO_compare_and_swap_full): Use _InterlockedCompareExchange() with args and result of PVOID type if AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE is defined (mostly for DigitalMars compiler support). * src/atomic_ops/sysdeps/msftc/x86.h (AO_compare_double_and_swap_double_full): Swap all "val1" and "val2" variables ("val1" is the lowest part of AO_double_t). * src/atomic_ops/sysdeps/msftc/x86.h (AO_compare_double_and_swap_double_full): Rename to AO_double_compare_and_swap_full (as it has 3 args). * src/atomic_ops/sysdeps/msftc/x86.h: Replace C++ style comment with ANSI C one. --- diff --git a/ChangeLog b/ChangeLog index 0ec61b5..07728c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,32 @@ -2009-08-06 Ivan Maidanski +2009-09-10 Ivan Maidanski + (diff109_cvs) + * src/atomic_ops/sysdeps/msftc/x86.h: Fix comments (prefix + ASSUME_WINDOWS98 with "AO_"). + * src/atomic_ops/sysdeps/msftc/x86.h: Prefix ASSUME_VISTA macro with + "AO_". + * src/atomic_ops/sysdeps/msftc/x86.h (AO_nop_full): Replace + K&R-style function definition with ANSI C one. + * src/atomic_ops/sysdeps/msftc/x86.h (AO_test_and_set_full): + Replace AO_TS_SET with its value 0xff (some compilers does not like + C enum consts inside inline assembler). + * src/atomic_ops/sysdeps/msftc/x86.h (AO_test_and_set_full): Add + comment about "missing return value" warning. + * src/atomic_ops/sysdeps/msftc/x86.h + (AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE): New macro. + * src/atomic_ops/sysdeps/msftc/x86.h (AO_compare_and_swap_full): Use + _InterlockedCompareExchange() with args and result of PVOID type + if AO_OLD_STYLE_INTERLOCKED_COMPARE_EXCHANGE is defined (mostly for + DigitalMars compiler support). + * src/atomic_ops/sysdeps/msftc/x86.h + (AO_compare_double_and_swap_double_full): Swap all "val1" and "val2" + variables ("val1" is the lowest part of AO_double_t). + * src/atomic_ops/sysdeps/msftc/x86.h + (AO_compare_double_and_swap_double_full): Rename to + AO_double_compare_and_swap_full (as it has 3 args). + * src/atomic_ops/sysdeps/msftc/x86.h: Replace C++ style comment + with ANSI C one. + +2009-09-10 Ivan Maidanski * src/atomic_ops/sysdeps/gcc/x86_64.h: Remove comments about i486 and 32-bit WinChips. * src/atomic_ops/sysdeps/msftc/x86_64.h: Ditto. diff --git a/src/atomic_ops/sysdeps/msftc/x86.h b/src/atomic_ops/sysdeps/msftc/x86.h index 81c67a1..e5d08f0 100644 --- a/src/atomic_ops/sysdeps/msftc/x86.h +++ b/src/atomic_ops/sysdeps/msftc/x86.h @@ -21,8 +21,8 @@ */ /* 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 */ +/* 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 "../all_aligned_atomic_load_store.h" @@ -92,7 +92,7 @@ LONG __cdecl _InterlockedCompareExchange(LONG volatile* Dest, #if defined(AO_USE_PENTIUM4_INSTRS) AO_INLINE void -AO_nop_full() +AO_nop_full(void) { __asm { mfence } } @@ -136,10 +136,11 @@ AO_test_and_set_full(volatile AO_TS_t *addr) { __asm { - mov eax,AO_TS_SET ; + mov eax,0xff ; /* AO_TS_SET */ mov ebx,addr ; xchg byte ptr [ebx],al ; } + /* Ignore possible "missing return value" warning here. */ } #define AO_HAVE_test_and_set_full @@ -150,19 +151,25 @@ 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 /* ASSUME_WINDOWS98 */ +#endif /* AO_ASSUME_WINDOWS98 */ #ifdef _WIN64 # error wrong architecture #endif -#ifdef ASSUME_VISTA +#ifdef AO_ASSUME_VISTA /* NEC LE-IT: whenever we run on a pentium class machine we have that * certain function */ @@ -174,8 +181,8 @@ 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); + __int64 oldv = (__int64)old_val1 | ((__int64)old_val2 << 32); + __int64 newv = (__int64)new_val1 | ((__int64)new_val2 << 32); return _InterlockedCompareExchange64((__int64 volatile *)addr, newv, oldv) == oldv; } @@ -183,15 +190,14 @@ AO_compare_double_and_swap_double_full(volatile AO_double_t *addr, #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) +AO_double_compare_and_swap_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 */ +#endif /* __cplusplus */ +#endif /* AO_ASSUME_VISTA */ #include "../ao_t_is_int.h"