The Pigweed namespace. More...
Namespaces | |
namespace | analog |
Analog-to-digital converter (ADC) library. | |
namespace | async |
(Deprecated) Async library | |
namespace | base64 |
Base64 encoding, decoding, and validating library. | |
namespace | bloat |
Binary size reports library. | |
namespace | bluetooth_sapphire |
Dual-mode Bluetooth host stack. | |
namespace | bytes |
Binary data manipulation utilities. | |
namespace | chrono |
Portable std::chrono library for embedded. | |
namespace | clock_tree |
Clock tree management library. | |
namespace | crypto |
Cryptography library. | |
namespace | digital_io |
GPIO library. | |
namespace | display |
Graphic display and framebuffer library. | |
namespace | dump |
Hexdump utilities. | |
namespace | elf |
Basic ELF reader library. | |
namespace | hdlc |
Serial comms library. | |
namespace | i2c |
Cross-platform I2C library. | |
namespace | interrupt |
Interrupt context interface. | |
namespace | kvs |
Lightweight key-value store library. | |
namespace | log |
Portable logging library. | |
namespace | malloc |
Replacement interface for standard libc dynamic memory operations. | |
namespace | perf_test |
Micro-benchmarks library. | |
namespace | persistent_ram |
Persistent RAM utilities and containers. | |
namespace | sync |
namespace | sys_io |
Unoptimized I/O library. | |
namespace | system |
Opinionated system framework. | |
namespace | thread |
Thread creation and execution library. | |
namespace | uart |
Core UART interfaces. | |
namespace | unit_test |
GoogleTest for embedded. | |
namespace | utf |
Provides basic helpers for reading and writing UTF-8-encoded strings. | |
namespace | uuid |
128-bit universally unique identifier library | |
namespace | work_queue |
Work queue library for threads and interrupts. | |
Typedefs | |
template<typename T > | |
using | AlignedAtomic = std::atomic< NaturallyAligned< T > > |
using | ByteSpan = span< std::byte > |
using | ConstByteSpan = span< const std::byte > |
template<typename T , size_t kCapacity = containers::internal::kGenericSized> | |
using | InlineAsyncDeque = BasicInlineAsyncDeque< T, uint16_t, kCapacity > |
template<typename ValueType , size_t kCapacity = containers::internal::kGenericSized> | |
using | InlineAsyncQueue = BasicInlineAsyncQueue< ValueType, uint16_t, kCapacity > |
template<typename ValueType , typename SizeType , size_t kCapacity = containers::internal::kGenericSized> | |
using | BasicInlineDeque = containers::internal::BasicInlineDequeImpl< ValueType, containers::internal::CountAndCapacity< SizeType >, kCapacity > |
template<typename T , size_t kCapacity = containers::internal::kGenericSized> | |
using | InlineDeque = BasicInlineDeque< T, uint16_t, kCapacity > |
template<typename T , size_t kCapacity = containers::internal::kGenericSized> | |
using | InlineQueue = BasicInlineQueue< T, uint16_t, kCapacity > |
template<size_t kMaxSizeBytes = containers::internal::kGenericSized> | |
using | InlineVarLenEntryQueue = BasicInlineVarLenEntryQueue< std::byte, kMaxSizeBytes > |
Variable-length entry queue that uses std::byte for the byte type. | |
template<typename T > | |
using | IntrusiveList = containers::future::IntrusiveList< T > |
template<typename FunctionType > | |
using | Function = fit::function_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > |
template<typename FunctionType , std::size_t inline_target_size = function_internal::config::kInlineCallableSize> | |
using | InlineFunction = fit::inline_function< FunctionType, inline_target_size > |
template<typename FunctionType , std::size_t inline_target_size = function_internal::config::kInlineCallableSize, typename Allocator = PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE> | |
using | DynamicFunction = fit::function_impl< inline_target_size, false, FunctionType, Allocator > |
using | Closure = Function< void()> |
void -returning pw::Function that takes no arguments. | |
template<typename FunctionType > | |
using | Callback = fit::callback_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > |
template<typename FunctionType , std::size_t inline_target_size = function_internal::config::kInlineCallableSize> | |
using | InlineCallback = fit::inline_callback< FunctionType, inline_target_size > |
Version of pw::Callback that exclusively uses inline storage. | |
template<typename FunctionType , std::size_t inline_target_size = function_internal::config::kInlineCallableSize, typename Allocator = PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE> | |
using | DynamicCallback = fit::callback_impl< inline_target_size, false, FunctionType, Allocator > |
Version of pw::Callback that supports dynamic allocation. | |
using | FlatMultiBuf = BasicMultiBuf<> |
Basic MultiBuf interface with mutable data. | |
using | FlatConstMultiBuf = BasicMultiBuf< MultiBufProperty::kConst > |
Basic MultiBuf interface with read-only data. | |
using | MultiBuf = BasicMultiBuf< MultiBufProperty::kLayerable > |
using | ConstMultiBuf = BasicMultiBuf< MultiBufProperty::kConst, MultiBufProperty::kLayerable > |
using | TrackedFlatMultiBuf = BasicMultiBuf< MultiBufProperty::kObservable > |
using | TrackedFlatConstMultiBuf = BasicMultiBuf< MultiBufProperty::kConst, MultiBufProperty::kObservable > |
using | TrackedMultiBuf = BasicMultiBuf< MultiBufProperty::kLayerable, MultiBufProperty::kObservable > |
using | TrackedConstMultiBuf = BasicMultiBuf< MultiBufProperty::kConst, MultiBufProperty::kLayerable, MultiBufProperty::kObservable > |
template<size_t kCapacity = string_impl::kGeneric> | |
using | InlineString = InlineBasicString< char, kCapacity > |
pw::InlineString is an alias of pw::InlineBasicString<char> and is equivalent to std::string . | |
template<size_t kCapacity = string_impl::kGeneric> | |
using | InlineByteString = InlineBasicString< std::byte, kCapacity > |
pw::InlineByteString is an alias of pw::InlineBasicString<std::byte> . InlineByteString may be used as a simple, efficient byte container. | |
using | DefaultThreadContext = ThreadContext< thread::backend::kDefaultStackSizeBytes > |
Alias for ThreadContext with the backend's default stack size. | |
using | ThreadPriority = thread::internal::Priority< thread::backend::PriorityType, thread::backend::kLowestPriority, thread::backend::kHighestPriority, thread::backend::kDefaultPriority > |
using | Thread = ::pw::thread::Thread |
Enumerations | |
enum class | MultiBufProperty : uint8_t { MultiBufProperty::kConst = 1 << 0 , MultiBufProperty::kLayerable = 1 << 1 , MultiBufProperty::kObservable = 1 << 2 } |
Basic properties of a MultiBuf. More... | |
Functions | |
constexpr size_t | countl_zero (size_t x) noexcept |
constexpr size_t | bit_width (size_t x) noexcept |
constexpr size_t | bit_ceil (size_t x) noexcept |
class pw::Deallocator | DoGetInfo (InfoType info_type, const void *ptr) override |
template<> | |
StatusWithSize | ToString (const async2::ReadyType &, span< char > buffer) |
template<> | |
StatusWithSize | ToString (const async2::PendingType &, span< char > buffer) |
template<typename T > | |
StatusWithSize | ToString (const async2::Poll< T > &poll, span< char > buffer) |
template<> | |
StatusWithSize | ToString (const async2::Poll<> &poll, span< char > buffer) |
bool | IsAlignedAs (const void *ptr, size_t alignment) |
Returns whether the given pointer meets the given alignment requirement. | |
template<typename T > | |
bool | IsAlignedAs (const void *ptr) |
constexpr size_t | AlignDown (uintptr_t value, size_t alignment) |
Returns the value rounded down to the nearest multiple of alignment. | |
template<typename T > | |
constexpr T * | AlignDown (T *value, size_t alignment) |
Returns the value rounded down to the nearest multiple of alignment. | |
constexpr size_t | AlignUp (uintptr_t value, size_t alignment) |
Returns the value rounded up to the nearest multiple of alignment. | |
template<typename T > | |
constexpr T * | AlignUp (T *value, size_t alignment) |
Returns the value rounded up to the nearest multiple of alignment. | |
constexpr size_t | Padding (size_t length, size_t alignment) |
Returns the number of padding bytes required to align the provided length. | |
ByteSpan | GetAlignedSubspan (ByteSpan bytes, size_t alignment) |
constexpr ByteBuilder::iterator | operator+ (int n, ByteBuilder::iterator it) |
template<typename T > | |
span< const std::byte, sizeof(T)> | ObjectAsBytes (const T &obj) |
template<typename T > | |
span< std::byte, sizeof(T)> | ObjectAsWritableBytes (T &obj) |
PW_CONSTEVAL std::byte | operator""_b (unsigned long long value) |
template<typename InputIt , typename Predicate > | |
constexpr bool | all_of (InputIt first, InputIt last, Predicate pred) |
constexpr backport of <algorithm> 's std::all_of for C++17. | |
template<typename InputIt , typename Predicate > | |
constexpr bool | any_of (InputIt first, InputIt last, Predicate pred) |
constexpr backport of <algorithm> 's std::any_of for C++17. | |
template<typename InputIt , typename Predicate > | |
constexpr InputIt | find_if (InputIt first, InputIt last, Predicate pred) |
constexpr backport of <algorithm> 's std::find_if for C++17. | |
template<typename ForwardIt , typename T > | |
constexpr void | fill (ForwardIt begin, ForwardIt end, const T &value) |
constexpr backport of <algorithm> 's std::fill for C++17. | |
template<typename It , typename Size , typename T > | |
constexpr It | fill_n (It begin, Size count, const T &value) |
constexpr backport of <algorithm> 's std::fill_n for C++17. | |
template<typename T , size_t kLhsSize, size_t kRhsSize> | |
bool | operator== (const Vector< T, kLhsSize > &lhs, const Vector< T, kRhsSize > &rhs) |
template<typename T , size_t kLhsSize, size_t kRhsSize> | |
bool | operator!= (const Vector< T, kLhsSize > &lhs, const Vector< T, kRhsSize > &rhs) |
template<typename T , size_t kLhsSize, size_t kRhsSize> | |
bool | operator< (const Vector< T, kLhsSize > &lhs, const Vector< T, kRhsSize > &rhs) |
template<typename T , size_t kLhsSize, size_t kRhsSize> | |
bool | operator<= (const Vector< T, kLhsSize > &lhs, const Vector< T, kRhsSize > &rhs) |
template<typename T , size_t kLhsSize, size_t kRhsSize> | |
bool | operator> (const Vector< T, kLhsSize > &lhs, const Vector< T, kRhsSize > &rhs) |
template<typename T , size_t kLhsSize, size_t kRhsSize> | |
bool | operator>= (const Vector< T, kLhsSize > &lhs, const Vector< T, kRhsSize > &rhs) |
template<auto method, typename T > | |
auto | bind_member (T *instance) |
template<typename Function > | |
ScopeGuard (Function()) -> ScopeGuard< Function(*)()> | |
template<typename A , typename B , typename T > | |
constexpr bool | CheckedAdd (A a, B b, T &result) |
template<typename T , typename A , typename B > | |
constexpr std::optional< T > | CheckedAdd (A a, B b) |
template<typename T , typename Inc > | |
constexpr bool | CheckedIncrement (T &base, Inc inc) |
template<typename A , typename B , typename T > | |
constexpr bool | CheckedSub (A a, B b, T &result) |
template<typename T , typename A , typename B > | |
constexpr std::optional< T > | CheckedSub (A a, B b) |
template<typename T , typename Dec > | |
constexpr bool | CheckedDecrement (T &base, Dec dec) |
template<typename A , typename B , typename T > | |
constexpr bool | CheckedMul (A a, B b, T &result) |
template<typename T , typename A , typename B > | |
constexpr std::optional< T > | CheckedMul (A a, B b) |
template<typename T > | |
constexpr T | IntegerDivisionRoundNearest (T dividend, T divisor) |
template<typename T > | |
constexpr T | add_sat (T lhs, T rhs) noexcept |
template<typename T > | |
constexpr T | mul_sat (T lhs, T rhs) noexcept |
template<class ResultT , size_t kSourceExtentBytes> | |
internal::SpanFromBytes< ResultT, kSourceExtentBytes > | span_cast (span< std::byte, kSourceExtentBytes > bytes) |
template<class ResultT , size_t kSourceExtentBytes> | |
internal::SpanFromBytes< const ResultT, kSourceExtentBytes > | span_cast (span< const std::byte, kSourceExtentBytes > bytes) |
template<typename T , size_t X> | |
span< const std::byte,(X==dynamic_extent ? dynamic_extent :sizeof(T) *X)> | as_bytes (span< T, X > s) noexcept |
template<typename T , size_t X, typename = std::enable_if_t<!std::is_const<T>::value>> | |
span< std::byte,(X==dynamic_extent ? dynamic_extent :sizeof(T) *X)> | as_writable_bytes (span< T, X > s) noexcept |
constexpr Status | OkStatus () |
constexpr bool | operator== (const Status &lhs, const Status &rhs) |
constexpr bool | operator!= (const Status &lhs, const Status &rhs) |
template<typename T , size_t kLhsCapacity, size_t kRhsCapacity> | |
constexpr bool | operator== (const InlineBasicString< T, kLhsCapacity > &lhs, const InlineBasicString< T, kRhsCapacity > &rhs) noexcept |
template<typename T , size_t kLhsCapacity, size_t kRhsCapacity> | |
constexpr bool | operator!= (const InlineBasicString< T, kLhsCapacity > &lhs, const InlineBasicString< T, kRhsCapacity > &rhs) noexcept |
template<typename T , size_t kLhsCapacity, size_t kRhsCapacity> | |
constexpr bool | operator< (const InlineBasicString< T, kLhsCapacity > &lhs, const InlineBasicString< T, kRhsCapacity > &rhs) noexcept |
template<typename T , size_t kLhsCapacity, size_t kRhsCapacity> | |
constexpr bool | operator<= (const InlineBasicString< T, kLhsCapacity > &lhs, const InlineBasicString< T, kRhsCapacity > &rhs) noexcept |
template<typename T , size_t kLhsCapacity, size_t kRhsCapacity> | |
constexpr bool | operator> (const InlineBasicString< T, kLhsCapacity > &lhs, const InlineBasicString< T, kRhsCapacity > &rhs) noexcept |
template<typename T , size_t kLhsCapacity, size_t kRhsCapacity> | |
constexpr bool | operator>= (const InlineBasicString< T, kLhsCapacity > &lhs, const InlineBasicString< T, kRhsCapacity > &rhs) noexcept |
template<typename T , size_t kLhsCapacity> | |
constexpr bool | operator== (const InlineBasicString< T, kLhsCapacity > &lhs, const T *rhs) |
template<typename T , size_t kRhsCapacity> | |
constexpr bool | operator== (const T *lhs, const InlineBasicString< T, kRhsCapacity > &rhs) |
template<typename T , size_t kLhsCapacity> | |
constexpr bool | operator!= (const InlineBasicString< T, kLhsCapacity > &lhs, const T *rhs) |
template<typename T , size_t kRhsCapacity> | |
constexpr bool | operator!= (const T *lhs, const InlineBasicString< T, kRhsCapacity > &rhs) |
template<typename T , size_t kLhsCapacity> | |
constexpr bool | operator< (const InlineBasicString< T, kLhsCapacity > &lhs, const T *rhs) |
template<typename T , size_t kRhsCapacity> | |
constexpr bool | operator< (const T *lhs, const InlineBasicString< T, kRhsCapacity > &rhs) |
template<typename T , size_t kLhsCapacity> | |
constexpr bool | operator<= (const InlineBasicString< T, kLhsCapacity > &lhs, const T *rhs) |
template<typename T , size_t kRhsCapacity> | |
constexpr bool | operator<= (const T *lhs, const InlineBasicString< T, kRhsCapacity > &rhs) |
template<typename T , size_t kLhsCapacity> | |
constexpr bool | operator> (const InlineBasicString< T, kLhsCapacity > &lhs, const T *rhs) |
template<typename T , size_t kRhsCapacity> | |
constexpr bool | operator> (const T *lhs, const InlineBasicString< T, kRhsCapacity > &rhs) |
template<typename T , size_t kLhsCapacity> | |
constexpr bool | operator>= (const InlineBasicString< T, kLhsCapacity > &lhs, const T *rhs) |
template<typename T , size_t kRhsCapacity> | |
constexpr bool | operator>= (const T *lhs, const InlineBasicString< T, kRhsCapacity > &rhs) |
template<size_t kBufferSize = 0u, typename... Args> | |
auto | MakeString (Args &&... args) |
system::AsyncCore & | System () |
void | SystemStart (channel::ByteReaderWriter &io_channel) |
void | InfiniteLoop () |
Variables | |
constexpr size_t | dynamic_extent = std::numeric_limits<size_t>::max() |
constexpr size_t | kExternallyAllocatedThreadStack |
constexpr ConstexprTag | kConstexpr {} |
The Pigweed namespace.
have no equivalent here.
For template parameter and variable naming, C
indicates the container type to which the function is applied, Pred
indicates the predicate object type to be used by the function and T
indicates the applicable element type.
Returns the largest aligned subspan of a given byte span.
The subspan will start and end on alignment boundaries.
ByteSpan
within bytes
aligned to alignment
, or an empty ByteSpan
if alignment was not possible. bool pw::IsAlignedAs | ( | const void * | ptr | ) |
Returns whether the given pointer meets the alignment requirement for the given type.
span< const std::byte, sizeof(T)> pw::ObjectAsBytes | ( | const T & | obj | ) |
Gets a read-only pw::span<const std::byte>
(ConstByteSpan
) view of an object.
This function is only available for types where it always safe to rely on the underlying bytes of the object, i.e. serializable objects designed to be sent over the wire. It cannot be used with, for example, types that include padding bytes, since those are indeterminate and may leak information.
For types that do not meet these criteria, it is still possible to represent them as bytes using pw::as_bytes
, albeit in a manner that is unsafe for serialization.
The returned span has a static extent.
span< std::byte, sizeof(T)> pw::ObjectAsWritableBytes | ( | T & | obj | ) |
Gets a writable pw::span<std::byte>
(ByteSpan
) view of an object.
This function is only available for types where it always safe to rely on the underlying bytes of the object, i.e. serializable objects designed to be sent over the wire. It cannot be used with, for example, types that include padding bytes, since those are indeterminate and may leak information.
For types that do not meet these criteria, it is still possible to represent them as bytes using pw::as_writable_bytes
, albeit in a manner that is unsafe for serialization.
The returned span has a static extent.
|
constexpr |
Returns an
embed:rst:inline :c:enumerator:`OK`
status. Equivalent to Status()
or Status(PW_STATUS_OK)
. This function is used instead of a Status::Ok()
function, which would be too similar to Status::ok()
.
PW_CONSTEVAL std::byte pw::operator""_b | ( | unsigned long long | value | ) |
Returns a std::byte
when used as a _b
suffix.
This is useful for writing byte literals, particularly in tests. To use, add using ::pw::operator""_b;
and then use like 5_b
in order to create a std::byte
with the contents 5
.
This should not be used in header files, as it requires a using
declaration that will be publicly exported at whatever level it is used.
internal::SpanFromBytes< const ResultT, kSourceExtentBytes > pw::span_cast | ( | span< const std::byte, kSourceExtentBytes > | bytes | ) |
Casts a pw::span<const std::byte>
(ConstByteSpan
) to a span of a different const type.
This function is only safe to use if the underlying data is actually of the specified type. You cannot safely use this function to reinterpret e.g. a raw byte array from malloc()
as a span of integers.
This function is essentially the inverse of pw::as_bytes
.
If kSourceExtentBytes
is dynamic_extent
, the returned span also has a dynamic extent. Otherwise, the returned span has a static extent of kSourceExtentBytes / sizeof(ResultT)
.
ResultT | The type of the returned span. Must be one byte to avoid misuse and violation of the strict aliasing rule. This restriction might be lifted in the future. |
kSourceExtentBytes | The extent of the source byte span. This is normally inferred and need not be explicitly provided. |