-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[avr] port a subset of libstdc++ to the AVR platform
This will allow for using large parts of the C++ standard library inside modm. Almost the complete implementation is copied from libstdc++ sources released with GCC 8.2.0. Most headers do not require any modifications. Some parts have been deliberately excluded because they are unavailable on embedded platforms or the provided implementation is inherently unsuitable for AVR and requires considerable porting efforts. For instance, the string conversion functions contain kilobytes of static data that would be put into RAM. IOStreams and std::string are also not available. All stream-related code is removed from the supplied headers. The following parts are included: - Containers - Algorithms (<algorithm>) - Iterators library (<iterator>, except for iostream iterators) - Numerics library (<complex>, <numeric>, <ratio>, <valarray>) - Utilities library (<type_traits>, <any>, <optional>, <variant>, <tuple>, <utility>, <chrono>, …) - Numeric limits (<limits>) - C headers except for C99/C11 additions not supported by AVR libc (<c*>) - Memory management (<new>, <memory>, <scoped_allocator>), except for std::shared_ptr - String view (<string_view>) Not included (may be incomplete): - std::string and string conversions, regex - Anything that requires an OS to work (threads, filesystem, locales, ...) - Atomics - iostreams and related headers - Random number generation (<random>) - std::shared_ptr (build on atomics, high porting effort) - std::bitset - Polymorphic allocators (<memory_resource>), experimental in libstdc++ - Exception headers - RTTI headers
- Loading branch information
Showing
19 changed files
with
270 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2018, Christopher Durand | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include <cstdint> | ||
#include <bits/functexcept.h> | ||
#include <modm/utils/bit_constants.hpp> | ||
|
||
%% if options["use_modm_assert"] | ||
#include <modm/architecture/interface/assert.hpp> | ||
|
||
#define __modm_stdcpp_failure(failure) modm_assert(false, "stdc++", "stdc++", failure);__builtin_abort(); | ||
%% else | ||
#define __modm_stdcpp_failure(failure) __builtin_abort(); | ||
%% endif | ||
|
||
namespace std _GLIBCXX_VISIBILITY(default) | ||
{ | ||
_GLIBCXX_BEGIN_NAMESPACE_VERSION | ||
|
||
void | ||
__throw_logic_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("logic_error"); } | ||
|
||
void | ||
__throw_domain_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("domain_error"); } | ||
|
||
void | ||
__throw_invalid_argument(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("invalid_argument"); } | ||
|
||
void | ||
__throw_length_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("length_error"); } | ||
|
||
void | ||
__throw_out_of_range(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("out_of_range"); } | ||
|
||
void | ||
__throw_runtime_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("runtime_error"); } | ||
|
||
void | ||
__throw_range_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("range_error"); } | ||
|
||
void | ||
__throw_overflow_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("overflow_error"); } | ||
|
||
void | ||
__throw_underflow_error(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("underflow_error"); } | ||
|
||
void | ||
__throw_bad_optional_access() | ||
{ __modm_stdcpp_failure("bad_optional"); } | ||
|
||
void | ||
__throw_bad_variant_access(const char* __s __attribute__((unused))) | ||
{ __modm_stdcpp_failure("bad_variant"); } | ||
|
||
void | ||
__throw_bad_function_call() | ||
{ __modm_stdcpp_failure("bad_function_call"); } | ||
|
||
void | ||
__throw_bad_any_cast() | ||
{ __modm_stdcpp_failure("bad_any_cast"); } | ||
_GLIBCXX_END_NAMESPACE_VERSION | ||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.