Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	include/etl/version.h
#	support/Release notes.txt
  • Loading branch information
jwellbelove committed Mar 30, 2018
1 parent 3d52e68 commit 2841afc
Show file tree
Hide file tree
Showing 17 changed files with 376 additions and 40 deletions.
16 changes: 8 additions & 8 deletions include/etl/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ namespace etl
{
if (i == std::find(begin1, i, *i))
{
int32_t n = std::count(begin2, end2, *i);
size_t n = std::count(begin2, end2, *i);

if (n == 0 || std::count(i, end1, *i) != n)
if (n == 0 || size_t(std::count(i, end1, *i)) != n)
{
return false;
}
Expand Down Expand Up @@ -583,9 +583,9 @@ namespace etl
{
if (i == std::find(begin1, i, *i))
{
int32_t n = std::count(begin2, end2, *i);
size_t n = std::count(begin2, end2, *i);

if (n == 0 || std::count(i, end1, *i) != n)
if (n == 0 || size_t(std::count(i, end1, *i)) != n)
{
return false;
}
Expand Down Expand Up @@ -619,9 +619,9 @@ namespace etl
{
if (i == std::find_if(begin1, i, std::bind1st(predicate, *i)))
{
int32_t n = std::count(begin2, end2, *i);
size_t n = std::count(begin2, end2, *i);

if (n == 0 || std::count(i, end1, *i) != n)
if (n == 0 || size_t(std::count(i, end1, *i)) != n)
{
return false;
}
Expand Down Expand Up @@ -652,9 +652,9 @@ namespace etl
{
if (i == std::find_if(begin1, i, std::bind1st(predicate, *i)))
{
int32_t n = std::count(begin2, end2, *i);
size_t n = std::count(begin2, end2, *i);

if (n == 0 || std::count(i, end1, *i) != n)
if (n == 0 || size_t(std::count(i, end1, *i)) != n)
{
return false;
}
Expand Down
12 changes: 12 additions & 0 deletions include/etl/debug_count.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ namespace etl
return *this;
}

inline debug_count& operator +=(size_t n)
{
count += int32_t(n);
return *this;
}

inline debug_count& operator -=(size_t n)
{
count -= int32_t(n);
return *this;
}

inline operator int32_t()
{
return count;
Expand Down
18 changes: 9 additions & 9 deletions include/etl/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace etl
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count)
{
count += std::distance(o_begin, o_end);
count += int32_t(std::distance(o_begin, o_end));

std::fill(o_begin, o_end, value);

Expand All @@ -108,7 +108,7 @@ namespace etl
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, TOutputIterator>::type
uninitialized_fill(TOutputIterator o_begin, TOutputIterator o_end, const T& value, TCounter& count)
{
count += std::distance(o_begin, o_end);
count += int32_t(std::distance(o_begin, o_end));

etl::uninitialized_fill(o_begin, o_end, value);

Expand Down Expand Up @@ -181,7 +181,7 @@ namespace etl
uninitialized_copy(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TCounter& count)
{
TOutputIterator o_end = std::copy(i_begin, i_end, o_begin);
count += std::distance(o_begin, o_end);
count += int32_t(std::distance(o_begin, o_end));

return o_end;
}
Expand All @@ -197,7 +197,7 @@ namespace etl
{
TOutputIterator o_end = etl::uninitialized_copy(i_begin, i_end, o_begin);

count += std::distance(o_begin, o_end);
count += int32_t(std::distance(o_begin, o_end));

return o_end;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ namespace etl
typename etl::enable_if<etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count)
{
count = std::distance(o_begin, o_end);
count = int32_t(std::distance(o_begin, o_end));
}

//*****************************************************************************
Expand All @@ -317,7 +317,7 @@ namespace etl
typename etl::enable_if<!etl::is_trivially_constructible<typename std::iterator_traits<TOutputIterator>::value_type>::value, void>::type
uninitialized_default_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count)
{
count += std::distance(o_begin, o_end);
count += int32_t(std::distance(o_begin, o_end));

etl::uninitialized_default_construct(o_begin, o_end);
}
Expand Down Expand Up @@ -533,7 +533,7 @@ namespace etl
template <typename TOutputIterator, typename TCounter>
void uninitialized_value_construct(TOutputIterator o_begin, TOutputIterator o_end, TCounter& count)
{
count += std::distance(o_begin, o_end);
count += int32_t(std::distance(o_begin, o_end));

etl::uninitialized_value_construct(o_begin, o_end);
}
Expand Down Expand Up @@ -649,7 +649,7 @@ namespace etl
typename etl::enable_if<etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, void>::type
destroy(TIterator i_begin, TIterator i_end, TCounter& count)
{
count -= std::distance(i_begin, i_end);
count -= int32_t(std::distance(i_begin, i_end));
}

//*****************************************************************************
Expand All @@ -661,7 +661,7 @@ namespace etl
typename etl::enable_if<!etl::is_trivially_destructible<typename std::iterator_traits<TIterator>::value_type>::value, void>::type
destroy(TIterator i_begin, TIterator i_end, TCounter& count)
{
count -= std::distance(i_begin, i_end);
count -= int32_t(std::distance(i_begin, i_end));

while (i_begin != i_end)
{
Expand Down
14 changes: 14 additions & 0 deletions include/etl/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/

#include <stdint.h>

#ifndef __ETL_PLATFORM__
#define __ETL_PLATFORM__

// Some targets do not support 8bit types.
#define ETL_8BIT_SUPPORT (CHAR_BIT == 8)

// Define a debug macro
#if defined(_DEBUG) || defined(DEBUG)
#define ETL_DEBUG
#endif

// Undefine all of the macros.
#undef ETL_PLATFORM_16BIT
#undef ETL_PLATFORM_32BIT
#undef ETL_PLATFORM_64BIT
#undef ETL_CPP11_SUPPORTED
#undef ETL_CPP14_SUPPORTED
#undef ETL_CPP17_SUPPORTED
Expand All @@ -46,8 +53,15 @@ SOFTWARE.
#undef ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED
#undef ETL_ATOMIC_SUPPORTED

// Determine the bit width of the platform.
#define ETL_PLATFORM_16BIT (UINT16_MAX == UINTPTR_MAX)
#define ETL_PLATFORM_32BIT (UINT32_MAX == UINTPTR_MAX)
#define ETL_PLATFORM_64BIT (UINT64_MAX == UINTPTR_MAX)

#include "etl_profile.h"

// The macros below are dependent on the profile.

#if defined(ETL_COMPILER_MICROSOFT)
// Disable warning of deprecated std::iterator.
#pragma warning(disable : 4996)
Expand Down
4 changes: 2 additions & 2 deletions include/etl/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ SOFTWARE.
/// Definitions of the ETL version
///\ingroup utilities

#define ETL_VERSION "11.00.0"
#define ETL_VERSION "11.3.0"
#define ETL_VERSION_MAJOR 11
#define ETL_VERSION_MINOR 0
#define ETL_VERSION_MINOR 3
#define ETL_VERSION_PATCH 0

#endif
Expand Down
6 changes: 5 additions & 1 deletion support/Release notes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
===============================================================================
11.1.0
11.3.0
Improved compatibility with 64 bit pltforms.

===============================================================================
11.2.0
Added std::initializer_list constructors to containers, if ETL_CPP11_SUPPORTED is set to 1

===============================================================================
Expand Down
21 changes: 21 additions & 0 deletions test/codeblocks/ETL.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@
<Mode after="always" />
</ExtraCommands>
</Target>
<Target title="Windows 64">
<Option output="bin/Debug/ETL" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-std=c++11" />
<Add option="-m64" />
<Add option="-g" />
<Add option="-D_DEBUG" />
<Add directory="../../src" />
</Compiler>
<Linker>
<Add option="-m64" />
</Linker>
<ExtraCommands>
<Add after="${TARGET_OUTPUT_DIR}${TARGET_OUTPUT_BASENAME}" />
</ExtraCommands>
</Target>
</Build>
<Compiler>
<Add option="-Wunused-parameter" />
Expand Down Expand Up @@ -278,9 +297,11 @@
<Unit filename="../../unittest-cpp/UnitTest++/UnitTestPP.h" />
<Unit filename="../../unittest-cpp/UnitTest++/Win32/TimeHelpers.cpp">
<Option target="Windows" />
<Option target="Windows 64" />
</Unit>
<Unit filename="../../unittest-cpp/UnitTest++/Win32/TimeHelpers.h">
<Option target="Windows" />
<Option target="Windows 64" />
</Unit>
<Unit filename="../../unittest-cpp/UnitTest++/XmlTestReporter.cpp" />
<Unit filename="../../unittest-cpp/UnitTest++/XmlTestReporter.h" />
Expand Down
6 changes: 5 additions & 1 deletion test/test_array_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,11 @@ namespace
{
Data5 aw5;
size_t hash = etl::hash<Data5>()(aw5);
size_t compare_hash = etl::fnv_1a_32(reinterpret_cast<const uint8_t*>(&data5[0]), reinterpret_cast<const uint8_t*>(&data5[5]));


size_t compare_hash = etl::__private_hash__::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&data5[0]), reinterpret_cast<const uint8_t*>(&data5[5]));


CHECK_EQUAL(compare_hash, hash);
}
};
Expand Down
45 changes: 34 additions & 11 deletions test/test_hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,40 +126,63 @@ namespace
{
size_t hash = etl::hash<long long>()((long long)(0x5AA555AA3CC333CC));

if (sizeof(size_t) == sizeof(long long))
CHECK_EQUAL(0x5AA555AA3CC333CCU, hash);
else
if (ETL_PLATFORM_32BIT)
{
CHECK_EQUAL(0xEC6A8D69U, hash);
}

if (ETL_PLATFORM_64BIT)
{
CHECK_EQUAL(0x5AA555AA3CC333CCU, hash);
}
}

//*************************************************************************
TEST(test_hash_unsigned_long_long)
{
size_t hash = etl::hash<unsigned long long>()((unsigned long long)(0x5AA555AA3CC333CC));

if (sizeof(size_t) == sizeof(unsigned long long))
CHECK_EQUAL(0x5AA555AA3CC333CCU, hash);
else
if (ETL_PLATFORM_32BIT)
{
CHECK_EQUAL(0xEC6A8D69U, hash);
}

if (ETL_PLATFORM_64BIT)
{
CHECK_EQUAL(0x5AA555AA3CC333CCU, hash);
}
}

//*************************************************************************
TEST(test_hash_float)
{
size_t hash = etl::hash<float>()((float)(1.2345));

CHECK_EQUAL(0X3F9E0419U, hash);
if (ETL_PLATFORM_32BIT)
{
CHECK_EQUAL(0X3F9E0419U, hash);
}

if (ETL_PLATFORM_64BIT)
{
CHECK_EQUAL(9821047038287739023U, hash);
}
}

//*************************************************************************
TEST(test_hash_double)
{
size_t hash = etl::hash<double>()((double)(1.2345));

if (sizeof(size_t) == sizeof(double))
CHECK_EQUAL(0X3FF3C083126E978DU, hash);
else

if (ETL_PLATFORM_32BIT)
{
CHECK_EQUAL(0x86FBF224U, hash);
}

if (ETL_PLATFORM_64BIT)
{
CHECK_EQUAL(0x3FF3C083126E978DU, hash);
}
}

//*************************************************************************
Expand Down
8 changes: 7 additions & 1 deletion test/test_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,17 @@ namespace
//*************************************************************************
TEST(test_type_error)
{
struct Test
{
uint64_t a;
uint64_t b;
};

etl::pool<uint32_t, 4> pool;

etl::ipool& ip = pool;

CHECK_THROW(ip.allocate<double>(), etl::pool_element_size);
CHECK_THROW(ip.allocate<Test>(), etl::pool_element_size);
}

//*************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion test/test_string_char.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3032,7 +3032,7 @@ namespace
// Test with actual string type.
Text text(STR("ABCDEFHIJKL"));
size_t hash = etl::hash<Text>()(text);
size_t compare_hash = etl::fnv_1a_32(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
size_t compare_hash = etl::__private_hash__::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
CHECK_EQUAL(compare_hash, hash);

// Test with interface string type.
Expand Down
2 changes: 1 addition & 1 deletion test/test_string_u16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ namespace
// Test with actual string type.
Text text(STR("ABCDEFHIJKL"));
size_t hash = etl::hash<Text>()(text);
size_t compare_hash = etl::fnv_1a_32(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
size_t compare_hash = etl::__private_hash__::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
CHECK_EQUAL(compare_hash, hash);

// Test with interface string type.
Expand Down
2 changes: 1 addition & 1 deletion test/test_string_u32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ namespace
// Test with actual string type.
Text text(STR("ABCDEFHIJKL"));
size_t hash = etl::hash<Text>()(text);
size_t compare_hash = etl::fnv_1a_32(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
size_t compare_hash = etl::__private_hash__::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
CHECK_EQUAL(compare_hash, hash);

// Test with interface string type.
Expand Down
2 changes: 1 addition & 1 deletion test/test_string_wchar_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,7 +3031,7 @@ namespace
// Test with actual string type.
Text text(STR("ABCDEFHIJKL"));
size_t hash = etl::hash<Text>()(text);
size_t compare_hash = etl::fnv_1a_32(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
size_t compare_hash = etl::__private_hash__::generic_hash<size_t>(reinterpret_cast<const uint8_t*>(&text[0]), reinterpret_cast<const uint8_t*>(&text[text.size()]));
CHECK_EQUAL(compare_hash, hash);

// Test with interface string type.
Expand Down
Loading

0 comments on commit 2841afc

Please sign in to comment.