diff options
Diffstat (limited to 'pw_kvs/public/pw_kvs/alignment.h')
-rw-r--r-- | pw_kvs/public/pw_kvs/alignment.h | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/pw_kvs/public/pw_kvs/alignment.h b/pw_kvs/public/pw_kvs/alignment.h index f8050d4ff..875d35074 100644 --- a/pw_kvs/public/pw_kvs/alignment.h +++ b/pw_kvs/public/pw_kvs/alignment.h @@ -19,6 +19,7 @@ #include <initializer_list> #include <utility> +#include "pw_bytes/alignment.h" #include "pw_bytes/span.h" #include "pw_kvs/io.h" #include "pw_span/span.h" @@ -26,21 +27,6 @@ namespace pw { -// Returns the value rounded down to the nearest multiple of alignment. -constexpr size_t AlignDown(size_t value, size_t alignment) { - return (value / alignment) * alignment; -} - -// Returns the value rounded up to the nearest multiple of alignment. -constexpr size_t AlignUp(size_t value, size_t alignment) { - return (value + alignment - 1) / alignment * alignment; -} - -// Returns the number of padding bytes required to align the provided length. -constexpr size_t Padding(size_t length, size_t alignment) { - return AlignUp(length, alignment) - length; -} - // Class for managing aligned writes. Stores data in an intermediate buffer and // calls an output function with aligned data as the buffer becomes full. Any // bytes remaining in the buffer are written to the output when Flush() is @@ -61,7 +47,7 @@ class AlignedWriter { AlignedWriter& operator=(const AlignedWriter&) = delete; ~AlignedWriter() { - Flush().IgnoreError(); // TODO(b/242598609): Handle Status properly + Flush().IgnoreError(); // TODO: b/242598609 - Handle Status properly } // Writes bytes to the AlignedWriter. The output may be called if the internal |