Updated for automatic detection of <new> or <new.h>

This commit is contained in:
John Wellbelove 2020-12-06 14:13:37 +00:00
parent cc418dd08f
commit e122383d7d
37 changed files with 106 additions and 84 deletions

View File

@ -31,8 +31,6 @@ SOFTWARE.
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "nullptr.h"
@ -41,6 +39,7 @@ SOFTWARE.
#include "timer.h"
#include "atomic.h"
#include "error_handler.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED
#include "delegate.h"

View File

@ -34,15 +34,10 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "utility.h"
#include "container.h"
#include "memory.h"
#include "exception.h"
@ -51,6 +46,7 @@ SOFTWARE.
#include "algorithm.h"
#include "type_traits.h"
#include "iterator.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -31,11 +31,10 @@ SOFTWARE.
#ifndef ETL_FLAT_MAP_INCLUDED
#define ETL_FLAT_MAP_INCLUDED
#include "private/new.h"
#include "platform.h"
#include "reference_flat_map.h"
#include "pool.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -31,12 +31,11 @@ SOFTWARE.
#ifndef ETL_FLAT_MULTMAP_INCLUDED
#define ETL_FLAT_MULTMAP_INCLUDED
#include "private/new.h"
#include "platform.h"
#include "reference_flat_multimap.h"
#include "pool.h"
#include "utility.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -34,6 +34,7 @@ SOFTWARE.
#include "platform.h"
#include "reference_flat_multiset.h"
#include "pool.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -31,11 +31,10 @@ SOFTWARE.
#ifndef ETL_FLAT_SET_INCLUDED
#define ETL_FLAT_SET_INCLUDED
#include "private/new.h"
#include "platform.h"
#include "reference_flat_set.h"
#include "pool.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,15 +33,11 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "utility.h"
#include "pool.h"
#include "container.h"
#include "exception.h"
@ -52,6 +48,7 @@ SOFTWARE.
#include "memory.h"
#include "iterator.h"
#include "static_assert.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -64,7 +64,6 @@ cog.outl("//********************************************************************
#define ETL_MESSAGE_ROUTER_INCLUDED
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "message.h"
@ -75,6 +74,7 @@ cog.outl("//********************************************************************
#include "exception.h"
#include "largest.h"
#include "nullptr.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "35"

View File

@ -33,14 +33,10 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "container.h"
#include "pool.h"
#include "exception.h"
@ -52,6 +48,7 @@ SOFTWARE.
#include "memory.h"
#include "iterator.h"
#include "static_assert.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,14 +33,10 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "container.h"
#include "pool.h"
#include "exception.h"
@ -51,6 +47,7 @@ SOFTWARE.
#include "parameter_type.h"
#include "iterator.h"
#include "utility.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -38,7 +38,7 @@ SOFTWARE.
#include "utility.h"
#include "nullptr.h"
#include "alignment.h"
#include "private/new.h"
#include "placement_new.h"
#include <assert.h>
#include <string.h>

View File

@ -52,7 +52,6 @@ SOFTWARE.
#define ETL_MESSAGE_ROUTER_INCLUDED
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "message.h"
@ -63,6 +62,7 @@ SOFTWARE.
#include "exception.h"
#include "largest.h"
#include "nullptr.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "35"

View File

@ -33,14 +33,10 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "container.h"
#include "pool.h"
#include "exception.h"
@ -51,6 +47,7 @@ SOFTWARE.
#include "parameter_type.h"
#include "iterator.h"
#include "utility.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,14 +33,10 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "parameter_type.h"
#include "container.h"
#include "pool.h"
@ -50,6 +46,7 @@ SOFTWARE.
#include "nullptr.h"
#include "type_traits.h"
#include "utility.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -31,15 +31,13 @@ SOFTWARE.
#ifndef ETL_OPTIONAL_INCLUDED
#define ETL_OPTIONAL_INCLUDED
#include "private/new.h"
#include "platform.h"
#include "alignment.h"
#include "type_traits.h"
#include "exception.h"
#include "error_handler.h"
#include "utility.h"
#include "placement_new.h"
namespace etl
{

View File

@ -31,12 +31,11 @@ SOFTWARE.
#ifndef ETL_PACKET_INCLUDED
#define ETL_PACKET_INCLUDED
#include "private/new.h"
#include "platform.h"
#include "static_assert.h"
#include "alignment.h"
#include "utility.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "38"

View File

@ -0,0 +1,48 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2019 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_NEW_INCLUDED
#define ETL_NEW_INCLUDED
///\ingroup private
#include "platform.h"
#if ETL_USING_STD_NEW
#include <new>
#else
// Define placement new if no new header is available
inline void* operator new(size_t, void* p) { return p; }
inline void* operator new[](size_t, void* p) { return p; }
inline void operator delete(void*, void*) ETL_NOEXCEPT {}
inline void operator delete[](void*, void*) ETL_NOEXCEPT {}
#endif
#endif

View File

@ -102,6 +102,19 @@ SOFTWARE.
// See if we can determine the OS we're compiling on, if haven't already done so in etl_profile.h
#include "profiles/determine_development_os.h"
#include <new.h>
// Figure out if we can use the standard library <new> header, if haven't already done so in etl_profile.h
#if !defined(ETL_USING_STD_NEW)
#if defined(__has_include)
#define ETL_USING_STD_NEW (__has_include(<new>) || __has_include(<new.h>))
#elif ETL_NOT_USING_STL || (defined(ARDUINO) && defined(__AVR__))
#define ETL_USING_STD_NEW 0
#else
#define ETL_USING_STD_NEW 1
#endif
#endif
// Option to force string construction from a character pointer to be explicit.
#if defined(ETL_FORCE_EXPLICIT_STRING_CONVERSION_FROM_CHAR)
#define ETL_EXPLICIT_STRING_FROM_CHAR explicit

View File

@ -32,9 +32,6 @@ SOFTWARE.
#define ETL_POOL_INCLUDED
#include "platform.h"
#include "private/new.h"
#include "algorithm.h"
#include "iterator.h"
#include "utility.h"
@ -47,6 +44,7 @@ SOFTWARE.
#include "alignment.h"
#include "static_assert.h"
#include "algorithm.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "11"

View File

@ -34,8 +34,6 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "container.h"
#include "alignment.h"
@ -48,6 +46,7 @@ SOFTWARE.
#include "memory_model.h"
#include "integral_limits.h"
#include "utility.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "13"

View File

@ -34,8 +34,6 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "mutex.h"
@ -46,6 +44,7 @@ SOFTWARE.
#include "memory_model.h"
#include "integral_limits.h"
#include "utility.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "48"

View File

@ -34,8 +34,6 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "alignment.h"
#include "parameter_type.h"
@ -43,6 +41,7 @@ SOFTWARE.
#include "memory_model.h"
#include "integral_limits.h"
#include "utility.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "47"

View File

@ -34,14 +34,13 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "alignment.h"
#include "parameter_type.h"
#include "memory_model.h"
#include "integral_limits.h"
#include "utility.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "46"

View File

@ -34,8 +34,6 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "alignment.h"
#include "parameter_type.h"
@ -43,6 +41,7 @@ SOFTWARE.
#include "integral_limits.h"
#include "function.h"
#include "utility.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "54"

View File

@ -33,8 +33,6 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "container.h"
#include "pool.h"
@ -46,10 +44,10 @@ SOFTWARE.
#include "parameter_type.h"
#include "iterator.h"
#include "utility.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -34,8 +34,6 @@ SOFTWARE.
#include <stddef.h>
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "utility.h"
@ -46,6 +44,7 @@ SOFTWARE.
#include "error_handler.h"
#include "debug_count.h"
#include "type_traits.h"
#include "placement_new.h"
#undef ETL_FILE
#define ETL_FILE "15"

View File

@ -33,8 +33,6 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
@ -53,6 +51,7 @@ SOFTWARE.
#include "exception.h"
#include "debug_count.h"
#include "iterator.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,8 +33,6 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
@ -53,6 +51,7 @@ SOFTWARE.
#include "exception.h"
#include "debug_count.h"
#include "iterator.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,15 +33,11 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
#include "functional.h"
#include "utility.h"
#include "container.h"
#include "pool.h"
#include "vector.h"
@ -54,6 +50,7 @@ SOFTWARE.
#include "exception.h"
#include "debug_count.h"
#include "iterator.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,8 +33,6 @@ SOFTWARE.
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "iterator.h"
@ -53,6 +51,7 @@ SOFTWARE.
#include "error_handler.h"
#include "debug_count.h"
#include "iterator.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -33,8 +33,6 @@ SOFTWARE.
#include <stdint.h>
#include "private/new.h"
#include "platform.h"
#include "utility.h"
#include "array.h"
@ -46,6 +44,7 @@ SOFTWARE.
#include "alignment.h"
#include "error_handler.h"
#include "null_type.h"
#include "placement_new.h"
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 940

View File

@ -37,8 +37,6 @@ SOFTWARE.
#include <stdint.h>
#include <stddef.h>
#include "private/new.h"
#include "platform.h"
#include "algorithm.h"
#include "type_traits.h"
@ -53,6 +51,7 @@ SOFTWARE.
#include "iterator.h"
#include "functional.h"
#include "static_assert.h"
#include "placement_new.h"
#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL
#include <initializer_list>

View File

@ -5,23 +5,23 @@ echo "********** GCC **********" >> etl_test_log.txt
gcc --version | grep gcc >> etl_test_log.txt
cmake --cmake-clean-cache -DNO_STL=OFF ..
make
./etl_tests >> etl_test_log.txt
./etl_tests | tee etl_test_log.txt
echo "********** GCC - No STL **********" >> etl_test_log.txt
gcc --version | grep gcc >> etl_test_log.txt
cmake --cmake-clean-cache -DNO_STL=ON ..
make
./etl_tests >> etl_test_log.txt
./etl_tests | tee etl_test_log.txt
echo "********** Clang **********" >> etl_test_log.txt
clang --version | grep clang >> etl_test_log.txt
export CC=clang
export CXX=clang++
cmake --cmake-clean-cache -DNO_STL=OFF ..
make
./etl_tests >> etl_test_log.txt
./etl_tests | tee etl_test_log.txt
echo "********** Clang - No STL **********" >> etl_test_log.txt
clang --version | grep clang >> etl_test_log.txt
export CC=clang
export CXX=clang++
cmake --cmake-clean-cache -DNO_STL=ON ..
make
./etl_tests >> etl_test_log.txt
./etl_tests | tee etl_test_log.txt

View File

@ -1293,6 +1293,7 @@
<ClInclude Include="..\..\include\etl\multi_array.h" />
<ClInclude Include="..\..\include\etl\mutex\mutex_freertos.h" />
<ClInclude Include="..\..\include\etl\negative.h" />
<ClInclude Include="..\..\include\etl\placement_new.h" />
<ClInclude Include="..\..\include\etl\null_type.h" />
<ClInclude Include="..\..\include\etl\parameter_pack.h" />
<ClInclude Include="..\..\include\etl\private\choose_namespace.h" />

View File

@ -894,6 +894,9 @@
<ClInclude Include="..\..\include\etl\buffer_descriptors.h">
<Filter>ETL\Containers</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\placement_new.h">
<Filter>ETL\Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\main.cpp">

View File

@ -30,19 +30,18 @@ SOFTWARE.
#ifndef ETL_NEW_INCLUDED
#define ETL_NEW_INCLUDED
///\ingroup private
#include "../platform.h"
#include "platform.h"
#ifdef ETL_NO_NEW_HEADER_AVAILABLE
// Define placement new if no new header is available
inline void* operator new(size_t, void* const __p){ return __p; }
inline void* operator new[](size_t, void* const __p){ return __p; }
inline void* operator new(size_t, void* const __p) { return __p; }
inline void* operator new[](size_t, void* const __p) { return __p; }
inline void operator delete(void*, void* const){ }
inline void operator delete[](void*, void* const){ }
inline void operator delete(void*, void* const) { }
inline void operator delete[](void*, void* const) {}
#else
#include <new>
#include <new>
#endif
#endif

1
wslcopy.sh Normal file
View File

@ -0,0 +1 @@
rsync -av --progress . /home/ubuntu/ --exclude etl/examples --exclude test/vs2019 --exclude test/vs2017 --exclude test/codeblocks