Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constexpr CRC for C++23 #907

Draft
wants to merge 15 commits into
base: pull-request/#907-Constexpr-CRC-for-C++23
Choose a base branch
from
Draft
163 changes: 163 additions & 0 deletions .github/workflows/clang-c++23.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: clang-c++23
on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]

jobs:

build-clang-cpp23-linux-no-stl:
name: Clang C++23 Linux - No STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang-18
export CXX=clang++-18
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./
clang-18 --version
make

- name: Run tests
run: ./test/etl_tests

build-clang-cpp23-linux-stl-force-cpp03:
name: Clang C++23 Linux - STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang-18
export CXX=clang++-18
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./
clang-18 --version
make

- name: Run tests
run: ./test/etl_tests

build-clang-cpp23-linux-no-stl-force-cpp03:
name: Clang C++23 Linux - No STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang-18
export CXX=clang++-18
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./
clang-18 --version
make

- name: Run tests
run: ./test/etl_tests

build-clang-cpp23-osx-stl:
name: Clang C++23 OSX - STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang
export CXX=clang++
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./
clang --version
make

- name: Run tests
run: ./test/etl_tests

build-clang-cpp23-osx-no-stl:
name: Clang C++23 OSX - No STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang
export CXX=clang++
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./
clang --version
make

- name: Run tests
run: ./test/etl_tests

build-clang-cpp23-osx-stl-force-cpp03:
name: Clang C++23 OSX - STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang
export CXX=clang++
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./
clang --version
make

- name: Run tests
run: ./test/etl_tests

build-clang-cpp23-osx-no-stl-force-cpp03:
name: Clang C++23 OSX - No STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-12]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export CC=clang
export CXX=clang++
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./
clang --version
make

- name: Run tests
run: ./test/etl_tests

96 changes: 96 additions & 0 deletions .github/workflows/gcc-c++23.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: gcc-c++23
on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]

jobs:

build-gcc-cpp23-linux-stl:
name: GCC C++23 Linux - STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
export CC=gcc
export CXX=g++
cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./
gcc --version
make

- name: Run tests
run: ./test/etl_tests

build-gcc-cpp23-linux-no-stl:
name: GCC C++23 Linux - No STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
export CC=gcc
export CXX=g++
cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./
gcc --version
make

- name: Run tests
run: ./test/etl_tests

build-gcc-cpp23-linux-stl-force-cpp03:
name: GCC C++23 Linux - STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
export CC=gcc
export CXX=g++
cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./
gcc --version
make

- name: Run tests
run: ./test/etl_tests

build-gcc-cpp23-linux-no-stl-force-cpp03:
name: GCC C++23 Linux - No STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04]

steps:
- uses: actions/checkout@v3

- name: Build
run: |
export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0
export CC=gcc
export CXX=g++
cmake -DBUILD_TESTS=ON -DNO_STL=OON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./
gcc --version
make

- name: Run tests
run: ./test/etl_tests
12 changes: 6 additions & 6 deletions include/etl/frame_check_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace etl
//*************************************************************************
/// Default constructor.
//*************************************************************************
frame_check_sequence()
ETL_CONSTEXPR14 frame_check_sequence()
{
reset();
}
Expand All @@ -118,7 +118,7 @@ namespace etl
/// \param end End of the range.
//*************************************************************************
template<typename TIterator>
frame_check_sequence(TIterator begin, const TIterator end)
ETL_CONSTEXPR14 frame_check_sequence(TIterator begin, const TIterator end)
{
ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits<TIterator>::value_type) == 1, "Type not supported");

Expand All @@ -129,7 +129,7 @@ namespace etl
//*************************************************************************
/// Resets the FCS to the initial state.
//*************************************************************************
void reset()
ETL_CONSTEXPR14 void reset()
{
frame_check = policy.initial();
}
Expand All @@ -140,7 +140,7 @@ namespace etl
/// \param end
//*************************************************************************
template<typename TIterator>
void add(TIterator begin, const TIterator end)
ETL_CONSTEXPR23 void add(TIterator begin, const TIterator end)
{
ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits<TIterator>::value_type) == 1, "Type not supported");

Expand All @@ -154,15 +154,15 @@ namespace etl
//*************************************************************************
/// \param value The uint8_t to add to the FCS.
//*************************************************************************
void add(uint8_t value_)
ETL_CONSTEXPR23 void add(uint8_t value_)
{
frame_check = policy.add(frame_check, value_);
}

//*************************************************************************
/// Gets the FCS value.
//*************************************************************************
value_type value() const
ETL_CONSTEXPR14 value_type value() const
{
return policy.final(frame_check);
}
Expand Down
2 changes: 2 additions & 0 deletions include/etl/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ SOFTWARE.
// C++23
#if ETL_USING_CPP23 && !defined(ETL_FORCE_NO_ADVANCED_CPP)
#define ETL_ASSUME(expression) [[assume(expression)]]
#define ETL_CONSTEXPR23 constexpr
#else
#define ETL_ASSUME ETL_DO_NOTHING
#define ETL_CONSTEXPR23
#endif

//*************************************
Expand Down
Loading
Loading