Skip to content

Commit 5fdd5e5

Browse files
committed
💚 Remove template argument from single allocator
1 parent 5c6ed12 commit 5fdd5e5

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

conanfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def _runtime_select(self):
6767
return "ARM_CORTEX_GCC"
6868
elif self._is_arm_cortex and self.options.runtime == "estell":
6969
return "ARM_CORTEX_ESTELL"
70+
else:
71+
return "ARM_CORTEX_GCC"
7072

7173
def validate(self):
7274
if self.settings.get_safe("compiler.cppstd"):

src/control.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
#include <array>
1616
#include <cstdint>
17-
#include <exception>
17+
#include <memory_resource>
1818

1919
#include <libhal-exceptions/control.hpp>
20-
#include <memory_resource>
2120

2221
namespace __cxxabiv1 { // NOLINT
2322
std::terminate_handler __terminate_handler = +[]() { // NOLINT
@@ -46,19 +45,12 @@ std::terminate_handler get_terminate() noexcept
4645
*
4746
* This allocator can only allocates space for a single exception object at a
4847
* time.
49-
*
50-
* @tparam size - size of the exception object memory buffer. If this is set too
51-
* small (less than 128 bytes), then it is likely that the memory will not be
52-
* enough for any exception runtime and will result in terminate being called.
5348
*/
54-
template<size_t size>
5549
class single_exception_allocator : public std::pmr::memory_resource
5650
{
5751
public:
5852
single_exception_allocator() = default;
59-
virtual ~single_exception_allocator() override
60-
{
61-
}
53+
~single_exception_allocator() override = default;
6254

6355
private:
6456
void* do_allocate(std::size_t p_size,
@@ -87,13 +79,12 @@ class single_exception_allocator : public std::pmr::memory_resource
8779
return this == &other;
8880
}
8981

90-
std::array<std::uint8_t, size> m_buffer{};
82+
std::array<std::uint8_t, 256> m_buffer{};
9183
bool m_allocated = false;
9284
};
9385

9486
// TODO(#11): Add macro to IFDEF this out if the user want to save 256 bytes.
95-
using default_exception_allocator = single_exception_allocator<256>;
96-
default_exception_allocator _default_allocator{}; // NOLINT
87+
single_exception_allocator _default_allocator{}; // NOLINT
9788
std::pmr::memory_resource* _exception_allocator =
9889
&_default_allocator; // NOLINT
9990

0 commit comments

Comments
 (0)