aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-09-23 02:21:49 +0300
committerLasse Collin <lasse.collin@tukaani.org>2023-10-18 19:02:45 +0300
commit6828242735cbf61b93d140383336e1e51a006f2d (patch)
tree122b80b7a4069451e8b4d5d414bc849651472cd0 /src/common
parentliblzma: Set the MSVC optimization fix to only cover lzma_crc64_clmul(). (diff)
downloadxz-6828242735cbf61b93d140383336e1e51a006f2d.tar.xz
tuklib_integer: Add missing write64be and write64le fallback functions.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tuklib_integer.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/common/tuklib_integer.h b/src/common/tuklib_integer.h
index 24d9efb1..0eaca369 100644
--- a/src/common/tuklib_integer.h
+++ b/src/common/tuklib_integer.h
@@ -454,6 +454,40 @@ write32le(uint8_t *buf, uint32_t num)
#endif
+#ifndef write64be
+static inline void
+write64be(uint8_t *buf, uint64_t num)
+{
+ buf[0] = (uint8_t)(num >> 56);
+ buf[1] = (uint8_t)(num >> 48);
+ buf[2] = (uint8_t)(num >> 40);
+ buf[3] = (uint8_t)(num >> 32);
+ buf[4] = (uint8_t)(num >> 24);
+ buf[5] = (uint8_t)(num >> 16);
+ buf[6] = (uint8_t)(num >> 8);
+ buf[7] = (uint8_t)num;
+ return;
+}
+#endif
+
+
+#ifndef write64le
+static inline void
+write64le(uint8_t *buf, uint64_t num)
+{
+ buf[0] = (uint8_t)num;
+ buf[1] = (uint8_t)(num >> 8);
+ buf[2] = (uint8_t)(num >> 16);
+ buf[3] = (uint8_t)(num >> 24);
+ buf[4] = (uint8_t)(num >> 32);
+ buf[5] = (uint8_t)(num >> 40);
+ buf[6] = (uint8_t)(num >> 48);
+ buf[7] = (uint8_t)(num >> 56);
+ return;
+}
+#endif
+
+
//////////////////////////////
// Aligned reads and writes //
//////////////////////////////