WL#4983: Add Windows support for Google SMP patch in Server

Affects: Server-5.4   —   Status: Complete   —   Priority: Medium

MySQL 5.4.1:
To improve MySQL Server scalability under Windows, update the Google 
SMP patches from the launchpad tree 5.1-patches maintained by Mark 
Callaghan, to work on Windows:
http://code.google.com/p/google-mysql-tools/wiki/SmpPerformance
Applied to MySQL 5.4.1.

Adapt the Google SMP patch so that scalability enhancements are also
available on Windows. Original patch is a Community contribution; for 
details, follow the link to launchpad:
http://code.google.com/p/google-mysql-tools/wiki/SmpPerformance
and the MySQL 5.4.0 description:
https://clustra.norway.sun.com/twiki/bin/view/DatabasesAtSun/MySQLServer51PPHome#Summit_v0_2_Features
=== modified file 'storage/innobase/CMakeLists.txt'
--- storage/innobase/CMakeLists.txt 2009-03-06 23:12:36 +0000
+++ storage/innobase/CMakeLists.txt 2009-06-17 17:16:49 +0000
@@ -31,16 +31,18 @@ IF (NOT WITHOUT_ATOMICS)
# Check for 64 bit atomics TRY_RUN(RUN_RES COMPILE_RES ${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/storage/innobase/win_atomics64_test.c)
- IF (RUN_RES)
+ IF (COMPILE_RES AND NOT RUN_RES) + MESSAGE("Adding support for Win64 atomics")
ADD_DEFINITIONS(-DWIN_ATOMICS64)
- ENDIF (RUN_RES)
+ ENDIF (COMPILE_RES AND NOT RUN_RES)
ELSE (CMAKE_SIZEOF_VOID_P MATCHES 8) # Check for 32 bit atomics TRY_RUN(RUN_RES
COMPILE_RES ${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/storage/innobase/win_atomics32_test.c)
- IF (RUN_RES)
+ IF (COMPILE_RES AND NOT RUN_RES) + MESSAGE("Adding support for Win32 atomics")
ADD_DEFINITIONS(-DWIN_ATOMICS32)
- ENDIF (RUN_RES)
+ ENDIF (COMPILE_RES AND NOT RUN_RES)
ENDIF (CMAKE_SIZEOF_VOID_P MATCHES 8) ENDIF (NOT WITHOUT_ATOMICS) 

====

=== modified file 'storage/innobase/include/os0sync.ic'
--- storage/innobase/include/os0sync.ic 2009-03-06 18:25:38 +0000
+++ storage/innobase/include/os0sync.ic 2009-06-16 13:16:15 +0000
@@ -142,9 +142,9 @@ os_atomic_increment(
#elif HAVE_SOLARIS_ATOMIC return ((lint)atomic_add_long_nv((volatile ulong_t
*)ptr, amount)); #elif WIN_ATOMICS32
- return ((lint)InterlockedExchangeAdd(ptr, amount));
+ return ((lint)InterlockedExchangeAdd(ptr, amount) + amount);
#elif WIN_ATOMICS64
- return ((lint)InterlockedExchangeAdd64(ptr, amount));
+ return ((lint)InterlockedExchangeAdd64(ptr, amount) + amount);
#else #error "Need support for atomic ops" #endif 

====

=== modified file 'storage/innobase/win_atomics32_test.c'
--- storage/innobase/win_atomics32_test.c 2009-03-06 18:25:38 +0000
+++ storage/innobase/win_atomics32_test.c 2009-06-16 13:16:15 +0000
@@ -1,17 +1,17 @@
-# Copyright (C) 2009 Sun Microsystems AB -# -# This program is free software;
you can redistribute it and/or modify -# it under the terms of the GNU General
Public License as published by -# the Free Software Foundation; version 2 of the
License. -# -# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of -#
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General
Public License for more details. -# -# You should have received a copy of the
GNU General Public License -# along with this program; if not, write to the Free
Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+/* Copyright (C) 2009 Sun Microsystems AB + + This program is free software;
you can redistribute it and/or modify + it under the terms of the GNU General
Public License as published by + the Free Software Foundation; version 2 of the
License. + + This program is distributed in the hope that it will be useful, +
but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for
more details. + + You should have received a copy of the GNU General Public
License + along with this program; if not, write to the Free Software +
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <windows.h> 

====

=== modified file 'storage/innobase/win_atomics64_test.c'
--- storage/innobase/win_atomics64_test.c 2009-03-06 18:25:38 +0000
+++ storage/innobase/win_atomics64_test.c 2009-06-16 13:16:15 +0000
@@ -1,17 +1,18 @@
-# Copyright (C) 2009 Sun Microsystems AB -# -# This program is free software;
you can redistribute it and/or modify -# it under the terms of the GNU General
Public License as published by -# the Free Software Foundation; version 2 of the
License. -# -# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of -#
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General
Public License for more details. -# -# You should have received a copy of the
GNU General Public License -# along with this program; if not, write to the Free
Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+/* Copyright (C) 2009 Sun Microsystems AB + + This program is free software;
you can redistribute it and/or modify + it under the terms of the GNU General
Public License as published by + the Free Software Foundation; version 2 of the
License. + + This program is distributed in the hope that it will be useful, +
but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for
more details. + + You should have received a copy of the GNU General Public
License + along with this program; if not, write to the Free Software +
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +
#include <windows.h> int main()