diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-10-10 20:21:41 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-10-10 20:21:41 +0000 |
commit | da51482d4777ad7b2900fa5fbeb87df047f50f02 (patch) | |
tree | 41ae56a55594dc68d255a57d1cf3ade60ada1037 /sys | |
parent | d08bba148ce6d2bc797cefbe3915b386dd8e3820 (diff) |
Use the MI random() for all cases; no need for a MD version since it
has never been performance sensitive.
Running on all platforms, discussed with millert and kettenis, ok toby
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/conf/files.i386 | 3 | ||||
-rw-r--r-- | sys/arch/i386/i386/random.s | 64 | ||||
-rw-r--r-- | sys/arch/solbourne/solbourne/locore.s | 54 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/locore.s | 54 | ||||
-rw-r--r-- | sys/arch/vax/conf/files.vax | 3 | ||||
-rw-r--r-- | sys/arch/vax/vax/random.s | 105 | ||||
-rw-r--r-- | sys/conf/files | 6 | ||||
-rw-r--r-- | sys/lib/libkern/arch/sparc/random.S | 1 |
8 files changed, 7 insertions, 283 deletions
diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index 2eb74d13a7c..21b51d2a205 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $OpenBSD: files.i386,v 1.182 2008/07/08 05:22:00 dlg Exp $ +# $OpenBSD: files.i386,v 1.183 2008/10/10 20:21:38 deraadt Exp $ # # new style config file for i386 architecture # @@ -35,7 +35,6 @@ file arch/i386/i386/powernow-k7.c !small_kernel file arch/i386/i386/powernow-k8.c !small_kernel file arch/i386/i386/process_machdep.c file arch/i386/i386/procfs_machdep.c procfs -file arch/i386/i386/random.s file arch/i386/i386/sys_machdep.c file arch/i386/i386/trap.c file arch/i386/i386/vm_machdep.c diff --git a/sys/arch/i386/i386/random.s b/sys/arch/i386/i386/random.s deleted file mode 100644 index c40bad195b8..00000000000 --- a/sys/arch/i386/i386/random.s +++ /dev/null @@ -1,64 +0,0 @@ -/* $OpenBSD: random.s,v 1.4 2003/04/17 03:42:14 drahn Exp $ */ -/* $NetBSD: random.s,v 1.5 1995/01/15 23:20:33 mycroft Exp $ */ - -/* - * Copyright (c) 1995 Charles Hannum. - * Copyright (c) 1990,1993 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Here is a very good random number generator. This implementation is - * based on ``Two Fast Implementations of the "Minimal Standard" Random - * Number Generator'', David G. Carta, Communications of the ACM, Jan 1990, - * Vol 33 No 1. Do NOT modify this code unless you have a very thorough - * understanding of the algorithm. It's trickier than you think. If - * you do change it, make sure that its 10,000'th invocation returns - * 1043618065. - * - * Here is easier-to-decipher pseudocode: - * - * p = (16807*seed)<30:0> # e.g., the low 31 bits of the product - * q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32 - * if (p + q < 2^31) - * seed = p + q - * else - * seed = ((p + q) & (2^31 - 1)) + 1 - * return (seed); - * - * The result is in (0,2^31), e.g., it's always positive. - */ -#include <machine/asm.h> - - .data - .globl _C_LABEL(_randseed) -_C_LABEL(_randseed): - .long 1 - .text -ENTRY(random) - movl $16807,%eax - imull _C_LABEL(_randseed) - shld $1,%eax,%edx - andl $0x7fffffff,%eax - addl %edx,%eax - js 1f - movl %eax,_C_LABEL(_randseed) - ret -1: - subl $0x7fffffff,%eax - movl %eax,_C_LABEL(_randseed) - ret diff --git a/sys/arch/solbourne/solbourne/locore.s b/sys/arch/solbourne/solbourne/locore.s index 749c80559d0..442798dcf92 100644 --- a/sys/arch/solbourne/solbourne/locore.s +++ b/sys/arch/solbourne/solbourne/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.12 2008/07/28 19:08:46 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.13 2008/10/10 20:21:39 deraadt Exp $ */ /* OpenBSD: locore.s,v 1.64 2005/04/17 18:47:50 miod Exp */ /* @@ -4610,58 +4610,6 @@ Lumul_shortway: addcc %g0, %g0, %o1 ! %o1 = zero, and set Z /* - * Here is a very good random number generator. This implementation is - * based on ``Two Fast Implementations of the "Minimal Standard" Random - * Number Generator", David G. Carta, Communications of the ACM, Jan 1990, - * Vol 33 No 1. - */ - .data - .globl _C_LABEL(_randseed) -_C_LABEL(_randseed): - .word 1 - .text -ENTRY(random) - sethi %hi(16807), %o1 - wr %o1, %lo(16807), %y - sethi %hi(_C_LABEL(_randseed)), %g1 - ld [%g1 + %lo(_C_LABEL(_randseed))], %o0 - andcc %g0, 0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %g0, %o2 - rd %y, %o3 - srl %o2, 16, %o1 - set 0xffff, %o4 - and %o4, %o2, %o0 - sll %o0, 15, %o0 - srl %o3, 17, %o3 - or %o3, %o0, %o0 - addcc %o0, %o1, %o0 - bneg 1f - sethi %hi(0x7fffffff), %o1 - retl - st %o0, [%g1 + %lo(_C_LABEL(_randseed))] -1: - or %o1, %lo(0x7fffffff), %o1 - add %o0, 1, %o0 - and %o1, %o0, %o0 - retl - st %o0, [%g1 + %lo(_C_LABEL(_randseed))] - -/* * delay function * * void delay(N) -- delay N microseconds diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s index 7b996396ca4..5278ac381df 100644 --- a/sys/arch/sparc/sparc/locore.s +++ b/sys/arch/sparc/sparc/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.81 2008/07/28 19:08:46 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.82 2008/10/10 20:21:39 deraadt Exp $ */ /* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */ /* @@ -5920,58 +5920,6 @@ Lumul_shortway: addcc %g0, %g0, %o1 ! %o1 = zero, and set Z /* - * Here is a very good random number generator. This implementation is - * based on ``Two Fast Implementations of the "Minimal Standard" Random - * Number Generator", David G. Carta, Communications of the ACM, Jan 1990, - * Vol 33 No 1. - */ - .data - .globl _C_LABEL(_randseed) -_C_LABEL(_randseed): - .word 1 - .text -ENTRY(random) - sethi %hi(16807), %o1 - wr %o1, %lo(16807), %y - sethi %hi(_C_LABEL(_randseed)), %g1 - ld [%g1 + %lo(_C_LABEL(_randseed))], %o0 - andcc %g0, 0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %o0, %o2 - mulscc %o2, %g0, %o2 - rd %y, %o3 - srl %o2, 16, %o1 - set 0xffff, %o4 - and %o4, %o2, %o0 - sll %o0, 15, %o0 - srl %o3, 17, %o3 - or %o3, %o0, %o0 - addcc %o0, %o1, %o0 - bneg 1f - sethi %hi(0x7fffffff), %o1 - retl - st %o0, [%g1 + %lo(_C_LABEL(_randseed))] -1: - or %o1, %lo(0x7fffffff), %o1 - add %o0, 1, %o0 - and %o1, %o0, %o0 - retl - st %o0, [%g1 + %lo(_C_LABEL(_randseed))] - -/* * void lo_microtime(struct timeval *tv) * * LBL's sparc bsd 'microtime': We don't need to spl (so this routine diff --git a/sys/arch/vax/conf/files.vax b/sys/arch/vax/conf/files.vax index 0c34f42ef43..34c89ba13f0 100644 --- a/sys/arch/vax/conf/files.vax +++ b/sys/arch/vax/conf/files.vax @@ -1,4 +1,4 @@ -# $OpenBSD: files.vax,v 1.48 2008/08/18 23:19:21 miod Exp $ +# $OpenBSD: files.vax,v 1.49 2008/10/10 20:21:39 deraadt Exp $ # $NetBSD: files.vax,v 1.60 1999/08/27 20:04:32 ragge Exp $ # # new style config file for vax architecture @@ -384,7 +384,6 @@ file arch/vax/vax/bus_mem.c file arch/vax/vax/sgmap.c file arch/vax/vax/vm_machdep.c file arch/vax/vax/findcpu.c -file arch/vax/vax/random.s file arch/vax/vax/autoconf.c file arch/vax/vax/mutex.c file arch/vax/vax/in_cksum.c inet diff --git a/sys/arch/vax/vax/random.s b/sys/arch/vax/vax/random.s deleted file mode 100644 index 41fea6aea6c..00000000000 --- a/sys/arch/vax/vax/random.s +++ /dev/null @@ -1,105 +0,0 @@ -/* $OpenBSD: random.s,v 1.5 2007/01/14 19:13:35 otto Exp $ */ -/* $NetBSD: random.S,v 1.4 2007/01/14 13:26:18 ragge Exp $ */ - -/* - * Copyright (c) 1994 Ludd, University of Lule}, Sweden. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1990,1993 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Here is a very good random number generator. This implementation is - * based on ``Two Fast Implementations of the "Minimal Standard" Random - * Number Generator'', David G. Carta, Communications of the ACM, Jan 1990, - * Vol 33 No 1. Do NOT modify this code unless you have a very thorough - * understanding of the algorithm. It's trickier than you think. If - * you do change it, make sure that its 10,000'th invocation returns - * 1043618065. - * - * Here is easier-to-decipher pseudocode: - * - * p = (16807*seed)<30:0> # e.g., the low 31 bits of the product - * q = (16807*seed)<62:31> # e.g., the high 31 bits starting at bit 32 - * if (p + q < 2^31) - * seed = p + q - * else - * seed = ((p + q) & (2^31 - 1)) + 1 - * return (seed); - * - * The result is in (0,2^31), e.g., it's always positive. - */ - -#include <machine/asm.h> - - .data - .globl __randseed -__randseed: - .long 1 -ENTRY(random, 0) - movl $16807,r0 - - movl __randseed,r1 # r2=16807*loword(__randseed) - bicl3 $0xffff0000,r1,r2 - mull2 r0,r2 - ashl $-16,r1,r1 # r1=16807*hiword(__randseed) - bicl2 $0xffff0000,r1 - mull2 r0,r1 - bicl3 $0xffff0000,r2,r0 - ashl $-16,r2,r2 # r1+=(r2>>16) - bicl2 $0xffff0000,r2 - addl2 r2,r1 - ashl $16,r1,r2 # r0|=r1<<16 - bisl2 r2,r0 - ashl $-16,r1,r1 # r1=r1>>16 - - ashl $1,r1,r1 - movl r0,r2 - rotl $1,r0,r0 - bicl2 $0xfffffffe,r0 - bisl2 r0,r1 - movl r2,r0 - bicl2 $0x80000000,r0 - addl2 r1,r0 - bgeq L1 - subl2 $0x7fffffff,r0 -L1: movl r0,__randseed - ret diff --git a/sys/conf/files b/sys/conf/files index 3644ee064f1..4391aad2531 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.442 2008/09/09 13:56:39 henning Exp $ +# $OpenBSD: files,v 1.443 2008/10/10 20:21:40 deraadt Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -1032,8 +1032,8 @@ file compat/common/vm_43.c !small_kernel # libkern MI components file lib/libkern/mcount.c gprof file lib/libkern/getsn.c -file lib/libkern/arch/${MACHINE_ARCH}/random.S | lib/libkern/random.c -file lib/libkern/arch/${MACHINE_ARCH}/srandom.S | lib/libkern/srandom.c +file lib/libkern/random.c +file lib/libkern/srandom.c file lib/libkern/arch/${MACHINE_ARCH}/strchr.S | lib/libkern/strchr.c file lib/libkern/arch/${MACHINE_ARCH}/strrchr.S | lib/libkern/strrchr.c file lib/libkern/arch/${MACHINE_ARCH}/__main.S | lib/libkern/__main.c diff --git a/sys/lib/libkern/arch/sparc/random.S b/sys/lib/libkern/arch/sparc/random.S deleted file mode 100644 index 33ba5c2da5c..00000000000 --- a/sys/lib/libkern/arch/sparc/random.S +++ /dev/null @@ -1 +0,0 @@ -/* No code here since kernel impliments this itself */ |