]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Ensure a dynamically linked xxhash lib is >= 0.8 for XX3.
authorWayne Davison <wayne@opencoder.net>
Sun, 14 Aug 2022 17:09:34 +0000 (10:09 -0700)
committerWayne Davison <wayne@opencoder.net>
Sun, 14 Aug 2022 17:09:40 +0000 (10:09 -0700)
checksum.c
compat.c
usage.c

index 178b0f505a7091abac73ae104034a2cc83e12edd..fb8c0a099e7f7752c1eba8c061e775a956ba397f 100644 (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;
+}
index dec363a6188566053ba0a0df45120394c1502955..b46eb199c061443d8b0f4d266236ca57a1819a8e 100644 (file)
--- a/compat.c
+++ b/compat.c
@@ -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);
 
diff --git a/usage.c b/usage.c
index cbca83e3aa530b7608aeb0767b4546aff3a4248d..df033c92b5e2c1be15a00760c660d9827c41890b 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -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);