From owner-freebsd-current Tue Oct 8 01:04:00 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id BAA06811 for current-outgoing; Tue, 8 Oct 1996 01:04:00 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id BAA06773; Tue, 8 Oct 1996 01:03:51 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.7.6/8.6.9) id RAA27388; Tue, 8 Oct 1996 17:56:32 +1000 Date: Tue, 8 Oct 1996 17:56:32 +1000 From: Bruce Evans Message-Id: <199610080756.RAA27388@godzilla.zeta.org.au> To: louie@TransSys.COM, terry@lambert.org Subject: Re: I plan to change random() for -current (was Re: rand() and random()) 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 Sender: owner-current@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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