Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
ed9d1e1f
Commit
ed9d1e1f
authored
Aug 24, 2016
by
Billy Donahue
Committed by
GitHub
Aug 24, 2016
Browse files
Merge pull request #721 from ilmagico/fix-mingw-threads
Fix compilation of googletest with MinGW using Win32 threads
parents
ec44c6c1
a138385e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
googletest/cmake/internal_utils.cmake
googletest/cmake/internal_utils.cmake
+3
-1
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+9
-3
googletest/test/gtest-port_test.cc
googletest/test/gtest-port_test.cc
+7
-0
googletest/test/gtest_unittest.cc
googletest/test/gtest_unittest.cc
+1
-1
No files found.
googletest/cmake/internal_utils.cmake
View file @
ed9d1e1f
...
@@ -46,7 +46,9 @@ endmacro()
...
@@ -46,7 +46,9 @@ endmacro()
# Google Mock. You can tweak these definitions to suit your need. A
# Google Mock. You can tweak these definitions to suit your need. A
# variable's value is empty before it's explicitly assigned to.
# variable's value is empty before it's explicitly assigned to.
macro
(
config_compiler_and_linker
)
macro
(
config_compiler_and_linker
)
if
(
NOT gtest_disable_pthreads
)
# Note: pthreads on MinGW is not supported, even if available
# instead, we use windows threading primitives
if
(
NOT gtest_disable_pthreads AND NOT MINGW
)
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
find_package
(
Threads
)
find_package
(
Threads
)
endif
()
endif
()
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
ed9d1e1f
...
@@ -396,10 +396,16 @@
...
@@ -396,10 +396,16 @@
# include <io.h>
# include <io.h>
# endif
# endif
// In order to avoid having to include <windows.h>, use forward declaration
// In order to avoid having to include <windows.h>, use forward declaration
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
#if GTEST_OS_WINDOWS_MINGW
// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
// separate (equivalent) structs, instead of using typedef
typedef
struct
_CRITICAL_SECTION
GTEST_CRITICAL_SECTION
;
#else
// Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
struct
_RTL_CRITICAL_SECTION
;
typedef
struct
_RTL_CRITICAL_SECTION
GTEST_CRITICAL_SECTION
;
#endif
#else
#else
// This assumes that non-Windows OSes provide unistd.h. For OSes where this
// This assumes that non-Windows OSes provide unistd.h. For OSes where this
// is not the case, we need to include headers that provide the functions
// is not the case, we need to include headers that provide the functions
...
@@ -1693,7 +1699,7 @@ class GTEST_API_ Mutex {
...
@@ -1693,7 +1699,7 @@ class GTEST_API_ Mutex {
// by the linker.
// by the linker.
MutexType
type_
;
MutexType
type_
;
long
critical_section_init_phase_
;
// NOLINT
long
critical_section_init_phase_
;
// NOLINT
_RTL
_CRITICAL_SECTION
*
critical_section_
;
GTEST
_CRITICAL_SECTION
*
critical_section_
;
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
Mutex
);
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
Mutex
);
};
};
...
...
googletest/test/gtest-port_test.cc
View file @
ed9d1e1f
...
@@ -1295,9 +1295,16 @@ TEST(WindowsTypesTest, HANDLEIsVoidStar) {
...
@@ -1295,9 +1295,16 @@ TEST(WindowsTypesTest, HANDLEIsVoidStar) {
StaticAssertTypeEq
<
HANDLE
,
void
*>
();
StaticAssertTypeEq
<
HANDLE
,
void
*>
();
}
}
#if GTEST_OS_WINDOWS_MINGW
TEST
(
WindowsTypesTest
,
_CRITICAL_SECTIONIs_CRITICAL_SECTION
)
{
StaticAssertTypeEq
<
CRITICAL_SECTION
,
_CRITICAL_SECTION
>
();
}
#else
TEST
(
WindowsTypesTest
,
CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION
)
{
TEST
(
WindowsTypesTest
,
CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION
)
{
StaticAssertTypeEq
<
CRITICAL_SECTION
,
_RTL_CRITICAL_SECTION
>
();
StaticAssertTypeEq
<
CRITICAL_SECTION
,
_RTL_CRITICAL_SECTION
>
();
}
}
#endif
#endif // GTEST_OS_WINDOWS
#endif // GTEST_OS_WINDOWS
}
// namespace internal
}
// namespace internal
...
...
googletest/test/gtest_unittest.cc
View file @
ed9d1e1f
...
@@ -442,7 +442,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
...
@@ -442,7 +442,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
// tzset() distinguishes between the TZ variable being present and empty
// tzset() distinguishes between the TZ variable being present and empty
// and not being present, so we have to consider the case of time_zone
// and not being present, so we have to consider the case of time_zone
// being NULL.
// being NULL.
#if _MSC_VER
#if _MSC_VER
|| GTEST_OS_WINDOWS_MINGW
// ...Unless it's MSVC, whose standard library's _putenv doesn't
// ...Unless it's MSVC, whose standard library's _putenv doesn't
// distinguish between an empty and a missing variable.
// distinguish between an empty and a missing variable.
const
std
::
string
env_var
=
const
std
::
string
env_var
=
...
...
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