From 686e915d830d5f3ddd44567952626ff67d67d19a Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 20 Jan 2017 18:10:05 +0300 Subject: [PATCH] Always define word-wide CAS for x86 (MS VC++ 8 or later) Visual Studio 2005 (MS VC++ 8.0) discontinued support of Windows 95. This patch deprecates AO_ASSUME_WINDOWS98 macro. * configure.ac (AO_ASSUME_WINDOWS98): Remove AH template. * doc/README.txt (AO_ASSUME_WINDOWS98): Remove documentation (as relates only to Win95). * doc/README_win32.txt (AO_ASSUME_WINDOWS98): Likwise. * doc/README_win32.txt (AO_ASSUME_VISTA): Update documentation. * src/Makefile.msft (CFLAGS): Remove "-D AO_ASSUME_WINDOWS98". * src/Makefile.msft (test_atomic_w95): Remove target. * src/Makefile.msft (check): Do not call test_atomic_w95; remove the corresponding printed message. * src/atomic_ops/sysdeps/msftc/x86.h: Remove AO_ASSUME_WINDOWS98 from comment. * src/atomic_ops/sysdeps/msftc/x86.h (AO_ASSUME_WINDOWS98): Define (implicitly) if _MSC_VER >= 1400. --- configure.ac | 3 --- doc/README.txt | 6 ------ doc/README_win32.txt | 6 ++---- src/Makefile.msft | 9 ++------- src/atomic_ops/sysdeps/msftc/x86.h | 5 +++-- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index d3eccf8..9087c59 100644 --- a/configure.ac +++ b/configure.ac @@ -149,9 +149,6 @@ AH_TEMPLATE([AO_ASM_X64_AVAILABLE], [Inline assembly available (only VC/x86_64)]) AH_TEMPLATE([AO_ASSUME_VISTA], [Assume Windows Server 2003, Vista or later target (only VC/x86)]) -AH_TEMPLATE([AO_ASSUME_WINDOWS98], - [Assume hardware compare-and-swap functionality available \ - on target (only VC/x86)]) AH_TEMPLATE([AO_CMPXCHG16B_AVAILABLE], [Assume target is not old AMD Opteron chip (only x86_64)]) AH_TEMPLATE([AO_FORCE_USE_SWP], diff --git a/doc/README.txt b/doc/README.txt index 5902e4f..043ea0d 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -230,12 +230,6 @@ Platform notes: All X86: We quietly assume 486 or better. -Microsoft compilers: -Define AO_ASSUME_WINDOWS98 to get access to hardware compare-and-swap -functionality. This relies on the InterlockedCompareExchange() function -which was apparently not supported in Windows95. (There may be a better -way to get access to this.) - Gcc on x86: Define AO_USE_PENTIUM4_INSTRS to use the Pentium 4 mfence instruction. Currently this is appears to be of marginal benefit. diff --git a/doc/README_win32.txt b/doc/README_win32.txt index 812006c..4f1f281 100644 --- a/doc/README_win32.txt +++ b/doc/README_win32.txt @@ -22,10 +22,8 @@ pieces from the resulting src directory contents: The atomic_ops.h implementation is entirely in the header files in Win32. -Most clients of atomic_ops.h will need to define AO_ASSUME_WINDOWS98 before -including it. Compare_and_swap is otherwise not available. -Defining AO_ASSUME_VISTA will make compare_double_and_swap_double available -as well. +If the client defines AO_ASSUME_VISTA (before include atomic_ops.h), it should +make double_compare_and_swap_full available. Please note that MS compiler for x86 does not align AO_double_t on an 8-byte boundary, thus to avoid an undefined behavior, an AO_double_t (volatile) variable should be declared with AO_DOUBLE_ALIGN attribute if the variable diff --git a/src/Makefile.msft b/src/Makefile.msft index 56c0bc3..1438720 100644 --- a/src/Makefile.msft +++ b/src/Makefile.msft @@ -16,7 +16,7 @@ #CPU=$(MY_CPU) #!include -CFLAGS=-O2 -W3 -DAO_ASSUME_WINDOWS98 +CFLAGS=-O2 -W3 LIB_OBJS=atomic_ops.obj atomic_ops_malloc.obj atomic_ops_stack.obj @@ -37,9 +37,6 @@ libatomic_ops_gpl.lib: $(LIB_OBJS) test_atomic: ..\tests\test_atomic.c ..\tests\test_atomic_include.h cl $(CFLAGS) -I. ..\tests\test_atomic.c /Fo.\test_atomic -test_atomic_w95: ..\tests\test_atomic.c ..\tests\test_atomic_include.h - cl -W3 -O2 -I. ..\tests\test_atomic.c /Fo.\test_atomic_w95 - test_malloc: ..\tests\test_malloc.c libatomic_ops_gpl.lib cl $(CFLAGS) -I. ..\tests\test_malloc.c /Fo.\test_malloc \ libatomic_ops_gpl.lib @@ -48,9 +45,7 @@ test_stack: ..\tests\test_stack.c libatomic_ops_gpl.lib cl $(CFLAGS) -I. ..\tests\test_stack.c /Fo.\test_stack \ libatomic_ops_gpl.lib -check: test_atomic test_atomic_w95 test_malloc test_stack - @echo "The following will print lots of 'Missing ...' messages" - test_atomic_w95 +check: test_atomic test_malloc test_stack @echo "The following will print some 'Missing ...' messages" test_atomic test_malloc diff --git a/src/atomic_ops/sysdeps/msftc/x86.h b/src/atomic_ops/sysdeps/msftc/x86.h index aa6ca1b..d9272f5 100644 --- a/src/atomic_ops/sysdeps/msftc/x86.h +++ b/src/atomic_ops/sysdeps/msftc/x86.h @@ -20,7 +20,6 @@ * SOFTWARE. */ -/* 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. */ @@ -28,7 +27,9 @@ #include "../test_and_set_t_is_char.h" -#if defined(AO_ASSUME_VISTA) && !defined(AO_ASSUME_WINDOWS98) +#if !defined(AO_ASSUME_WINDOWS98) \ + && (defined(AO_ASSUME_VISTA) || _MSC_VER >= 1400) + /* Visual Studio 2005 (MS VC++ 8.0) discontinued support of Windows 95. */ # define AO_ASSUME_WINDOWS98 #endif -- 2.40.0