From: David Kalnischkies Date: Fri, 12 Aug 2016 08:02:28 +0000 (+0200) Subject: ensure a good clock() value for usage and tests X-Git-Tag: 1.3_rc2~24 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/379a36f43d3f4db4afa5ad4fb6f79b89824c999c?hp=379a36f43d3f4db4afa5ad4fb6f79b89824c999c ensure a good clock() value for usage and tests We use clock() as a very cheap way of getting a "random" value, but the manpage warns that this could return -1, so we should be dealing with this. Additionally, e.g. on hurd-i386 the value increases only slowly – to slow for our fast running tests for randomness hence producing the same range in both samples, so we introduce a simple busy-wait loop (as clock is counting processor time used by the program) in the test which delays the second sample just enough making our randomness a bit more predictable. ---