Skip to content

Commit

Permalink
Merge pull request #37 from DragoonX6/master
Browse files Browse the repository at this point in the history
Fixing MingW/Clang issues on Windows.
  • Loading branch information
rparolin committed Apr 3, 2016
2 parents 5a1f0ff + 2a72b7b commit 124048e
Show file tree
Hide file tree
Showing 22 changed files with 133 additions and 96 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ endif()
#-------------------------------------------------------------------------------------------
add_definitions(-D_CHAR16T)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DEASTL_OPENSOURCE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-DEASTL_OPENSOURCE=1)

#-------------------------------------------------------------------------------------------
# Library definition
Expand All @@ -48,12 +49,22 @@ add_library(EASTL ${EASTL_SOURCES})
# Compiler Flags
#-------------------------------------------------------------------------------------------
set_property(TARGET EASTL PROPERTY CXX_STANDARD 11)

if(EASTL_BUILD_TESTS OR EASTL_BUILD_BENCHMARK)
set_property(TARGET EAStdC EATest PROPERTY CXX_STANDARD 11)
endif()

if( UNIX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fasm-blocks" )
endif()

if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
endif()

#-------------------------------------------------------------------------------------------
Expand Down
34 changes: 30 additions & 4 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ cmake_minimum_required(VERSION 3.1)
project(EASTLBenchmarks CXX)
include(CTest)

#-------------------------------------------------------------------------------------------
# Defines
#-------------------------------------------------------------------------------------------
add_definitions(-D_CHAR16T)

#-------------------------------------------------------------------------------------------
# Include directories
#-------------------------------------------------------------------------------------------
Expand All @@ -19,8 +24,25 @@ include_directories(../test/source)
# Compiler Flags
#-------------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
endif()

# Work around a crash bug that only occurs with MingW when compiled with optimizations enabled and a dynamic runtime.
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND MINGW)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -static")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -static")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -static")
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_BUILD_TYPE MATCHES "MinSizeRel" AND MINGW)
message(FATAL_ERROR "FIXME: MinSizeRel on MingW's Clang fails to link.")
endif()

#-------------------------------------------------------------------------------------------
Expand All @@ -33,19 +55,23 @@ set(SOURCES ${EASTLBENCHMARK_SOURCES})
# Defines
#-------------------------------------------------------------------------------------------
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-DEASTL_THREAD_SUPPORT_AVAILABLE=0)
add_definitions(-DEASTL_OPENSOURCE)
add_definitions(-DEASTL_OPENSOURCE=1)
add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS) # silence std::hash_map deprecation warnings

#-------------------------------------------------------------------------------------------
# Executable definition
#-------------------------------------------------------------------------------------------
add_executable(EASTLBenchmarks ${EASTLBENCHMARK_SOURCES})

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

set(EASTLBenchmark_Libraries
EASTL
EATest)
target_link_libraries(EASTLBenchmarks ${EASTLBenchmark_Libraries})
target_link_libraries(EASTLBenchmarks ${EASTLBenchmark_Libraries} Threads::Threads)

#-------------------------------------------------------------------------------------------
# Run Unit tests and verify the results.
Expand Down
4 changes: 3 additions & 1 deletion benchmark/source/BenchmarkHash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#define STD_HASH_SUPPORTED 0
#elif defined(EA_COMPILER_GNUC) && (EA_COMPILER_VERSION >= 4006) // To consider: Find a better way to identify the switchover from pre-C++11 hash containers to C++11 hash containers.
#define STD_HASH_SUPPORTED 0 // Need to use std::unordered_map, etc. instead of hash_map, etc.
#elif defined(EA_COMPILER_CLANG) && (EA_COMPILER_CPP11_ENABLED) // Bad way to determine if we have C++11 hash containers
#define STD_HASH_SUPPORTED 0
#else
#define STD_HASH_SUPPORTED 1
#endif
Expand All @@ -34,7 +36,7 @@
#pragma warning(disable: 4350) // behavior change: X called instead of Y
#endif
#if STD_HASH_SUPPORTED
#if defined(__GNUC__) && (defined(_CXXCONFIG) || defined(EA_PLATFORM_UNIX))
#if (defined(EA_COMPILER_GNUC) || defined(EA_COMPILER_CLANG)) && (defined(_CXXCONFIG) || defined(EA_PLATFORM_UNIX) || defined(EA_PLATFORM_MINGW))
#include <ext/hash_map>
#else
#include <hash_map>
Expand Down
2 changes: 1 addition & 1 deletion benchmark/source/BenchmarkString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void BenchmarkString()

