Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
c6a6820e
Commit
c6a6820e
authored
Mar 06, 2009
by
Mikael Ronstrom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for Atomic instructions for Windows
Enables Google patch support on Windows
parent
ea9e898b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
112 additions
and
2 deletions
+112
-2
storage/innobase/CMakeLists.txt
storage/innobase/CMakeLists.txt
+19
-0
storage/innobase/Makefile.am
storage/innobase/Makefile.am
+2
-1
storage/innobase/include/os0sync.ic
storage/innobase/include/os0sync.ic
+22
-1
storage/innobase/include/univ.i
storage/innobase/include/univ.i
+8
-0
storage/innobase/win_atomics32_test.c
storage/innobase/win_atomics32_test.c
+30
-0
storage/innobase/win_atomics64_test.c
storage/innobase/win_atomics64_test.c
+29
-0
win/README
win/README
+1
-0
win/configure.js
win/configure.js
+1
-0
No files found.
storage/innobase/CMakeLists.txt
View file @
c6a6820e
...
...
@@ -25,6 +25,25 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio" AND CMAKE_SIZEOF_VOID_P MATCHES 8)
PROPERTIES COMPILE_FLAGS -Od
)
ENDIF
(
CMAKE_GENERATOR MATCHES
"Visual Studio"
AND CMAKE_SIZEOF_VOID_P MATCHES 8
)
IF
(
NOT WITHOUT_ATOMICS
)
# Check if this Windows version supports atomic instructions
IF
(
CMAKE_SIZEOF_VOID_P MATCHES 8
)
# 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
)
ADD_DEFINTIONS
(
-DWIN_ATOMICS64
)
ENDIF
(
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
)
ADD_DEFINITIONS
(
-DWIN_ATOMICS32
)
ENDIF
(
RUN_RES
)
ENDIF
(
CMAKE_SIZEOF_VOID_P MATCHES 8
)
ENDIF
(
NOT WITHOUT_ATOMICS
)
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
/include
${
CMAKE_SOURCE_DIR
}
/zlib
${
CMAKE_SOURCE_DIR
}
/storage/innobase/include
${
CMAKE_SOURCE_DIR
}
/storage/innobase/handler
...
...
storage/innobase/Makefile.am
View file @
c6a6820e
...
...
@@ -168,7 +168,8 @@ ha_innodb_la_SOURCES= $(libinnobase_a_SOURCES)
EXTRA_DIST
=
CMakeLists.txt plug.in
\
pars/make_bison.sh pars/make_flex.sh
\
pars/pars0grm.y pars/pars0lex.l
pars/pars0grm.y pars/pars0lex.l
\
win_atomics32_test.c win_atomics64_test.c
# Don't update the files from bitkeeper
%
::
SCCS/s.%
storage/innobase/include/os0sync.ic
View file @
c6a6820e
...
...
@@ -64,6 +64,12 @@ os_compare_and_swap(
lint retVal = (lint)atomic_cas_ulong((volatile ulong_t *)ptr,
oldVal, newVal);
return (retVal == oldVal);
#elif WIN_ATOMICS32
lint retVal = (lint)InterlockedCompareExchange(ptr, newVal, oldVal);
return (retVal == oldVal);
#elif WIN_ATOMICS64
lint retVal = (lint)InterlockedCompareExchange64(ptr, newVal, oldVal);
return (retVal == oldVal);
#else
#error "Need support for atomic ops"
#endif
...
...
@@ -79,6 +85,10 @@ os_memory_barrier_load()
__sync_synchronize();
#elif HAVE_SOLARIS_ATOMIC
membar_consumer();
#elif WIN_ATOMICS32
MemoryBarrier();
#elif WIN_ATOMICS64
MemoryBarrier();
#endif
}
...
...
@@ -92,6 +102,10 @@ os_memory_barrier_store()
__sync_synchronize();
#elif HAVE_SOLARIS_ATOMIC
membar_producer();
#elif WIN_ATOMICS32
MemoryBarrier();
#elif WIN_ATOMICS64
MemoryBarrier();
#endif
}
...
...
@@ -105,6 +119,10 @@ os_memory_barrier()
__sync_synchronize();
#elif HAVE_SOLARIS_ATOMIC
membar_enter();
#elif WIN_ATOMICS32
MemoryBarrier();
#elif WIN_ATOMICS64
MemoryBarrier();
#endif
}
...
...
@@ -123,9 +141,12 @@ os_atomic_increment(
return (__sync_add_and_fetch(ptr, amount));
#elif HAVE_SOLARIS_ATOMIC
return ((lint)atomic_add_long_nv((volatile ulong_t *)ptr, amount));
#elif WIN_ATOMICS32
return ((lint)InterlockedExchangeAdd(ptr, amount));
#elif WIN_ATOMICS64
return ((lint)InterlockedExchangeAdd64(ptr, amount));
#else
#error "Need support for atomic ops"
#endif
}
#endif /* UNIV_SYNC_ATOMIC */
storage/innobase/include/univ.i
View file @
c6a6820e
...
...
@@ -144,6 +144,14 @@ by one. */
#
define
UNIV_SYNC_ATOMIC
#
endif
#
if
defined
(
WIN_ATOMICS32
)
||
defined
(
WIN_ATOMICS64
)
/*
* We have a full set of atomic ops available - we will use them
* This is on Windows
*/
#
define
UNIV_SYNC_ATOMIC
#
endif
/*
#define UNIV_SQL_DEBUG
#define UNIV_LOG_DEBUG
...
...
storage/innobase/win_atomics32_test.c
0 → 100644
View file @
c6a6820e
# 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
()
{
volatile
long
var32
=
0
;
long
add32
=
1
;
long
old32
=
0
;
long
exch32
=
1
;
long
ret_value
;
ret_value
=
InterlockedExchangeAdd
(
&
var32
,
add32
);
ret_value
=
InterlockedCompareExchange
(
&
var32
,
exch32
,
old32
);
MemoryBarrier
();
return
EXIT_SUCCESS
;
}
storage/innobase/win_atomics64_test.c
0 → 100644
View file @
c6a6820e
# 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
()
{
volatile
long
long
var64
=
0
;
long
long
add64
=
1
;
long
long
old64
=
0
;
long
long
exch64
=
1
;
long
long
ret_value
;
ret_value
=
InterlockedExchangeAdd64
(
&
var64
,
add64
);
ret_value
=
InterlockedCompareExchange64
(
&
var64
,
exch64
,
old64
);
MemoryBarrier
();
return
EXIT_SUCCESS
;
}
win/README
View file @
c6a6820e
...
...
@@ -58,6 +58,7 @@ The options right now are:
WITH_EXAMPLE_STORAGE_ENGINE
WITH_FEDERATED_STORAGE_ENGINE
__NT__ Enable named pipe support
WITHOUT_ATOMICS Do not use atomic instructions
MYSQL_SERVER_SUFFIX=<suffix> Server suffix, default none
COMPILATION_COMMENT=<comment> Server comment, default "Source distribution"
MYSQL_TCP_PORT=<port> Server port, default 3306
...
...
win/configure.js
View file @
c6a6820e
...
...
@@ -50,6 +50,7 @@ try
case
"
EMBED_MANIFESTS
"
:
case
"
EXTRA_DEBUG
"
:
case
"
WITH_EMBEDDED_SERVER
"
:
case
"
WITHOUT_ATOMICS
"
:
configfile
.
WriteLine
(
"
SET (
"
+
args
.
Item
(
i
)
+
"
TRUE)
"
);
break
;
case
"
MYSQL_SERVER_SUFFIX
"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment