Date: Tue, 8 Oct 1996 17:56:32 +1000 From: Bruce Evans <bde@zeta.org.au> To: louie@TransSys.COM, terry@lambert.org Cc: ache@nagual.ru, bde@zeta.org.au, current@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG, joerg_wunsch@uriah.heep.sax.de, wollman@lcs.mit.edu Subject: Re: I plan to change random() for -current (was Re: rand() and random()) Message-ID: <199610080756.RAA27388@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>I have to agree with Terry here about "fixing" rand()/srand(). For >better or worse, there are expections on the implementation of these >functions in a standard C libarary. For instance, in a recent >Internet Draft of a protocol specification for multicast routing >protocol (draft-ietf-idmr-pim-sm-spec-05.txt): >> 3.7 Hash Function >>.... >> 1 For each candidate RP address Ci in the Candidate-RP- >> Set, whose Group-prefix covers G, compute a value: >> Value(G,M,Ci) = >> 1103515245 ((1103515245 (G&M)+12345) XOR Ci)+ 12345 mod 2^31 If you want exactly that, use your own routine. Apparently a quality hash function isn't required. >> In standard C, this corresponds to: ^^^^^^^^^^ the usual (low quality) BSD implementation of the Standard C library functions srand() and rand() >> >> srand(G & M); >> srand(rand() ^ Ci); >> value = rand(); Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610080756.RAA27388>