# # Patch name: sysrandom # Patch version: 1 # Author's name: Jason Young # Author's email: doogie@forbidden-donut.anet-stl.com # Version of PennMUSH: 1.6.10p4 # Date patch made: May 1, 1997 # Author is willing to support (yes/no): no # Patch format: context diff # # # This is a contributed PennMUSH patch. Its use is subject to the # same restrictions found in PennMUSH's hdrs/copyrite.h file. # # No warranty is given for this patch. It is not necessarily going # to work on your system, with any version of PennMUSH other than # the one above, etc. # # If the author given above was willing to support the patch, you # should write to the author if you have any questions or problems. Do # *NOT* send email messages to Javelin or any PennMUSH mailing list about # this patch! # # Below this line is the author's description of the patch, # followed by the patch itself. If the patch is in context diff # format, you'll probably apply it by typing: patch < patchfile # in your top-level MUSH directory, unless instructed otherwise # below. # Replaces the fancy random routine in getrandom() with a simple call to the system's random() function. This avoids a bizarre loop problem that Doogie has experienced. - Javelin *** utils.c Mon Dec 16 10:51:13 1996 --- utils.c.doogie Wed Apr 30 23:03:45 1997 *************** *** 264,286 **** getrandom(x) int x; { ! /* In order to be perfectly anal about not introducing any further sources ! * of statistical bias, we're going to call random() until we get a number ! * less than the greatest representable multiple of x. We'll then return ! * n mod x. ! */ long n; if (x <= 0) return -1; ! do { ! n = random(); ! } while (LONG_MAX - n < x); ! /* N.B. This loop happens in randomized constant time, and pretty damn ! * fast randomized constant time too, since P(LONG_MAX - n < x) < 0.5 ! * for any x, so for any X, the average number of times we should ! * have to call random() is less than 2. ! */ ! return (n % x); } --- 264,276 ---- getrandom(x) int x; { ! /* Brutally butchered because random() is Random Enough For Me. */ ! long n; if (x <= 0) return -1; ! ! return (random() % x); }