diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 11cc725d..005fe8d8 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -1319,7 +1319,7 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { - etl::mem_copy(i_element + 1, end(), i_element); + etl::mem_move(i_element + 1, end(), i_element); p_buffer[--current_size] = 0; return i_element; @@ -1334,7 +1334,7 @@ namespace etl { iterator i_element_(to_iterator(i_element)); - etl::mem_copy(i_element + 1, end(), i_element_); + etl::mem_move(i_element + 1, end(), i_element_); p_buffer[--current_size] = 0; return i_element_; @@ -1395,7 +1395,7 @@ namespace etl count = size() - pos; } - etl::mem_copy(p_buffer + pos, count, dest); + etl::mem_move(p_buffer + pos, count, dest); return count; } @@ -2675,7 +2675,7 @@ namespace etl typename etl::enable_if::value && etl::is_pointer::value, TIterator2>::type copy_characters(TIterator1 from, size_t n, TIterator2 to) { - etl::mem_copy(from, n, to); + etl::mem_move(from, n, to); return to + n; } @@ -2755,7 +2755,7 @@ namespace etl pointer dst = position; size_t length = get_string_length(src); size_t count = (length < size_t(free_space)) ? length : size_t(free_space); - etl::mem_copy(src, count, dst); + etl::mem_move(src, count, dst); truncated |= (src[count] != 0); current_size = size_t(start) + count; diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 34723248..e7d6e5dd 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -2423,8 +2423,7 @@ typedef integral_constant true_type; template struct underlying_type { - ETL_STATIC_ASSERT(false, "No user defined specialisation of etl::underlying_type for this type"); - typedef char type; + typedef int type; }; #endif diff --git a/include/etl/memory.h b/include/etl/memory.h index fea4904e..93f3c0ec 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -2290,9 +2290,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value, "Cannot mem_copy a non trivially copyable type"); - memcpy(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); + ::memcpy(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(T) * static_cast(se - sb)); return db; } @@ -2309,9 +2309,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value, "Cannot mem_copy a non trivially copyable type"); - memcpy(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * n); + ::memcpy(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(T) * n); return db; } @@ -2328,9 +2328,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value, "Cannot mem_move a non trivially copyable type"); - memmove(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(T) * static_cast(se - sb)); + ::memmove(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(T) * static_cast(se - sb)); return db; } @@ -2347,9 +2347,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value, "Cannot mem_move a non trivially copyable type"); - memmove(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(typename etl::iterator_traits::value_type) * n); + ::memmove(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(T) * n); return db; } @@ -2369,9 +2369,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value, "Cannot mem_compare a non trivially copyable type"); - return memcmp(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(T) * static_cast(se - sb)); + return ::memcmp(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(T) * static_cast(se - sb)); } //*************************************************************************** @@ -2389,16 +2389,16 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value, "Cannot mem_compare a non trivially copyable type"); - return memcmp(reinterpret_cast(db), - reinterpret_cast(sb), - sizeof(T) * n); + return ::memcmp(reinterpret_cast(db), + reinterpret_cast(sb), + sizeof(T) * n); } //*************************************************************************** /// Template wrapper for memset. /// \param db Destination begin. /// \param de Destination end. - /// \param value The value to set each byte of the memory region. + /// \param value The value to set each char of the memory region. /// \return The destination //*************************************************************************** template @@ -2410,9 +2410,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value_type>::value, "Cannot mem_set a non trivially copyable type"); - memset(reinterpret_cast(db), - static_cast(value), - sizeof(typename etl::iterator_traits::value_type) * static_cast(de - db)); + ::memset(reinterpret_cast(db), + static_cast(value), + sizeof(typename etl::iterator_traits::value_type) * static_cast(de - db)); return db; } @@ -2421,7 +2421,7 @@ namespace etl /// Template wrapper for memset. /// \param db Destination begin. /// \param n Destination length. - /// \param value The value to set each byte of the memory region. + /// \param value The value to set each char of the memory region. /// \return The destination //*************************************************************************** template @@ -2433,9 +2433,9 @@ namespace etl { ETL_STATIC_ASSERT(etl::is_trivially_copyable::value_type>::value, "Cannot mem_set a non trivially copyable type"); - memset(reinterpret_cast(db), - static_cast(value), - sizeof(typename etl::iterator_traits::value_type) * n); + ::memset(reinterpret_cast(db), + static_cast(value), + sizeof(typename etl::iterator_traits::value_type) * n); return db; } @@ -2455,9 +2455,9 @@ namespace etl sizeof(T) == 1, char*>::type mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT { - void* result = memchr(reinterpret_cast(sb), - static_cast(value), - sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); + void* result = ::memchr(reinterpret_cast(sb), + static_cast(value), + sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); return (result == 0U) ? reinterpret_cast(se) : reinterpret_cast(result); } @@ -2477,9 +2477,9 @@ namespace etl sizeof(T) == 1, const char*>::type mem_char(TPointer sb, TPointer se, T value) ETL_NOEXCEPT { - const void* result = memchr(reinterpret_cast(sb), - static_cast(value), - sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); + const void* result = ::memchr(reinterpret_cast(sb), + static_cast(value), + sizeof(typename etl::iterator_traits::value_type) * static_cast(se - sb)); return (result == 0U) ? reinterpret_cast(se) : reinterpret_cast(result); } @@ -2499,9 +2499,9 @@ namespace etl sizeof(T) == 1, char*>::type mem_char(TPointer sb, size_t n, T value) ETL_NOEXCEPT { - void* result = memchr(reinterpret_cast(sb), - static_cast(value), - sizeof(typename etl::iterator_traits::value_type) * n); + void* result = ::memchr(reinterpret_cast(sb), + static_cast(value), + sizeof(typename etl::iterator_traits::value_type) * n); return (result == 0U) ? reinterpret_cast(sb + n) : reinterpret_cast(result); } @@ -2521,9 +2521,9 @@ namespace etl sizeof(T) == 1, const char*>::type mem_char(TPointer sb, size_t n, T value) ETL_NOEXCEPT { - const void* result = memchr(reinterpret_cast(sb), - static_cast(value), - sizeof(typename etl::iterator_traits::value_type) * n); + const void* result = ::memchr(reinterpret_cast(sb), + static_cast(value), + sizeof(typename etl::iterator_traits::value_type) * n); return (result == 0U) ? reinterpret_cast(sb + n) : reinterpret_cast(result); } diff --git a/include/etl/platform.h b/include/etl/platform.h index b51bc33b..f8ecb237 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -579,7 +579,7 @@ namespace etl static ETL_CONSTANT bool using_generic_compiler = (ETL_USING_GENERIC_COMPILER == 1); static ETL_CONSTANT bool using_legacy_bitset = (ETL_USING_LEGACY_BITSET == 1); static ETL_CONSTANT bool using_exceptions = (ETL_USING_EXCEPTIONS == 1); - static ETL_CONSTANT bool using_wide_characters = (ETL_USING_WIDE_CHARACTERS == 1); + static ETL_CONSTANT bool using_libc_wchar_h = (ETL_USING_LIBC_WCHAR_H == 1); // Has... static ETL_CONSTANT bool has_initializer_list = (ETL_HAS_INITIALIZER_LIST == 1); diff --git a/include/etl/private/pvoidvector.h b/include/etl/private/pvoidvector.h index 641b1868..728fceb0 100644 --- a/include/etl/private/pvoidvector.h +++ b/include/etl/private/pvoidvector.h @@ -367,7 +367,7 @@ namespace etl void** p_first = (void**)(first); void** p_last = (void**)(last); - p_end = etl::mem_copy(p_first, p_last, p_buffer) + (p_last - p_first); + p_end = etl::mem_move(p_first, p_last, p_buffer) + (p_last - p_first); } //********************************************************************* @@ -593,7 +593,7 @@ namespace etl ETL_ASSERT_OR_RETURN((size() + count) <= CAPACITY, ETL_ERROR(vector_full)); etl::mem_move(position_, p_end, position_ + count); - etl::mem_copy((void**)first, (void**)last, position_); + etl::mem_move((void**)first, (void**)last, position_); p_end += count; } @@ -604,7 +604,7 @@ namespace etl //********************************************************************* iterator erase(iterator i_element) { - etl::mem_copy(i_element + 1, end(), i_element); + etl::mem_move(i_element + 1, end(), i_element); --p_end; return i_element; @@ -619,7 +619,7 @@ namespace etl { iterator i_element_ = to_iterator(i_element); - etl::mem_copy(i_element_ + 1, end(), i_element_); + etl::mem_move(i_element_ + 1, end(), i_element_); --p_end; return i_element_; @@ -638,7 +638,7 @@ namespace etl iterator first_ = to_iterator(first); iterator last_ = to_iterator(last); - etl::mem_copy(last_, end(), first_); + etl::mem_move(last_, end(), first_); size_t n_delete = static_cast(etl::distance(first, last)); // Just adjust the count. diff --git a/include/etl/string_view.h b/include/etl/string_view.h index ee06257d..62f42772 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -366,7 +366,7 @@ namespace etl { n = etl::min(count, size() - position); - etl::mem_copy(mbegin + position, n, destination); + etl::mem_move(mbegin + position, n, destination); } return n; diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index efa9b1cf..db22a215 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -2412,12 +2412,11 @@ typedef integral_constant true_type; }; #else /// Primary template for etl::underlying_type - /// Users must spelialise this template for their enumerations. + /// Users must specialise this template for their enumerations. template struct underlying_type { - ETL_STATIC_ASSERT(false, "No user defined specialisation of etl::underlying_type for this type"); - typedef char type; + typedef int type; }; #endif diff --git a/test/test_etl_traits.cpp b/test/test_etl_traits.cpp index 6adf725d..fa1c700d 100644 --- a/test/test_etl_traits.cpp +++ b/test/test_etl_traits.cpp @@ -50,7 +50,7 @@ namespace CHECK_EQUAL((ETL_USING_CPP20 == 1), etl::traits::using_cpp20); CHECK_EQUAL((ETL_USING_CPP23 == 1), etl::traits::using_cpp23); CHECK_EQUAL((ETL_USING_EXCEPTIONS == 1), etl::traits::using_exceptions); - CHECK_EQUAL((ETL_USING_WIDE_CHARACTERS == 1), etl::traits::using_wide_characters); + CHECK_EQUAL((ETL_USING_LIBC_WCHAR_H == 1), etl::traits::using_libc_wchar_h); CHECK_EQUAL((ETL_USING_GCC_COMPILER == 1), etl::traits::using_gcc_compiler); CHECK_EQUAL((ETL_USING_MICROSOFT_COMPILER == 1), etl::traits::using_microsoft_compiler); CHECK_EQUAL((ETL_USING_ARM5_COMPILER == 1), etl::traits::using_arm5_compiler);