Compatibility with xxHash 0.7.3

parent b7392da0
...@@ -5830,8 +5830,10 @@ main(int argc, char **argv) ...@@ -5830,8 +5830,10 @@ main(int argc, char **argv)
l = FH_SHA256 + 1; l = FH_SHA256 + 1;
#endif #endif
for (hash = FH_SHA256; hash < l; hash++) for (hash = FH_SHA256; hash < l; hash++) {
t_cache(hash); if (fh_name[hash])
t_cache(hash);
}
printf("OK\n"); printf("OK\n");
return (0); return (0);
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#ifdef HAVE_XXHASH_H #ifdef HAVE_XXHASH_H
#define MIN_XXH_VERSION 800 #define MIN_XXH_VERSION 703
#include <xxhash.h> #include <xxhash.h>
#if XXH_VERSION_NUMBER < MIN_XXH_VERSION #if XXH_VERSION_NUMBER < MIN_XXH_VERSION
#error "xxhash version unsupported" #error "xxhash version unsupported"
...@@ -92,12 +92,14 @@ fh(uint8_t fht, union fh *fhh, const void *p, size_t l) ...@@ -92,12 +92,14 @@ fh(uint8_t fht, union fh *fhh, const void *p, size_t l)
} }
} }
#if XXH_VERSION_NUMBER >= 800
static inline int static inline int
xxh3_128_cmp(const uint8_t v[16], const void *p, size_t l) xxh3_128_cmp(const uint8_t v[16], const void *p, size_t l)
{ {
XXH128_hash_t h = XXH3_128bits(p, l); XXH128_hash_t h = XXH3_128bits(p, l);
return (memcmp(v, &h, sizeof h)); return (memcmp(v, &h, sizeof h));
} }
#endif
#define FH_C_SHA256(v, p, l) sha256cmp(v, p, l) #define FH_C_SHA256(v, p, l) sha256cmp(v, p, l)
#define FH_C_XXH32(v, p, l) ((v) != XXH32(p, l, 0)) #define FH_C_XXH32(v, p, l) ((v) != XXH32(p, l, 0))
......
...@@ -675,6 +675,8 @@ run(const struct tc *tc, void *t_priv) ...@@ -675,6 +675,8 @@ run(const struct tc *tc, void *t_priv)
#endif #endif
for (h = 1; h < l; h++) { for (h = 1; h < l; h++) {
if (fh_name[h] == NULL)
continue;
r = runh(tc, t_priv, h); r = runh(tc, t_priv, h);
if (r != 0) if (r != 0)
break; break;
...@@ -752,6 +754,10 @@ main(int argc, char **argv) ...@@ -752,6 +754,10 @@ main(int argc, char **argv)
double t; double t;
const double tmax = 1; const double tmax = 1;
void *priv = NULL; void *priv = NULL;
uint8_t fht[2];
fht[0] = fh_name[FH_XXH3_128] ? FH_XXH3_128 : FH_XXH32;
fht[1] = fh_name[FH_XXH3_64] ? FH_XXH3_64 : FH_XXH32;
if (argc == 2 && *argv[1] != '-') if (argc == 2 && *argv[1] != '-')
filename = argv[1]; filename = argv[1];
...@@ -767,7 +773,7 @@ main(int argc, char **argv) ...@@ -767,7 +773,7 @@ main(int argc, char **argv)
// panic on "nothing must be resurrected" // panic on "nothing must be resurrected"
AZ(runh(&tc_resur_add, &priv, FH_SHA256)); AZ(runh(&tc_resur_add, &priv, FH_SHA256));
#ifdef HAVE_XXHASH_H #ifdef HAVE_XXHASH_H
AZ(runh(&tc_resur_del, &priv, FH_XXH3_128)); AZ(runh(&tc_resur_del, &priv, FH_XXH32));
#else #else
AZ(runh(&tc_resur_del, &priv, FH_SHA256)); AZ(runh(&tc_resur_del, &priv, FH_SHA256));
#endif #endif
...@@ -775,9 +781,9 @@ main(int argc, char **argv) ...@@ -775,9 +781,9 @@ main(int argc, char **argv)
// same but keep across a close/open // same but keep across a close/open
#ifdef HAVE_XXHASH_H #ifdef HAVE_XXHASH_H
AZ(runh(&tc_resur_add, &priv, FH_XXH3_128)); AZ(runh(&tc_resur_add, &priv, fht[0]));
AZ(runh(&tc_adddel_keep, NULL, FH_XXH32)); AZ(runh(&tc_adddel_keep, NULL, FH_SHA256));
AZ(runh(&tc_resur_del, &priv, FH_XXH3_64)); AZ(runh(&tc_resur_del, &priv, fht[1]));
#else #else
AZ(runh(&tc_resur_add, &priv, FH_SHA256)); AZ(runh(&tc_resur_add, &priv, FH_SHA256));
AZ(runh(&tc_adddel_keep, NULL, FH_SHA256)); AZ(runh(&tc_adddel_keep, NULL, FH_SHA256));
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
* electronic and paper mail. * electronic and paper mail.
*/ */
#ifdef HAVE_XXHASH_H
#include <xxhash.h>
#endif
struct stvfe_tune { struct stvfe_tune {
unsigned magic; unsigned magic;
#define STVFE_TUNE_MAGIC 0x92d8d31c #define STVFE_TUNE_MAGIC 0x92d8d31c
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
FH(SHA256, sha256, FSHA256_LEN) FH(SHA256, sha256, FSHA256_LEN)
#ifdef HAVE_XXHASH_H #ifdef HAVE_XXHASH_H
FH(XXH32, xxh32, sizeof(XXH32_hash_t)) FH(XXH32, xxh32, sizeof(XXH32_hash_t))
#if XXH_VERSION_NUMBER >= 800
FH(XXH3_64, xxh3_64, sizeof(XXH64_hash_t)) FH(XXH3_64, xxh3_64, sizeof(XXH64_hash_t))
FH(XXH3_128, xxh3_128, sizeof(XXH128_hash_t)) FH(XXH3_128, xxh3_128, sizeof(XXH128_hash_t))
#endif #endif
#endif
#undef FH #undef FH
...@@ -54,8 +54,13 @@ TUNE(unsigned, io_batch_min, 8, 1, UINT_MAX); ...@@ -54,8 +54,13 @@ TUNE(unsigned, io_batch_min, 8, 1, UINT_MAX);
TUNE(unsigned, io_batch_max, 512, 1, UINT_MAX); TUNE(unsigned, io_batch_max, 512, 1, UINT_MAX);
TUNE(int8_t, cram, 1, -64, 64); TUNE(int8_t, cram, 1, -64, 64);
#ifdef HAVE_XXHASH_H #ifdef HAVE_XXHASH_H
#if XXH_VERSION_NUMBER >= 800
TUNEH(uint8_t, hash_obj, FH_XXH3_64, FH_NONE + 1, FH_LIM - 1); TUNEH(uint8_t, hash_obj, FH_XXH3_64, FH_NONE + 1, FH_LIM - 1);
TUNEH(uint8_t, hash_log, FH_XXH3_64, FH_NONE + 1, FH_LIM - 1); TUNEH(uint8_t, hash_log, FH_XXH3_64, FH_NONE + 1, FH_LIM - 1);
#else
TUNEH(uint8_t, hash_obj, FH_XXH32, FH_NONE + 1, FH_XXH32);
TUNEH(uint8_t, hash_log, FH_XXH32, FH_NONE + 1, FH_XXH32);
#endif
#else #else
TUNEH(uint8_t, hash_obj, FH_SHA256, FH_NONE + 1, FH_LIM - 1); TUNEH(uint8_t, hash_obj, FH_SHA256, FH_NONE + 1, FH_LIM - 1);
TUNEH(uint8_t, hash_log, FH_SHA256, FH_NONE + 1, FH_LIM - 1); TUNEH(uint8_t, hash_log, FH_SHA256, FH_NONE + 1, FH_LIM - 1);
......
...@@ -722,7 +722,9 @@ fellow storage can be fine tuned: ...@@ -722,7 +722,9 @@ fellow storage can be fine tuned:
* *hash_obj*, *hash_log* * *hash_obj*, *hash_log*
- value: one of ``sha256``, ``xxh32``, ``xxh3_64``, ``xxh3_128`` - value: one of ``sha256``, ``xxh32``, ``xxh3_64``, ``xxh3_128``
- default: ``xxh3_64`` if xxhash has been compiled in, ``sha256`` otherwise - default: ``xxh3_64`` if xxhash > 0.8.0 has been compiled in,
``xxh32`` if xxhash > 0.7.3 has been compiled in,
``sha256`` otherwise
*hash_obj* specifies the hash algorithm to ensure data integrity of *hash_obj* specifies the hash algorithm to ensure data integrity of
objects and their data. objects and their data.
......
...@@ -660,7 +660,9 @@ fellow storage can be fine tuned: ...@@ -660,7 +660,9 @@ fellow storage can be fine tuned:
* *hash_obj*, *hash_log* * *hash_obj*, *hash_log*
- value: one of ``sha256``, ``xxh32``, ``xxh3_64``, ``xxh3_128`` - value: one of ``sha256``, ``xxh32``, ``xxh3_64``, ``xxh3_128``
- default: ``xxh3_64`` if xxhash has been compiled in, ``sha256`` otherwise - default: ``xxh3_64`` if xxhash > 0.8.0 has been compiled in,
``xxh32`` if xxhash > 0.7.3 has been compiled in,
``sha256`` otherwise
*hash_obj* specifies the hash algorithm to ensure data integrity of *hash_obj* specifies the hash algorithm to ensure data integrity of
objects and their data. objects and their data.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment