mirror of https://github.com/borgbackup/borg.git
commit
d16ed301be
|
@ -0,0 +1,27 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#if defined (__SVR4) && defined (__sun)
|
||||||
|
#include <sys/isa_defs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)) || \
|
||||||
|
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || \
|
||||||
|
(defined(_BIG_ENDIAN) && defined(__SVR4) && defined(__sun))
|
||||||
|
#define BORG_BIG_ENDIAN 1
|
||||||
|
#elif (defined(BYTE_ORDER) && defined(LITTLE_ENDIAN) && (BYTE_ORDER == LITTLE_ENDIAN)) || \
|
||||||
|
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
|
||||||
|
(defined(_LITTLE_ENDIAN) && defined(__SVR4) && defined(__sun))
|
||||||
|
#define BORG_BIG_ENDIAN 0
|
||||||
|
#else
|
||||||
|
#error Unknown byte order
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if BORG_BIG_ENDIAN
|
||||||
|
#define _le32toh(x) __builtin_bswap32(x)
|
||||||
|
#define _htole32(x) __builtin_bswap32(x)
|
||||||
|
#else
|
||||||
|
#define _le32toh(x) (x)
|
||||||
|
#define _htole32(x) (x)
|
||||||
|
#endif
|
|
@ -10,29 +10,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if defined (__SVR4) && defined (__sun)
|
#include "_endian.h"
|
||||||
#include <sys/isa_defs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)) || \
|
|
||||||
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || \
|
|
||||||
(defined(_BIG_ENDIAN) && defined(__SVR4)&&defined(__sun))
|
|
||||||
#define BORG_BIG_ENDIAN 1
|
|
||||||
#elif (defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)) || \
|
|
||||||
(defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \
|
|
||||||
(defined(_LITTLE_ENDIAN) && defined(__SVR4)&&defined(__sun))
|
|
||||||
#define BORG_BIG_ENDIAN 0
|
|
||||||
#else
|
|
||||||
#error Unknown byte order
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BORG_BIG_ENDIAN
|
|
||||||
#define _le32toh(x) __builtin_bswap32(x)
|
|
||||||
#define _htole32(x) __builtin_bswap32(x)
|
|
||||||
#else
|
|
||||||
#define _le32toh(x) (x)
|
|
||||||
#define _htole32(x) (x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAGIC "BORG_IDX"
|
#define MAGIC "BORG_IDX"
|
||||||
#define MAGIC_LEN 8
|
#define MAGIC_LEN 8
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
// size_t
|
// size_t
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "../_endian.h"
|
||||||
|
|
||||||
/// compute CRC32 (Slicing-by-8 algorithm), unroll inner loop 4 times
|
/// compute CRC32 (Slicing-by-8 algorithm), unroll inner loop 4 times
|
||||||
uint32_t crc32_4x8bytes(const void* data, size_t length, uint32_t previousCrc32);
|
uint32_t crc32_4x8bytes(const void* data, size_t length, uint32_t previousCrc32);
|
||||||
|
|
||||||
|
@ -23,23 +25,6 @@ uint32_t crc32_4x8bytes(const void* data, size_t length, uint32_t previousCrc32)
|
||||||
/// zlib's CRC32 polynomial
|
/// zlib's CRC32 polynomial
|
||||||
const uint32_t Polynomial = 0xEDB88320;
|
const uint32_t Polynomial = 0xEDB88320;
|
||||||
|
|
||||||
/// swap endianness
|
|
||||||
#if defined (__SVR4) && defined (__sun)
|
|
||||||
#include <sys/isa_defs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined(BYTE_ORDER)&&(BYTE_ORDER == BIG_ENDIAN)) || \
|
|
||||||
(defined(_BIG_ENDIAN)&&defined(__SVR4)&&defined(__sun))
|
|
||||||
#define _le32toh(x) __builtin_bswap32(x)
|
|
||||||
#define BORG_BIG_ENDIAN
|
|
||||||
#elif (defined(BYTE_ORDER)&&(BYTE_ORDER == LITTLE_ENDIAN)) || \
|
|
||||||
(defined(_LITTLE_ENDIAN)&&defined(__SVR4)&&defined(__sun))
|
|
||||||
#define _le32toh(x) (x)
|
|
||||||
#define BORG_LITTLE_ENDIAN
|
|
||||||
#else
|
|
||||||
#error Unknown byte order
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////
|
||||||
// constants
|
// constants
|
||||||
|
|
||||||
|
@ -358,7 +343,7 @@ uint32_t crc32_slice_by_8(const void* data, size_t length, uint32_t previousCrc3
|
||||||
size_t unrolling;
|
size_t unrolling;
|
||||||
for (unrolling = 0; unrolling < Unroll; unrolling++)
|
for (unrolling = 0; unrolling < Unroll; unrolling++)
|
||||||
{
|
{
|
||||||
#ifdef BORG_BIG_ENDIAN
|
#if BORG_BIG_ENDIAN
|
||||||
uint32_t one = *current++ ^ _le32toh(crc);
|
uint32_t one = *current++ ^ _le32toh(crc);
|
||||||
uint32_t two = *current++;
|
uint32_t two = *current++;
|
||||||
crc = Crc32Lookup[0][ two & 0xFF] ^
|
crc = Crc32Lookup[0][ two & 0xFF] ^
|
||||||
|
|
Loading…
Reference in New Issue