aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/check
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma/check')
-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
7 files changed, 13 insertions, 35 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;
}