aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma')
-rw-r--r--src/liblzma/check/check.c4
-rw-r--r--src/liblzma/check/crc32_fast.c4
-rw-r--r--src/liblzma/check/crc32_tablegen.c8
-rw-r--r--src/liblzma/check/crc64_fast.c4
-rw-r--r--src/liblzma/check/crc64_tablegen.c8
-rw-r--r--src/liblzma/check/crc_macros.h2
-rw-r--r--src/liblzma/check/sha256.c18
-rw-r--r--src/liblzma/common/alone_encoder.c2
-rw-r--r--src/liblzma/common/block_header_decoder.c2
-rw-r--r--src/liblzma/common/block_header_encoder.c2
-rw-r--r--src/liblzma/common/common.h2
-rw-r--r--src/liblzma/common/stream_flags_decoder.c6
-rw-r--r--src/liblzma/common/stream_flags_encoder.c6
-rw-r--r--src/liblzma/lz/lz_encoder_hash.h2
-rw-r--r--src/liblzma/lzma/lzma_decoder.c2
-rw-r--r--src/liblzma/lzma/lzma_encoder.c2
-rw-r--r--src/liblzma/lzma/lzma_encoder_private.h2
-rw-r--r--src/liblzma/simple/simple_decoder.c2
-rw-r--r--src/liblzma/simple/simple_encoder.c2
19 files changed, 29 insertions, 51 deletions
diff --git a/src/liblzma/check/check.c b/src/liblzma/check/check.c
index ba8622e6..428ddaeb 100644
--- a/src/liblzma/check/check.c
+++ b/src/liblzma/check/check.c
@@ -150,13 +150,13 @@ lzma_check_finish(lzma_check_state *check, lzma_check type)
switch (type) {
#ifdef HAVE_CHECK_CRC32
case LZMA_CHECK_CRC32:
- check->buffer.u32[0] = integer_le_32(check->state.crc32);
+ check->buffer.u32[0] = conv32le(check->state.crc32);
break;
#endif
#ifdef HAVE_CHECK_CRC64
case LZMA_CHECK_CRC64:
- check->buffer.u64[0] = integer_le_64(check->state.crc64);
+ check->buffer.u64[0] = conv64le(check->state.crc64);
break;
#endif
diff --git a/src/liblzma/check/crc32_fast.c b/src/liblzma/check/crc32_fast.c
index a308eff5..49dc31f2 100644
--- a/src/liblzma/check/crc32_fast.c
+++ b/src/liblzma/check/crc32_fast.c
@@ -29,7 +29,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
crc = ~crc;
#ifdef WORDS_BIGENDIAN
- crc = bswap_32(crc);
+ crc = bswap32(crc);
#endif
if (size > 8) {
@@ -75,7 +75,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
#ifdef WORDS_BIGENDIAN
- crc = bswap_32(crc);
+ crc = bswap32(crc);
#endif
return ~crc;
diff --git a/src/liblzma/check/crc32_tablegen.c b/src/liblzma/check/crc32_tablegen.c
index 56bc5c7f..31a4d275 100644
--- a/src/liblzma/check/crc32_tablegen.c
+++ b/src/liblzma/check/crc32_tablegen.c
@@ -14,12 +14,8 @@
//
///////////////////////////////////////////////////////////////////////////////
-#include <inttypes.h>
#include <stdio.h>
-
-#ifdef WORDS_BIGENDIAN
-# include "../../common/bswap.h"
-#endif
+#include "../../common/tuklib_integer.h"
static uint32_t crc32_table[8][256];
@@ -48,7 +44,7 @@ init_crc32_table(void)
#ifdef WORDS_BIGENDIAN
for (size_t s = 0; s < 8; ++s)
for (size_t b = 0; b < 256; ++b)
- crc32_table[s][b] = bswap_32(crc32_table[s][b]);
+ crc32_table[s][b] = bswap32(crc32_table[s][b]);
#endif
return;
diff --git a/src/liblzma/check/crc64_fast.c b/src/liblzma/check/crc64_fast.c
index 25557264..e42fc3dc 100644
--- a/src/liblzma/check/crc64_fast.c
+++ b/src/liblzma/check/crc64_fast.c
@@ -32,7 +32,7 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
crc = ~crc;
#ifdef WORDS_BIGENDIAN
- crc = bswap_64(crc);
+ crc = bswap64(crc);
#endif
if (size > 4) {
@@ -64,7 +64,7 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
#ifdef WORDS_BIGENDIAN
- crc = bswap_64(crc);
+ crc = bswap64(crc);
#endif
return ~crc;
diff --git a/src/liblzma/check/crc64_tablegen.c b/src/liblzma/check/crc64_tablegen.c
index 92b9a7da..fddaa7ed 100644
--- a/src/liblzma/check/crc64_tablegen.c
+++ b/src/liblzma/check/crc64_tablegen.c
@@ -13,12 +13,8 @@
//
///////////////////////////////////////////////////////////////////////////////
-#include <inttypes.h>
#include <stdio.h>
-
-#ifdef WORDS_BIGENDIAN
-# include "../../common/bswap.h"
-#endif
+#include "../../common/tuklib_integer.h"
static uint64_t crc64_table[4][256];
@@ -47,7 +43,7 @@ init_crc64_table(void)
#ifdef WORDS_BIGENDIAN
for (size_t s = 0; s < 4; ++s)
for (size_t b = 0; b < 256; ++b)
- crc64_table[s][b] = bswap_64(crc64_table[s][b]);
+ crc64_table[s][b] = bswap64(crc64_table[s][b]);
#endif
return;
diff --git a/src/liblzma/check/crc_macros.h b/src/liblzma/check/crc_macros.h
index 9e2c0303..a7c21b76 100644
--- a/src/liblzma/check/crc_macros.h
+++ b/src/liblzma/check/crc_macros.h
@@ -11,8 +11,6 @@
///////////////////////////////////////////////////////////////////////////////
#ifdef WORDS_BIGENDIAN
-# include "../../common/bswap.h"
-
# define A(x) ((x) >> 24)
# define B(x) (((x) >> 16) & 0xFF)
# define C(x) (((x) >> 8) & 0xFF)
diff --git a/src/liblzma/check/sha256.c b/src/liblzma/check/sha256.c
index 6053a51b..04231dba 100644
--- a/src/liblzma/check/sha256.c
+++ b/src/liblzma/check/sha256.c
@@ -29,10 +29,6 @@
#include "check.h"
-#ifndef WORDS_BIGENDIAN
-# include "../../common/bswap.h"
-#endif
-
// At least on x86, GCC is able to optimize this to a rotate instruction.
#define rotr_32(num, amount) ((num) >> (amount) | (num) << (32 - (amount)))
@@ -123,7 +119,7 @@ process(lzma_check_state *check)
uint32_t data[16];
for (size_t i = 0; i < 16; ++i)
- data[i] = bswap_32(check->buffer.u32[i]);
+ data[i] = bswap32(check->buffer.u32[i]);
transform(check->state.sha256.state, data);
#endif
@@ -194,20 +190,12 @@ lzma_sha256_finish(lzma_check_state *check)
// Convert the message size from bytes to bits.
check->state.sha256.size *= 8;
-#ifdef WORDS_BIGENDIAN
- check->buffer.u64[(64 - 8) / 8] = check->state.sha256.size;
-#else
- check->buffer.u64[(64 - 8) / 8] = bswap_64(check->state.sha256.size);
-#endif
+ check->buffer.u64[(64 - 8) / 8] = conv64be(check->state.sha256.size);
process(check);
for (size_t i = 0; i < 8; ++i)
-#ifdef WORDS_BIGENDIAN
- check->buffer.u32[i] = check->state.sha256.state[i];
-#else
- check->buffer.u32[i] = bswap_32(check->state.sha256.state[i]);
-#endif
+ check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);
return;
}
diff --git a/src/liblzma/common/alone_encoder.c b/src/liblzma/common/alone_encoder.c
index 68c9505d..d8c0170f 100644
--- a/src/liblzma/common/alone_encoder.c
+++ b/src/liblzma/common/alone_encoder.c
@@ -116,7 +116,7 @@ alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
if (d != UINT32_MAX)
++d;
- integer_write_32(next->coder->header + 1, d);
+ unaligned_write32le(next->coder->header + 1, d);
// - Uncompressed size (always unknown and using EOPM)
memset(next->coder->header + 1 + 4, 0xFF, 8);
diff --git a/src/liblzma/common/block_header_decoder.c b/src/liblzma/common/block_header_decoder.c
index 868f71b2..2c9573ee 100644
--- a/src/liblzma/common/block_header_decoder.c
+++ b/src/liblzma/common/block_header_decoder.c
@@ -59,7 +59,7 @@ lzma_block_header_decode(lzma_block *block,
const size_t in_size = block->header_size - 4;
// Verify CRC32
- if (lzma_crc32(in, in_size, 0) != integer_read_32(in + in_size))
+ if (lzma_crc32(in, in_size, 0) != unaligned_read32le(in + in_size))
return LZMA_DATA_ERROR;
// Check for unsupported flags.
diff --git a/src/liblzma/common/block_header_encoder.c b/src/liblzma/common/block_header_encoder.c
index bc1a10f8..79dafb80 100644
--- a/src/liblzma/common/block_header_encoder.c
+++ b/src/liblzma/common/block_header_encoder.c
@@ -126,7 +126,7 @@ lzma_block_header_encode(const lzma_block *block, uint8_t *out)
memzero(out + out_pos, out_size - out_pos);
// CRC32
- integer_write_32(out + out_size, lzma_crc32(out, out_size, 0));
+ unaligned_write32le(out + out_size, lzma_crc32(out, out_size, 0));
return LZMA_OK;
}
diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h
index d794cb30..81f51421 100644
--- a/src/liblzma/common/common.h
+++ b/src/liblzma/common/common.h
@@ -15,7 +15,7 @@
#include "sysdefs.h"
#include "mythread.h"
-#include "integer.h"
+#include "tuklib_integer.h"
#if defined(_WIN32) || defined(__CYGWIN__)
# ifdef DLL_EXPORT
diff --git a/src/liblzma/common/stream_flags_decoder.c b/src/liblzma/common/stream_flags_decoder.c
index 3dbbbcf4..1bc2f97c 100644
--- a/src/liblzma/common/stream_flags_decoder.c
+++ b/src/liblzma/common/stream_flags_decoder.c
@@ -38,7 +38,7 @@ lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in)
// and unsupported files.
const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic),
LZMA_STREAM_FLAGS_SIZE, 0);
- if (crc != integer_read_32(in + sizeof(lzma_header_magic)
+ if (crc != unaligned_read32le(in + sizeof(lzma_header_magic)
+ LZMA_STREAM_FLAGS_SIZE))
return LZMA_DATA_ERROR;
@@ -67,7 +67,7 @@ lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in)
// CRC32
const uint32_t crc = lzma_crc32(in + sizeof(uint32_t),
sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0);
- if (crc != integer_read_32(in))
+ if (crc != unaligned_read32le(in))
return LZMA_DATA_ERROR;
// Stream Flags
@@ -75,7 +75,7 @@ lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in)
return LZMA_OPTIONS_ERROR;
// Backward Size
- options->backward_size = integer_read_32(in + sizeof(uint32_t));
+ options->backward_size = unaligned_read32le(in + sizeof(uint32_t));
options->backward_size = (options->backward_size + 1) * 4;
return LZMA_OK;
diff --git a/src/liblzma/common/stream_flags_encoder.c b/src/liblzma/common/stream_flags_encoder.c
index ecbd0f13..4e717159 100644
--- a/src/liblzma/common/stream_flags_encoder.c
+++ b/src/liblzma/common/stream_flags_encoder.c
@@ -46,7 +46,7 @@ lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)
const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic),
LZMA_STREAM_FLAGS_SIZE, 0);
- integer_write_32(out + sizeof(lzma_header_magic)
+ unaligned_write32le(out + sizeof(lzma_header_magic)
+ LZMA_STREAM_FLAGS_SIZE, crc);
return LZMA_OK;
@@ -66,7 +66,7 @@ lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)
if (!is_backward_size_valid(options))
return LZMA_PROG_ERROR;
- integer_write_32(out + 4, options->backward_size / 4 - 1);
+ unaligned_write32le(out + 4, options->backward_size / 4 - 1);
// Stream Flags
if (stream_flags_encode(options, out + 2 * 4))
@@ -76,7 +76,7 @@ lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)
const uint32_t crc = lzma_crc32(
out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0);
- integer_write_32(out, crc);
+ unaligned_write32le(out, crc);
// Magic
memcpy(out + 2 * 4 + LZMA_STREAM_FLAGS_SIZE,
diff --git a/src/liblzma/lz/lz_encoder_hash.h b/src/liblzma/lz/lz_encoder_hash.h
index 884c27b9..c398d7d0 100644
--- a/src/liblzma/lz/lz_encoder_hash.h
+++ b/src/liblzma/lz/lz_encoder_hash.h
@@ -37,7 +37,7 @@
#define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE)
// Endianness doesn't matter in hash_2_calc() (no effect on the output).
-#ifdef HAVE_FAST_UNALIGNED_ACCESS
+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
# define hash_2_calc() \
const uint32_t hash_value = *(const uint16_t *)(cur);
#else
diff --git a/src/liblzma/lzma/lzma_decoder.c b/src/liblzma/lzma/lzma_decoder.c
index a013a62b..92c127f1 100644
--- a/src/liblzma/lzma/lzma_decoder.c
+++ b/src/liblzma/lzma/lzma_decoder.c
@@ -1042,7 +1042,7 @@ lzma_lzma_props_decode(void **options, lzma_allocator *allocator,
// All dictionary sizes are accepted, including zero. LZ decoder
// will automatically use a dictionary at least a few KiB even if
// a smaller dictionary is requested.
- opt->dict_size = integer_read_32(props + 1);
+ opt->dict_size = unaligned_read32le(props + 1);
opt->preset_dict = NULL;
opt->preset_dict_size = 0;
diff --git a/src/liblzma/lzma/lzma_encoder.c b/src/liblzma/lzma/lzma_encoder.c
index e9836978..0fe992d5 100644
--- a/src/liblzma/lzma/lzma_encoder.c
+++ b/src/liblzma/lzma/lzma_encoder.c
@@ -661,7 +661,7 @@ lzma_lzma_props_encode(const void *options, uint8_t *out)
if (lzma_lzma_lclppb_encode(opt, out))
return LZMA_PROG_ERROR;
- integer_write_32(out + 1, opt->dict_size);
+ unaligned_write32le(out + 1, opt->dict_size);
return LZMA_OK;
}
diff --git a/src/liblzma/lzma/lzma_encoder_private.h b/src/liblzma/lzma/lzma_encoder_private.h
index 017f58bd..3895de2d 100644
--- a/src/liblzma/lzma/lzma_encoder_private.h
+++ b/src/liblzma/lzma/lzma_encoder_private.h
@@ -24,7 +24,7 @@
// needed in lzma_lzma_optimum_*() to test if the match is at least
// MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no
// reason to not use it when it is supported.
-#ifdef HAVE_FAST_UNALIGNED_ACCESS
+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
# define not_equal_16(a, b) \
(*(const uint16_t *)(a) != *(const uint16_t *)(b))
#else
diff --git a/src/liblzma/simple/simple_decoder.c b/src/liblzma/simple/simple_decoder.c
index 9be1bfef..0beccd32 100644
--- a/src/liblzma/simple/simple_decoder.c
+++ b/src/liblzma/simple/simple_decoder.c
@@ -28,7 +28,7 @@ lzma_simple_props_decode(void **options, lzma_allocator *allocator,
if (opt == NULL)
return LZMA_MEM_ERROR;
- opt->start_offset = integer_read_32(props);
+ opt->start_offset = unaligned_read32le(props);
// Don't leave an options structure allocated if start_offset is zero.
if (opt->start_offset == 0)
diff --git a/src/liblzma/simple/simple_encoder.c b/src/liblzma/simple/simple_encoder.c
index 1ceabd1f..8aa463be 100644
--- a/src/liblzma/simple/simple_encoder.c
+++ b/src/liblzma/simple/simple_encoder.c
@@ -32,7 +32,7 @@ lzma_simple_props_encode(const void *options, uint8_t *out)
if (opt == NULL || opt->start_offset == 0)
return LZMA_OK;
- integer_write_32(out, opt->start_offset);
+ unaligned_write32le(out, opt->start_offset);
return LZMA_OK;
}