Skip to content

Commit

Permalink
#805 legacy etl::bitset set/reset does not work if the element type i…
Browse files Browse the repository at this point in the history
…s greater than 8 bit
  • Loading branch information
John Wellbelove committed Dec 18, 2023
1 parent d17f422 commit c75617c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
18 changes: 9 additions & 9 deletions include/etl/private/bitset_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ namespace etl
typedef typename etl::make_unsigned<ETL_BITSET_ELEMENT_TYPE>::type element_type;
typedef element_type element_t; // Backward compatibility

static ETL_CONSTANT element_type ALL_SET = etl::integral_limits<element_type>::max;
static ETL_CONSTANT element_type ALL_SET = etl::integral_limits<element_type>::max;
static ETL_CONSTANT element_type ALL_CLEAR = 0;

static ETL_CONSTANT size_t Bits_Per_Element = etl::integral_limits<element_type>::bits;
static ETL_CONSTANT size_t Bits_Per_Element = etl::integral_limits<element_type>::bits;

#if ETL_USING_CPP11
typedef etl::span<element_type> span_type;
Expand Down Expand Up @@ -311,7 +311,7 @@ namespace etl
//*************************************************************************
ibitset& set()
{
::memset(pdata, 0xFF, Number_Of_Elements);
etl::fill_n(pdata, Number_Of_Elements - 1U, ALL_SET);
pdata[Number_Of_Elements - 1U] = Top_Mask;

return *this;
Expand Down Expand Up @@ -519,7 +519,7 @@ namespace etl
return v;
}

//*************************************************************************
//*************************************************************************
/// Put to a unsigned long.
//*************************************************************************
unsigned long to_ulong() const
Expand All @@ -540,7 +540,7 @@ namespace etl
//*************************************************************************
ibitset& reset()
{
::memset(pdata, 0, Number_Of_Elements * sizeof(element_type));
etl::fill_n(pdata, Number_Of_Elements, ALL_CLEAR);

return *this;
}
Expand Down Expand Up @@ -582,10 +582,10 @@ namespace etl
//*************************************************************************
ibitset& flip()
{
for (size_t i = 0UL; i < Number_Of_Elements; ++i)
{
pdata[i] = ~pdata[i];
}
etl::transform_n(pdata,
Number_Of_Elements,
pdata,
etl::binary_not<element_type>());

clear_unused_bits_in_msb();

Expand Down
8 changes: 4 additions & 4 deletions include/etl/private/bitset_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,10 @@ namespace etl
//*************************************************************************
ETL_CONSTEXPR14 void flip(pointer pbuffer, size_t number_of_elements) ETL_NOEXCEPT
{
for (size_t i = 0UL; i < number_of_elements; ++i)
{
pbuffer[i] = ~pbuffer[i];
}
etl::transform_n(pbuffer,
number_of_elements,
pbuffer,
etl::binary_not<element_type>());
}

//*************************************************************************
Expand Down
30 changes: 24 additions & 6 deletions test/vs2022/etl.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3340,12 +3340,6 @@
<None Include="..\..\appveyor.yml">
<Filter>Resource Files\CI\Appveyor</Filter>
</None>
<None Include="..\..\.github\workflows\clang.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\gcc.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.clang-format">
<Filter>Resource Files</Filter>
</None>
Expand Down Expand Up @@ -3412,6 +3406,30 @@
<None Include="..\..\scripts\update_version.py">
<Filter>Tests\Scripts</Filter>
</None>
<None Include="..\..\.github\workflows\clang-c++11.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\clang-c++14.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\clang-c++17.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\clang-c++20.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\gcc-c++11.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\gcc-c++14.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\gcc-c++17.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
<None Include="..\..\.github\workflows\gcc-c++20.yml">
<Filter>Resource Files\CI\Github</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\support\Release notes.txt">
Expand Down

0 comments on commit c75617c

Please sign in to comment.