Skip to content

Commit

Permalink
Merge branch '64bithash' of https://github.com/jmacd/xdelta-devel int…
Browse files Browse the repository at this point in the history
…o 64bithash
  • Loading branch information
jmacd committed Jan 1, 2016
2 parents 5025a49 + 45a7439 commit 1d815e5
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 32 deletions.
19 changes: 12 additions & 7 deletions xdelta3/testing/checksum_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ template <typename Word>
usize_t bitsof();

template<>
usize_t bitsof<uint32_t>() {
return 32;
usize_t bitsof<unsigned int>() {
return sizeof(unsigned int) * 8;
}

template<>
usize_t bitsof<uint64_t>() {
return 64;
usize_t bitsof<unsigned long>() {
return sizeof(unsigned long) * 8;
}

template<>
usize_t bitsof<unsigned long long>() {
return sizeof(unsigned long long) * 8;
}

template <typename Word>
Expand Down Expand Up @@ -448,12 +453,12 @@ struct test_result : public test_result_base {

void print() {
if (fstats.count != count()) {
fprintf(stderr, "internal error: %d != %d\n", fstats.count, count());
fprintf(stderr, "internal error: %" W "d != %" W "d\n", fstats.count, count());
abort();
}
print_header();
printf("%-32s%d/%d 2^%" Z "\t%" Z "\t%0.4f\t%.4f\t%.4f\t%.1e\t%.2f\t"
"%" Z "\t%" Z "\n",
printf("%-32s%d/%d 2^%" W "u\t%" W "u\t%0.4f\t%.4f\t%.4f\t%.1e\t%.2f\t"
"%" W "u\t%" W "u\n",
test_name,
Checksum::cksum_size,
Checksum::cksum_skip,
Expand Down
1 change: 0 additions & 1 deletion xdelta3/xdelta3-decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ xd3_decode_input (xd3_stream *stream)

case DEC_CPYOFF:
/* Copy window offset: only if VCD_SOURCE or VCD_TARGET is set */

OFFSET_CASE(SRCORTGT (stream->dec_win_ind), stream->dec_cpyoff,
DEC_ENCLEN);

Expand Down
62 changes: 46 additions & 16 deletions xdelta3/xdelta3-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ xd3_emit_uint32_t (xd3_stream *stream, xd3_output **output, uint32_t num)
#endif /* USE_UINT32 */

#if USE_UINT64
static uint32_t
static inline uint32_t
xd3_sizeof_uint64_t (uint64_t num)
{
IF_SIZEOF64(1);
Expand All @@ -321,7 +321,7 @@ static inline int
xd3_decode_uint64_t (xd3_stream *stream, uint64_t *val)
{ DECODE_INTEGER_TYPE (stream->dec_64part, UINT64_OFLOW_MASK); }

static int
static inline int
xd3_read_uint64_t (xd3_stream *stream, const uint8_t **inpp,
const uint8_t *maxp, uint64_t *valp)
{ READ_INTEGER_TYPE (uint64_t, UINT64_OFLOW_MASK); }
Expand All @@ -336,35 +336,65 @@ xd3_emit_uint64_t (xd3_stream *stream, xd3_output **output, uint64_t num)
#if SIZEOF_USIZE_T == 4
#define USIZE_T_MAX UINT32_MAX
#define USIZE_T_MAXBLKSZ 0x80000000U
#define xd3_decode_size xd3_decode_uint32_t
#define xd3_emit_size xd3_emit_uint32_t
#define xd3_sizeof_size xd3_sizeof_uint32_t
#define xd3_read_size xd3_read_uint32_t
#define XD3_MAXSRCWINSZ (1ULL << 31)
#define xd3_large_cksum xd3_large32_cksum
#define xd3_large_cksum_update xd3_large32_cksum_update
#define xd3_hash_multiplier xd3_hash_multiplier32
#define XD3_MAXSRCWINSZ (1ULL << 31)

static inline uint32_t xd3_sizeof_size (usize_t num)
{ return xd3_sizeof_uint32_t (num); }
static inline int xd3_decode_size (xd3_stream *stream, usize_t *valp)
{ return xd3_decode_uint32_t (stream, (uint32_t*) valp); }
static inline int xd3_read_size (xd3_stream *stream, const uint8_t **inpp,
const uint8_t *maxp, usize_t *valp)
{ return xd3_read_uint32_t (stream, inpp, maxp, (uint32_t*) valp); }
#if XD3_ENCODER
static inline int xd3_emit_size (xd3_stream *stream, xd3_output **output, usize_t num)
{ return xd3_emit_uint32_t (stream, output, num); }
#endif

#elif SIZEOF_USIZE_T == 8
#define USIZE_T_MAX UINT64_MAX
#define USIZE_T_MAXBLKSZ 0x8000000000000000ULL
#define xd3_decode_size xd3_decode_uint64_t
#define xd3_emit_size xd3_emit_uint64_t
#define xd3_sizeof_size xd3_sizeof_uint64_t
#define xd3_read_size xd3_read_uint64_t
#define XD3_MAXSRCWINSZ (1ULL << 61)
#define xd3_large_cksum xd3_large64_cksum
#define xd3_large_cksum_update xd3_large64_cksum_update
#define xd3_hash_multiplier xd3_hash_multiplier64
#define XD3_MAXSRCWINSZ (1ULL << 61)

static inline uint32_t xd3_sizeof_size (usize_t num)
{ return xd3_sizeof_uint64_t (num); }
static inline int xd3_decode_size (xd3_stream *stream, usize_t *valp)
{ return xd3_decode_uint64_t (stream, (uint64_t*) valp); }
static inline int xd3_read_size (xd3_stream *stream, const uint8_t **inpp,
const uint8_t *maxp, usize_t *valp)
{ return xd3_read_uint64_t (stream, inpp, maxp, (uint64_t*) valp); }
#if XD3_ENCODER
static inline int xd3_emit_size (xd3_stream *stream, xd3_output **output, usize_t num)
{ return xd3_emit_uint64_t (stream, output, num); }
#endif

#endif /* SIZEOF_USIZE_T */

#if SIZEOF_XOFF_T == 4
#define XOFF_T_MAX UINT32_MAX
#define xd3_decode_offset xd3_decode_uint32_t
#define xd3_emit_offset xd3_emit_uint32_t

static inline int xd3_decode_offset (xd3_stream *stream, xoff_t *valp)
{ return xd3_decode_uint32_t (stream, (uint32_t*) valp); }
#if XD3_ENCODER
static inline int xd3_emit_offset (xd3_stream *stream, xd3_output **output, xoff_t num)
{ return xd3_emit_uint32_t (stream, output, num); }
#endif

#elif SIZEOF_XOFF_T == 8
#define XOFF_T_MAX UINT64_MAX
#define xd3_decode_offset xd3_decode_uint64_t
#define xd3_emit_offset xd3_emit_uint64_t

static inline int xd3_decode_offset (xd3_stream *stream, xoff_t *valp)
{ return xd3_decode_uint64_t (stream, (uint64_t*) valp); }
#if XD3_ENCODER
static inline int xd3_emit_offset (xd3_stream *stream, xd3_output **output, xoff_t num)
{ return xd3_emit_uint64_t (stream, output, num); }
#endif

#endif

#define USIZE_T_OVERFLOW(a,b) ((USIZE_T_MAX - (usize_t) (a)) < (usize_t) (b))
Expand Down
9 changes: 9 additions & 0 deletions xdelta3/xdelta3-main.h
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,15 @@ main_set_secondary_flags (xd3_config *config)
}
}

if (option_verbose)
{
XPR(NT "secondary compression: %s\n",
(config->flags | XD3_SEC_LZMA) ? "lzma" :
((config->flags | XD3_SEC_FGK) ? "fgk" :
((config->flags | XD3_SEC_DJW) ? "djw" :
"none")));
}

return 0;
}

Expand Down
14 changes: 6 additions & 8 deletions xdelta3/xdelta3.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,20 @@

#ifndef WINVER
#if XD3_USE_LARGEFILE64
/* 64 bit file offsets: uses GetFileSizeEx and SetFilePointerEx.
* requires Win2000 or newer version of WinNT */
/* 64 bit file offsets: uses GetFileSizeEx and SetFilePointerEx. */
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#else /* xoff_t is 32bit */
/* 32 bit (DWORD) file offsets: uses GetFileSize and
* SetFilePointer. compatible with win9x-me and WinNT4 */
/* 32 bit file offsets: uses GetFileSize and SetFilePointer. */
#define WINVER 0x0400
#define _WIN32_WINNT 0x0400
#endif /* if XD3_USE_LARGEFILE64 */
#endif /* ifndef WINVER */

#include <windows.h>

/* _MSV_VER is defined by Microsoft tools, not by mingw32 */
/* _MSV_VER is defined by Microsoft tools, not by Mingw32 */
#ifdef _MSC_VER
/*#define inline*/
typedef signed int ssize_t;
#if _MSC_VER < 1600
typedef unsigned char uint8_t;
Expand All @@ -150,15 +147,16 @@ typedef ULONGLONG uint64_t;
#include <stdint.h>
#endif /* _MSC_VER < 1600 */
#else /* _MSC_VER not defined */
/* mingw32, lcc and watcom provide a proper header */
/* Mingw32 */
#include <stdint.h>
#endif /* _MSC_VER defined */

#endif /* _WIN32 defined */

/* Settings based on the size of xoff_t (32 vs 64 file offsets) */
#if XD3_USE_LARGEFILE64
/* xoff_t is a 64-bit type */
#define __USE_FILE_OFFSET64 1 /* GLIBC: for 64bit fileops, ... ? */
#define __USE_FILE_OFFSET64 1 /* GLIBC: for 64bit fileops. */

#ifndef _LARGEFILE_SOURCE
#define _LARGEFILE_SOURCE
Expand Down

0 comments on commit 1d815e5

Please sign in to comment.