Ensure a dynamically linked xxhash lib is >= 0.8 for XX3.

This commit is contained in:
Wayne Davison
2022-08-14 10:09:34 -07:00
parent 9cb7529ba6
commit b7ea3fcd19
3 changed files with 37 additions and 0 deletions

View File

@@ -62,6 +62,8 @@ struct name_num_obj valid_checksums = {
int xfersum_type = 0; /* used for the file transfer checksums */
int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
static int initialized_choices = 0;
int parse_csum_name(const char *name, int len)
{
struct name_num_item *nni;
@@ -79,6 +81,9 @@ int parse_csum_name(const char *name, int len)
return CSUM_MD4_ARCHAIC;
}
if (!initialized_choices)
init_checksum_choices();
nni = get_nni_by_name(&valid_checksums, name, len);
if (!nni) {
@@ -623,3 +628,31 @@ int sum_end(char *sum)
return csum_len_for_type(cursum_type, 0);
}
void init_checksum_choices()
{
#ifdef SUPPORT_XXH3
char buf[32816];
int j;
for (j = 0; j < (int)sizeof buf; j++) {
buf[j] = ' ' + (j % 96);
}
sum_init(CSUM_XXH3_64, 0);
sum_update(buf, 32816);
sum_update(buf, 31152);
sum_update(buf, 32474);
sum_update(buf, 9322);
if (XXH3_64bits_digest(xxh3_state) != 0xadbcf16d4678d1de) {
int t, f;
struct name_num_item *nni = valid_checksums.list;
for (t = f = 0; nni[f].name; f++) {
if (nni[f].num == CSUM_XXH3_64 || nni[f].num == CSUM_XXH3_128)
continue;
if (t != f)
nni[t++] = nni[f];
}
nni[t].name = NULL;
}
#endif
initialized_choices = 1;
}

View File

@@ -523,6 +523,8 @@ static void negotiate_the_strings(int f_in, int f_out)
{
/* We send all the negotiation strings before we start to read them to help avoid a slow startup. */
init_checksum_choices();
if (!checksum_choice)
send_negotiate_str(f_out, &valid_checksums, NSTR_CHECKSUM);

View File

@@ -195,6 +195,8 @@ void print_rsync_version(enum logcode f)
print_info_flags(f);
init_checksum_choices();
rprintf(f, "Checksum list:\n");
get_default_nno_list(&valid_checksums, tmpbuf, sizeof tmpbuf, '(');
rprintf(f, " %s\n", tmpbuf);