On 16 Nov 2009, at 12:47, Mario Schwalbe wrote:
The test programs in the testing/ directory fail to link because arc4random(3) is not available on Linux. I found a compatibility function written for BIND that might work; the URI is:
See below for the actual code. Any objections to adding something like this to libdispatch?
Why does libdispatch has to use arc4random at all? Since, this is not a security-sensitive application but some testing code, why don't we use rand/random, that should be available on all systems?
I can't speak to the reason Apple made this design choice in the first place, but I can speak to *a* reason why this would be a problem: The rand(3) and random(3) APIs have well-defined characteristics with respect to repeatable behavior given a specific seed. If libdispatch uses srand(),rand(), it may interfere with the application's use of the same interfaces, replacing the application's seeding and consuming numbers from the sequence so that they are no longer returned to the application. Consider, for example, a simulator that accepts a seed as an argument so that the same sequence can be replayed. Robert