]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
better seed randomization for systems with poor clock() resolutation
authorYann Collet <yann.collet.73@gmail.com>
Thu, 16 Jun 2016 11:38:10 +0000 (13:38 +0200)
committerYann Collet <yann.collet.73@gmail.com>
Thu, 16 Jun 2016 11:38:10 +0000 (13:38 +0200)
programs/fuzzer.c

index 42d3640dab36bb27d8c1cf9ba8156f819200994e..d1dfe51e81d07a3e8e2ba45ed12c49c01ae5b319 100644 (file)
@@ -847,7 +847,12 @@ int main(int argc, const char** argv)
     /* Get Seed */
     DISPLAY("Starting zstd tester (%i-bits, %s)\n", (int)(sizeof(size_t)*8), ZSTD_VERSION_STRING);
 
-    if (!seedset) seed = (U32)(clock() % 10000);
+    if (!seedset) {
+        time_t const t = time(NULL);
+        U32 const h = XXH32(&t, sizeof(t), 1);
+        seed = h % 10000;
+    }
+
     DISPLAY("Seed = %u\n", seed);
     if (proba!=FUZ_compressibility_default) DISPLAY("Compressibility : %u%%\n", proba);