uint32_t start_offset;
} lzma_options_bcj;
+
+
+#ifdef LZMA_UNSTABLE
+/**
+ * \brief Raw ARM64 BCJ encoder
+ *
+ * This is for special use cases only.
+ *
+ * \param start_offset The lowest 32 bits of the offset in the
+ * executable being filtered. For the ARM64
+ * filter, this must be a multiple of four.
+ * For the very best results, this should also
+ * be in sync with 4096-byte page boundaries
+ * in the executable due to how ARM64's ADRP
+ * instruction works.
+ * \param buf Buffer to be filtered in place
+ * \param size Size of the buffer
+ *
+ * \return Number of bytes that were processed in `buf`. This is at most
+ * `size`. With the ARM64 filter, the return value is always
+ * a multiple of 4, and at most 3 bytes are left unfiltered.
+ *
+ * \since 5.7.1alpha
+ */
+extern LZMA_API(size_t) lzma_bcj_arm64_encode(
+ uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow;
+
+/**
+ * \brief Raw ARM64 BCJ decoder
+ *
+ * See lzma_bcj_arm64_encode().
+ *
+ * \since 5.7.1alpha
+ */
+extern LZMA_API(size_t) lzma_bcj_arm64_decode(
+ uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow;
+
+
+/**
+ * \brief Raw RISC-V BCJ encoder
+ *
+ * This is for special use cases only.
+ *
+ * \param start_offset The lowest 32 bits of the offset in the
+ * executable being filtered. For the RISC-V
+ * filter, this must be a multiple of 2.
+ * \param buf Buffer to be filtered in place
+ * \param size Size of the buffer
+ *
+ * \return Number of bytes that were processed in `buf`. This is at most
+ * `size`. With the RISC-V filter, the return value is always
+ * a multiple of 2, and at most 7 bytes are left unfiltered.
+ *
+ * \since 5.7.1alpha
+ */
+extern LZMA_API(size_t) lzma_bcj_riscv_encode(
+ uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow;
+
+/**
+ * \brief Raw RISC-V BCJ decoder
+ *
+ * See lzma_bcj_riscv_encode().
+ *
+ * \since 5.7.1alpha
+ */
+extern LZMA_API(size_t) lzma_bcj_riscv_decode(
+ uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow;
+
+
+/**
+ * \brief Raw x86 BCJ encoder
+ *
+ * This is for special use cases only.
+ *
+ * \param start_offset The lowest 32 bits of the offset in the
+ * executable being filtered. For the x86
+ * filter, all values are valid.
+ * \param buf Buffer to be filtered in place
+ * \param size Size of the buffer
+ *
+ * \return Number of bytes that were processed in `buf`. This is at most
+ * `size`. For the x86 filter, the return value is always
+ * a multiple of 1, and at most 4 bytes are left unfiltered.
+ *
+ * \since 5.7.1alpha
+ */
+extern LZMA_API(size_t) lzma_bcj_x86_encode(
+ uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow;
+
+/**
+ * \brief Raw x86 BCJ decoder
+ *
+ * See lzma_bcj_x86_encode().
+ *
+ * \since 5.7.1alpha
+ */
+extern LZMA_API(size_t) lzma_bcj_x86_decode(
+ uint32_t start_offset, uint8_t *buf, size_t size) lzma_nothrow;
+#endif
{
return arm64_coder_init(next, allocator, filters, true);
}
+
+
+extern LZMA_API(size_t)
+lzma_bcj_arm64_encode(uint32_t start_offset, uint8_t *buf, size_t size)
+{
+ // start_offset must be a multiple of four.
+ start_offset &= ~UINT32_C(3);
+ return arm64_code(NULL, start_offset, true, buf, size);
+}
#endif
{
return arm64_coder_init(next, allocator, filters, false);
}
+
+
+extern LZMA_API(size_t)
+lzma_bcj_arm64_decode(uint32_t start_offset, uint8_t *buf, size_t size)
+{
+ // start_offset must be a multiple of four.
+ start_offset &= ~UINT32_C(3);
+ return arm64_code(NULL, start_offset, false, buf, size);
+}
#endif
return lzma_simple_coder_init(next, allocator, filters,
&riscv_encode, 0, 8, 2, true);
}
+
+
+extern LZMA_API(size_t)
+lzma_bcj_riscv_encode(uint32_t start_offset, uint8_t *buf, size_t size)
+{
+ // start_offset must be a multiple of two.
+ start_offset &= ~UINT32_C(1);
+ return riscv_encode(NULL, start_offset, true, buf, size);
+}
#endif
return lzma_simple_coder_init(next, allocator, filters,
&riscv_decode, 0, 8, 2, false);
}
+
+
+extern LZMA_API(size_t)
+lzma_bcj_riscv_decode(uint32_t start_offset, uint8_t *buf, size_t size)
+{
+ // start_offset must be a multiple of two.
+ start_offset &= ~UINT32_C(1);
+ return riscv_decode(NULL, start_offset, false, buf, size);
+}
#endif
{
return x86_coder_init(next, allocator, filters, true);
}
+
+
+extern LZMA_API(size_t)
+lzma_bcj_x86_encode(uint32_t start_offset, uint8_t *buf, size_t size)
+{
+ lzma_simple_x86 simple = {
+ .prev_mask = 0,
+ .prev_pos = (uint32_t)(-5),
+ };
+
+ return x86_code(&simple, start_offset, true, buf, size);
+}
#endif
{
return x86_coder_init(next, allocator, filters, false);
}
+
+
+extern LZMA_API(size_t)
+lzma_bcj_x86_decode(uint32_t start_offset, uint8_t *buf, size_t size)
+{
+ lzma_simple_x86 simple = {
+ .prev_mask = 0,
+ .prev_pos = (uint32_t)(-5),
+ };
+
+ return x86_code(&simple, start_offset, false, buf, size);
+}
#endif