summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-01-04 22:32:47 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-01-04 22:32:47 +0000
commitf1f8ec084a4848342229b45f81844372a42bb6b3 (patch)
tree83c7754b135823a6396c7350a9a01bc77eab7839 /sys
parent91339e2fbe038a0c52beb0d56cdac038eeae8c09 (diff)
Switch to the C version of random() on m68k platforms. It is almost as fast
as the assembly version on 0[234]0, but *fifteen* times faster than it on 68060 systems, since it uses a form of muls.l which has to be emulated. And since we use random() for statclock variance, this means we were gratuitously doing an average of 100 emulation traps per second. ok deraadt@ millert@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/m68k/conf/files.m68k3
-rw-r--r--sys/arch/m68k/m68k/random.s60
-rw-r--r--sys/lib/libkern/arch/m68k/Makefile.inc4
3 files changed, 3 insertions, 64 deletions
diff --git a/sys/arch/m68k/conf/files.m68k b/sys/arch/m68k/conf/files.m68k
index ec43562b555..e5dbb46963c 100644
--- a/sys/arch/m68k/conf/files.m68k
+++ b/sys/arch/m68k/conf/files.m68k
@@ -1,4 +1,4 @@
-# $OpenBSD: files.m68k,v 1.14 2005/08/01 11:54:23 miod Exp $
+# $OpenBSD: files.m68k,v 1.15 2006/01/04 22:32:43 miod Exp $
# $NetBSD: files.m68k,v 1.18 1997/06/06 23:15:28 veego Exp $
#
file arch/m68k/m68k/bcopy.s
@@ -15,7 +15,6 @@ file arch/m68k/m68k/m68k_machdep.c
file arch/m68k/m68k/mappedcopy.c mappedcopy
file arch/m68k/m68k/oc_cksum.s inet
file arch/m68k/m68k/process_machdep.c
-file arch/m68k/m68k/random.s
file arch/m68k/m68k/regdump.c
file arch/m68k/m68k/sig_machdep.c
diff --git a/sys/arch/m68k/m68k/random.s b/sys/arch/m68k/m68k/random.s
deleted file mode 100644
index aafc3fd40a2..00000000000
--- a/sys/arch/m68k/m68k/random.s
+++ /dev/null
@@ -1,60 +0,0 @@
-/* $OpenBSD: random.s,v 1.4 1997/07/06 07:46:29 downsj Exp $ */
-/* $NetBSD: random.s,v 1.6 1997/04/25 02:22:02 thorpej Exp $ */
-
-/*
- * 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
-GLOBAL(_randseed)
- .long 1
-
-ENTRY(random)
- movl #16807, d0
- mulsl _C_LABEL(_randseed), d1:d0
- lsll #1, d0
- roxll #2, d1
- addl d1, d0
- moveql #1, d1
- addxl d1, d0
- lsrl #1, d0
- movl d0, _C_LABEL(_randseed)
- rts
diff --git a/sys/lib/libkern/arch/m68k/Makefile.inc b/sys/lib/libkern/arch/m68k/Makefile.inc
index fd44dc81ac6..fe75454e089 100644
--- a/sys/lib/libkern/arch/m68k/Makefile.inc
+++ b/sys/lib/libkern/arch/m68k/Makefile.inc
@@ -1,8 +1,8 @@
-# $OpenBSD: Makefile.inc,v 1.8 2003/06/01 17:00:30 deraadt Exp $
+# $OpenBSD: Makefile.inc,v 1.9 2006/01/04 22:32:46 miod Exp $
# $NetBSD: Makefile.inc,v 1.7 1996/04/18 01:53:04 cgd Exp $
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
- memchr.c memcmp.S memset.S \
+ memchr.c memcmp.S memset.S random.c \
bcmp.S bzero.S ffs.S strcmp.S strlcat.c strlcpy.c \
strlen.S strncmp.S \
strncpy.S htonl.S htons.S ntohl.S ntohs.S scanc.S skpc.S locc.S \