const char16_t pFind1_16[kFind1Size] = { 'p', 'a', 't', 't', 'e', 'r', 'n' };

#if !defined(EA_PLATFORM_IPHONE) // Crashes on iPhone.
#if !defined(EA_PLATFORM_IPHONE) && (!defined(EA_COMPILER_CLANG) && defined(EA_PLATFORM_MINGW)) // Crashes on iPhone.
ss16.insert(ss8.size() / 2, pFind1_16);
#endif
es16.insert(es8.size() / 2, pFind1_16);
Expand Down
2 changes: 1 addition & 1 deletion benchmark/source/EASTLBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Benchmark
return valueDest;
}

static void WriteTime(int64_t timeNS, eastl::string& sTime)
void WriteTime(int64_t timeNS, eastl::string& sTime)
{
if(timeNS > 1000000000)
sTime.sprintf(" %6.2f s", (double)timeNS / 1000000000);
Expand Down
1 change: 1 addition & 0 deletions benchmark/source/EASTLBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace Benchmark
void DoNothing(...);
void AddResult(const char* pName, int units, int64_t nTime1, int64_t nTime2, const char* pNotes = NULL);
void PrintResults();
void WriteTime(int64_t timeNS, eastl::string& sTime);


} // namespace Benchmark
Expand Down
6 changes: 5 additions & 1 deletion benchmark/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ int EAMain(int argc, char* argv[])
#endif

Benchmark::PrintResults();
EASTLTest_Printf("Time to complete all tests: %.1f seconds.\n", stopwatch.GetElapsedTimeFloat());

eastl::string sClockTime;
Benchmark::WriteTime(stopwatch.GetElapsedTime(), sClockTime);

EASTLTest_Printf("Time to complete all tests: %s.\n", sClockTime.c_str());

// Done
if(bWaitAtEnd)
Expand Down
12 changes: 6 additions & 6 deletions include/EASTL/bitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ EA_RESTORE_GCC_WARNING()
: base_type(value)
{
if((N & kBitsPerWordMask) || (N == 0)) // If there are any high bits to clear... (If we didn't have this check, then the code below would do the wrong thing when N == 32.
mWord[kWordCount - 1] &= ~(~static_cast<word_type>(0) << (N & kBitsPerWordMask)); // This clears any high unused bits.
mWord[kWordCount - 1] &= ~(static_cast<word_type>(~static_cast<word_type>(0)) << (N & kBitsPerWordMask)); // This clears any high unused bits.
}
EA_RESTORE_VC_WARNING()

