aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-10-04 22:57:12 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-10-04 22:57:12 +0300
commitebfb2c5e1f344e5c6e549b9dedaa49b0749a4a24 (patch)
tree7e2f519ad2be01b8f9c7b230f71d479d550c9ae4 /src/liblzma/common
parentAdd support for --enable-assume-ram=SIZE. (diff)
downloadxz-ebfb2c5e1f344e5c6e549b9dedaa49b0749a4a24.tar.xz
Use a tuklib module for integer handling.
This replaces bswap.h and integer.h. The tuklib module uses <byteswap.h> on GNU, <sys/endian.h> on *BSDs and <sys/byteorder.h> on Solaris, which may contain optimized code like inline assembly.
Diffstat (limited to 'src/liblzma/common')
-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
6 files changed, 10 insertions, 10 deletions
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,