Skip to content

Commit

Permalink
add static assert with auto message (#740)
Browse files Browse the repository at this point in the history
* Resolve all C++ -O2 warnings

Resolve all C++ -O2 warnings

Resolve all C++ -O2 warnings

* Updated release notes and version

* Made unit test suite names unique

* Added etl::bit_v for C++17

* add stringify macro (#741)

* Add include/linux/stringify.h from Linux kernel 2.6.12-rc2

(cherry picked from commit torvalds/linux@1da177e)

* Make __stringify support variable argument macros too

For example:

  __stringify(__entry->irq, __entry->ret)

will now convert it to:

  "REC->irq, REC->ret"

It also still supports single arguments as the old macro did.

Signed-off-by: Zhao Lei <[email protected]>
Acked-by: Frederic Weisbecker <[email protected]>
Cc: Steven Rostedt <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
(cherry picked from commit torvalds/linux@8f7c2c3)

* Add documentation.

* Adjust names in order to satisfy naming convention.

* Use __VA_ARGS__ instead a GNU extension as this works with more compilers.

Works with the newest versions of ICCAVR, GCC, CLANG and MSCV. C++11 may be required.

* Adjust to ETL folder structure.

* Change include guard to the one usual in ETL.

* Add definition guard for STRINGIFY.

---------

Co-authored-by: Linus Torvalds <[email protected]>
Co-authored-by: Zhaolei <[email protected]>

* Updated stringify macro for variadic parameters

* Edited comments

* Added multi char type strcmp, strncmp, strcpy & strncpy

* Added support for self transitions

* Remove some unreachable code in bitset_new.h (#743)

Warning[Pe111]: statement is unreachable

* Re-enabled tests for etl::string_ext

* Changes require for non-virtual messages

* MutexMessageRouter example

* Allow C++03 delegate in etl::callback_timer

* #745 Assertion triggered in hash.h when compiling for MSP430

* Removed redundant #includes

* Removed unused variable

Minor format edit

* Added time_to_next() status function

* Added 'sentence case' versions of constants

* Added C++03 compatible etl::move or etl::move_backward

* Added c++03 zero parameter emplace member functions

* Fix issue of release of an object on empty an pool

* Remove used variable

* Remove used variable

* Change to require semicolons after debug count macros.

Added error assert for vector reserve greater than capacity.

* Added destructor to CMSIS_RTOS2 mutex

* Updated version and release notes

* Removed semicolon warnings

* Updated vesrion and release notes

* #753 [porting] IAR's overload resolution struggles with etl::span::span(etl::array&)

#754 ambiguous etl::bit_stream_reader::bit_stream_reader() for some etl::span

* #755 warning about constexpr in array.h

* Re-enabled tests

* const_reference at(size_t i) const is only constexpr from C++14

* Added conversion operators to std::span

* MacOS clang span issue

* MacOS clang span issue

* MacOS clang span issue

* MacOS clang span issue

* MacOS clang span issue

* Updated version and release notes

* Possible fix for #756

* Fixed: move assignment not working for non-empty containers (#759)

* Updated release notes

* Make "private" includes relativ (#761)

Avoid "include not found" when indirectly including etl-header

Co-authored-by: Andreas Pelczer <[email protected]>

* Make "private" includes relativ (#761)

Avoid "include not found" when indirectly including etl-header

Co-authored-by: Andreas Pelczer <[email protected]>

* Remove BOM from random.h (#762)

random.h is the only file with UTF8-BOM and IAR can not handle it.
For compatibility reasons it should be removed.

Co-authored-by: Andreas Pelczer <[email protected]>

* Enabled etl::overload for C++11 & C++14

* Added conversion operators to std::span

MacOS clang span issue

MacOS clang span issue

MacOS clang span issue

MacOS clang span issue

MacOS clang span issue

* Updated version and release notes

* Possible fix for #756

* Fixed: move assignment not working for non-empty containers (#759)

* Updated release notes

* Make "private" includes relativ (#761)

Avoid "include not found" when indirectly including etl-header

Co-authored-by: Andreas Pelczer <[email protected]>

* Remove BOM from random.h (#762)

random.h is the only file with UTF8-BOM and IAR can not handle it.
For compatibility reasons it should be removed.

Co-authored-by: Andreas Pelczer <[email protected]>

* Enabled etl::overload for C++11 & C++14

* Commets added

* #766 etl::unique_ptr::reset() can call deleter with nullptr argument

* Refactored storage for etl::optional

* Updated release notes

* Updated release notes

* Test name updates

* Fixed alignment functionality

* Updated versions

* Updated versions

* Initial code

* Final changes

* Fix maybe-uninitialized warning

* Fix maybe-uninitialized warning

* Added etl::string::fill()

* Added etl::string interface to etl::base64

* static_cast for string_view & array_view size() member functions

* Return raw pointer for `etl::multi_span::operator->()`. (#773)

- using `operator*()` in case getting the current element is changed one day
- using `&` to get the address

Simply returning `p_value` may break in case the internal type of `p_value` would change. This way it is more robust to changes.

* Added -> operator test

* #773 Return raw pointer for etl::multi_span::operator->()

* static_cast for string_view & array_view size() member functions

* Initial code

* Final changes

* Fix maybe-uninitialized warning

* Added etl::string::fill()

* Added etl::string interface to etl::base64

* Add missing semicolons (#776)

* #776 Add missing semicolons

* moved BUILD_TESTS check outside of root cmake check to allow building tests in submodules (#777)

added check for GNUC >= 11 for -Wstringop-overread ignore pragma since it isn't introduced until gcc/g++-11

Co-authored-by: Josh <[email protected]>

* Try to fix library error for Github Actions for Clang C++20

* Try to fix library error for Github Actions for Clang C++20

* Added pul-request branches to CI

* Removed temporary fix

* Refactored swap

* Added add_lvalue_reference for rvalue reference

* Revert "Added add_lvalue_reference for rvalue reference"

This reverts commit a09efff.

* Updated  version and release notes

* Updated  version and release notes

* Try to fix library error for Github Actions for Clang C++20

(cherry picked from commit f208eb4)

The line got lost in 95c7f44.

* Add helper macro which enables function-like macro overload with 1 or 2 arguments.

Inspired by https://stackoverflow.com/a/11763277/

Warning: This requires support for variadic macros (`__VA_ARGS__`). These were officially added in C99 and C++11.

* Add unit test for static_assert.h

(cherry picked from commit 91e7f46)

* Add static assert overload for only 1 argument.

(cherry picked from commit ae8c19e)

* Add test case for static_assert with only 1 argument.

(cherry picked from commit 4d6e7a6)

* Spelling.

---------

Co-authored-by: John Wellbelove <[email protected]>
Co-authored-by: David Hebbeker <[email protected]>
Co-authored-by: Linus Torvalds <[email protected]>
Co-authored-by: Zhaolei <[email protected]>
Co-authored-by: John Wellbelove <[email protected]>
Co-authored-by: Soma Veszelovszki <[email protected]>
Co-authored-by: Andreas <[email protected]>
Co-authored-by: Andreas Pelczer <[email protected]>
Co-authored-by: H1MSK <[email protected]>
Co-authored-by: jmartens-42 <[email protected]>
Co-authored-by: Josh <[email protected]>
Co-authored-by: John Wellbelove <[email protected]>
  • Loading branch information
13 people authored Feb 22, 2024
1 parent f9da1cd commit 3392a6c
Show file tree
Hide file tree
Showing 198 changed files with 17,948 additions and 18,795 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/clang-syntax-checks.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: clang syntax checks
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]

jobs:
build-clang-cpp03-linux-STL:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: clang
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]

jobs:

build-clang-cpp11-linux-stl:
name: Clang C++11 Linux - STL
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gcc-syntax-checks.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: gcc syntax checks
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]

jobs:
build-gcc-cpp03-linux-STL:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: gcc
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]

jobs:
build-gcc-cpp11-linux-stl:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: msvc
on:
push:
branches: [ master, development ]
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master ]
branches: [ master, pull-request/* ]

jobs:
build-windows-msvc-stl:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,7 @@ test/vs2022/Release MSVC C++20 - No STL - Optimised -O2
test/vs2022/Release MSVC C++20 - Optimised O2
test/vs2022/Debug MSVC C++ 20 - No Tests
test/vs2022/enc_temp_folder
test/vs2022/Debug MSVC C++20 - No virtual messages
examples/MutexMessageRouter/.vs
support/time remaining test.xlsx
test/vs2022/Debug MSVC C++20 - Force C++03
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/etl DESTINATION include)

if (BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()

endif()

if (BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
2 changes: 1 addition & 1 deletion arduino/library-arduino.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Embedded Template Library - Arduino",
"version": "20.37.3",
"version": "20.38.4",
"authors": {
"name": "John Wellbelove",
"email": "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion arduino/library-arduino.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Embedded Template Library - Arduino
version=20.37.3
version=20.38.4
author= John Wellbelove <[email protected]>
maintainer=John Wellbelove <[email protected]>
license=MIT
Expand Down
12 changes: 12 additions & 0 deletions examples/MutexMessageRouter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.5.0)
project(etl_mutex_router LANGUAGES CXX)

add_executable(etl_mutex_router MutexMessageRouter.cpp)

target_compile_definitions(etl_mutex_router PRIVATE -DETL_DEBUG)

target_include_directories(etl_mutex_router
PRIVATE
${PROJECT_SOURCE_DIR}/../../include)

set_property(TARGET etl_mutex_router PROPERTY CXX_STANDARD 17)
110 changes: 110 additions & 0 deletions examples/MutexMessageRouter/MutexMessageRouter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@

#include <iostream>
#include <thread>
#include <atomic>
#include <string>
#include <chrono>

#include "etl/mutex.h"
#include "etl/message.h"
#include "etl/message_router.h"

//*************************************
struct Message1 : public etl::message<1>
{
};

//*************************************
struct Message2 : public etl::message<2>
{
};

//*************************************
class Router : public etl::message_router<Router, Message1, Message2>
{
public:

using base_t = etl::message_router<Router, Message1, Message2>;

//*****************
// Overridden receive that protects access with mutexes
void receive(const etl::imessage& msg) override
{
access.lock();
base_t::receive(msg); // Send it to the message_router's receive.
access.unlock();
}

//*****************
void on_receive(const Message1&)
{
result.append("Message1\n");
}

//*****************
void on_receive(const Message2&)
{
result.append("Message2\n");
}

//*****************
void on_receive_unknown(const etl::imessage&)
{
}

std::string result;

private:

etl::mutex access;
};

//*************************************
etl::atomic<bool> start = false;
Router router;

//*************************************
void thread1()
{
using namespace std::chrono_literals;

while (!start.load());

for (int i = 0; i < 10; ++i)
{
std::this_thread::sleep_for(1ms);
router.receive(Message1());
}
}

//*************************************
void thread2()
{
using namespace std::chrono_literals;

while (!start.load());

for (int i = 0; i < 10; ++i)
{
std::this_thread::sleep_for(1ms);
router.receive(Message2());
}
}

//*************************************
int main()
{
std::thread t1(thread1);
std::thread t2(thread2);

start.store(true);

t1.join();
t2.join();

std::cout << router.result << "\n";

return 0;
}


31 changes: 31 additions & 0 deletions examples/MutexMessageRouter/MutexMessageRouter.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34009.444
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MutexMessageRouter", "MutexMessageRouter.vcxproj", "{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x64.ActiveCfg = Debug|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x64.Build.0 = Debug|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x86.ActiveCfg = Debug|Win32
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Debug|x86.Build.0 = Debug|Win32
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x64.ActiveCfg = Release|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x64.Build.0 = Release|x64
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x86.ActiveCfg = Release|Win32
{23AD62D5-C3B6-48B0-BF0D-E349FEB3F338}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8AA5CBFE-B15F-4262-97AE-C12F7266BD85}
EndGlobalSection
EndGlobal
140 changes: 140 additions & 0 deletions examples/MutexMessageRouter/MutexMessageRouter.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{23ad62d5-c3b6-48b0-bf0d-e349feb3f338}</ProjectGuid>
<RootNamespace>MutexMessageRouter</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../include;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="MutexMessageRouter.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading

0 comments on commit 3392a6c

Please sign in to comment.