Expand Down Expand Up @@ -1856,7 +1856,7 @@ EA_RESTORE_GCC_WARNING()
EA_DISABLE_VC_WARNING(6313)
base_type::operator<<=(n);
if((N & kBitsPerWordMask) || (N == 0)) // If there are any high bits to clear... (If we didn't have this check, then the code below would do the wrong thing when N == 32.
mWord[kWordCount - 1] &= ~(~static_cast<word_type>(0) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
mWord[kWordCount - 1] &= ~(static_cast<word_type>(~static_cast<word_type>(0)) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
EA_RESTORE_VC_WARNING()
}
else
Expand All @@ -1883,7 +1883,7 @@ EA_RESTORE_GCC_WARNING()
{
base_type::set(); // This sets all bits.
if((N & kBitsPerWordMask) || (N == 0)) // If there are any high bits to clear... (If we didn't have this check, then the code below would do the wrong thing when N == 32.
mWord[kWordCount - 1] &= ~(~static_cast<word_type>(0) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
mWord[kWordCount - 1] &= ~(static_cast<word_type>(~static_cast<word_type>(0)) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
return *this;
}

Expand Down Expand Up @@ -1948,7 +1948,7 @@ EA_RESTORE_GCC_WARNING()
EA_DISABLE_VC_WARNING(6313)
base_type::flip();
if((N & kBitsPerWordMask) || (N == 0)) // If there are any high bits to clear... (If we didn't have this check, then the code below would do the wrong thing when N == 32.
mWord[kWordCount - 1] &= ~(~static_cast<word_type>(0) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
mWord[kWordCount - 1] &= ~(static_cast<word_type>(~static_cast<word_type>(0)) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
return *this;
EA_RESTORE_VC_WARNING()
}
Expand Down Expand Up @@ -2028,7 +2028,7 @@ EA_RESTORE_GCC_WARNING()
base_type::from_uint32(value);

if((N & kBitsPerWordMask) || (N == 0)) // If there are any high bits to clear... (If we didn't have this check, then the code below would do the wrong thing when N == 32.
mWord[kWordCount - 1] &= ~(~static_cast<word_type>(0) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
mWord[kWordCount - 1] &= ~(static_cast<word_type>(~static_cast<word_type>(0)) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
}


Expand All @@ -2038,7 +2038,7 @@ EA_RESTORE_GCC_WARNING()
base_type::from_uint64(value);

if((N & kBitsPerWordMask) || (N == 0)) // If there are any high bits to clear... (If we didn't have this check, then the code below would do the wrong thing when N == 32.
mWord[kWordCount - 1] &= ~(~static_cast<word_type>(0) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
mWord[kWordCount - 1] &= ~(static_cast<word_type>(~static_cast<word_type>(0)) << (N & kBitsPerWordMask)); // This clears any high unused bits. We need to do this so that shift operations proceed correctly.
}


Expand Down
10 changes: 7 additions & 3 deletions include/EASTL/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define WIN32_LEAN_AND_MEAN
#endif
EA_DISABLE_ALL_VC_WARNINGS()
#undef NOMINMAX
#define NOMINMAX
#include <Windows.h>
// #ifdef min
Expand All @@ -44,11 +45,14 @@
#pragma warning(pop)
#endif

#ifdef EA_PLATFORM_MICROSOFT
#if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_MINGW)
#include <thr/xtimec.h>
#elif defined(EA_PLATFORM_APPLE)
#include <mach/mach_time.h>
#elif defined(EA_PLATFORM_POSIX) // Posix means Linux, Unix, and Macintosh OSX, among others (including Linux-based mobile platforms).
#elif defined(EA_PLATFORM_POSIX) || defined(EA_PLATFORM_MINGW) // Posix means Linux, Unix, and Macintosh OSX, among others (including Linux-based mobile platforms).
#if defined(EA_PLATFORM_MINGW)
#include <pthread_time.h>
#endif
#if (defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC))
#include <time.h>
#include <errno.h>
Expand Down Expand Up @@ -534,7 +538,7 @@ namespace chrono

namespace Internal
{
#if defined EA_PLATFORM_MICROSOFT
#if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_MINGW)
#define EASTL_NS_PER_TICK _XTIME_NSECS_PER_TICK
#elif defined EA_PLATFORM_POSIX
#define EASTL_NS_PER_TICK _XTIME_NSECS_PER_TICK
Expand Down
9 changes: 1 addition & 8 deletions include/EASTL/internal/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1763,18 +1763,11 @@ typedef EASTL_SSIZE_T eastl_ssize_t; // Signed version of eastl_size_t. Concept
/// EASTL_OPENSOURCE
/// This is enabled when EASTL is building built in an "open source" mode. Which is a mode that eliminates code
/// dependencies on other technologies that have not been released publically.
/// EASTL_OPENSOURCE = 0, is the default.
/// EASTL_OPENSOURCE = 0, is the default.
/// EASTL_OPENSOURCE = 1, utilizes technologies that not publically available.
///
#ifndef EASTL_OPENSOURCE
#define EASTL_OPENSOURCE 0
#endif

#endif // Header include guard







28 changes: 4 additions & 24 deletions include/EASTL/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ namespace eastl
// shall name T&&; otherwise, type shall name T. [ Note: This rule reflects
// the semantics of reference collapsing (8.3.2). For example, when a type T
// names a type T1&, the type add_rvalue_reference<T>::type is not an
// rvalue reference. — end note ]
// rvalue reference. end note ]
//
// Rules (8.3.2 p6):
// void + && -> void
Expand Down Expand Up @@ -865,7 +865,9 @@ namespace eastl
//
///////////////////////////////////////////////////////////////////////

#if defined(EA_COMPILER_NO_VARIADIC_TEMPLATES) || defined(EA_COMPILER_MSVC) // VS2013 fails to compile the variadic code below due to what looks like a deficiency in their handling of integral variadic template parameters.
// VS2013 fails to compile the variadic code below due to what looks like a deficiency in their handling of integral variadic template parameters.
// Also mingw's clang and gcc fail to compile the code on windows.
#if defined(EA_COMPILER_NO_VARIADIC_TEMPLATES) || defined(EA_COMPILER_MSVC) || (defined(EA_PLATFORM_MINGW) && (defined(EA_COMPILER_CLANG) || defined(EA_COMPILER_GNUC)))
// We support only two parameters.

#define EASTL_TYPE_TRAIT_static_min_CONFORMANCE 0
Expand Down Expand Up @@ -894,7 +896,6 @@ namespace eastl
struct static_min<I0, I1, IN...>
{ static const size_t value = ((I0 <= I1) ? static_min<I0, IN...>::value : static_min<I1, IN...>::value); };


template <size_t I0, size_t ...IN>
struct static_max;

Expand All @@ -921,24 +922,3 @@ namespace eastl


#endif // Header include guard





















19 changes: 14 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ include_directories(source)
#-------------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)

if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-pointer-bool-conversion")
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
endif()

#-------------------------------------------------------------------------------------------
# Source files
#-------------------------------------------------------------------------------------------
file(GLOB EASTLTEST_SOURCES "source/*.cpp")
file(GLOB EASTLTEST_SOURCES "source/*.cpp" "source/*.inl" "source/*.h")
set(SOURCES ${EASTLTEST_SOURCES})

#-------------------------------------------------------------------------------------------
# Defines
#-------------------------------------------------------------------------------------------
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DEASTL_OPENSOURCE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-DEASTL_OPENSOURCE=1)
add_definitions(-D_CHAR16T)
add_definitions(-DEASTL_THREAD_SUPPORT_AVAILABLE=0)

Expand All @@ -42,10 +48,13 @@ add_definitions(-DEASTL_THREAD_SUPPORT_AVAILABLE=0)
#-------------------------------------------------------------------------------------------
add_executable(EASTLTest ${SOURCES})

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

set(EASTLTest_Libraries
EASTL
EATest)
target_link_libraries(EASTLTest ${EASTLTest_Libraries})
target_link_libraries(EASTLTest ${EASTLTest_Libraries} Threads::Threads)

#-------------------------------------------------------------------------------------------
# Run Unit tests and verify the results.
Expand Down
4 changes: 2 additions & 2 deletions test/packages/EABase/include/Common/EABase/eahave.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,10 @@
#endif

#if !defined(EA_HAVE_ISNAN) && !defined(EA_NO_HAVE_ISNAN)
#if defined(EA_PLATFORM_MICROSOFT)
#if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_COMPILER_CLANG)
#define EA_HAVE_ISNAN(x) _isnan(x) /* declared in <math.h> */
#define EA_HAVE_ISINF(x) !_finite(x)
#elif defined(EA_PLATFORM_APPLE)
#elif defined(EA_PLATFORM_APPLE) || (defined(EA_PLATFORM_MICROSOFT) && defined(EA_COMPILER_CLANG))
#define EA_HAVE_ISNAN(x) std::isnan(x) /* declared in <cmath> */
#define EA_HAVE_ISINF(x) std::isinf(x)
#elif defined(EA_PLATFORM_ANDROID)
Expand Down
5 changes: 0 additions & 5 deletions test/packages/EAMain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ project(EAMain CXX)
#-------------------------------------------------------------------------------------------
add_library(EAMain INTERFACE)

#-------------------------------------------------------------------------------------------
# Compiler Flags
#-------------------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)

#-------------------------------------------------------------------------------------------
# Source files
#-------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 124048e

Please sign in to comment.