diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-05-21 08:04:50 +1000 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-05-21 08:04:50 +1000 |
| commit | 1dce609c8ee560ec9f75961063f56cc58da84764 (patch) | |
| tree | a6355f81abd2bda0a518dd1955017da4088d21f8 /include/tinyff | |
| parent | 22b8c1286e50f96212c0a8b9d9bad70c0609fc31 (diff) | |
feat(common): add ff_write_be32 and le32 for inverse endianess functions
Diffstat (limited to 'include/tinyff')
| -rw-r--r-- | include/tinyff/common.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/tinyff/common.h b/include/tinyff/common.h index 891f9ee..1efe930 100644 --- a/include/tinyff/common.h +++ b/include/tinyff/common.h @@ -60,6 +60,21 @@ static inline uint32_t ff_le32(const uint8_t *b) { ((uint32_t)b[3] << 24); } +static inline void ff_write_be32(uint8_t *out, uint32_t v) +{ + out[0] = (v >> 24) & 0xFF; + out[1] = (v >> 16) & 0xFF; + out[2] = (v >> 8) & 0xFF; + out[3] = (v) & 0xFF; +} + +static inline void ff_write_le32(uint8_t *out, uint32_t v) +{ + out[0] = (v) & 0xFF; + out[1] = (v >> 8) & 0xFF; + out[2] = (v >> 16) & 0xFF; + out[3] = (v >> 24) & 0xFF; +} // Small stdlib helper functions static inline size_t ff_strlen(const char *str) |
