diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-11-25 18:25:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-11-25 18:25:37 +0000 |
commit | fd3cd56c5876d53b6c02e5b0821c0039831c6b6d (patch) | |
tree | 3d877f0b245dd0e07d6c535cd77daf7b8459efe5 /sys/lib | |
parent | 98824d13d14295a8c20e3c51cd80ca8e90e5c383 (diff) |
libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.
There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.
Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..
Diffstat (limited to 'sys/lib')
110 files changed, 3573 insertions, 1504 deletions
diff --git a/sys/lib/libkern/Makefile b/sys/lib/libkern/Makefile deleted file mode 100644 index fc877d59c9a..00000000000 --- a/sys/lib/libkern/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# $OpenBSD: Makefile,v 1.19 2007/05/04 22:14:37 deraadt Exp $ - -LIB= kern -NOPIC= - -MACHINE= ${XMACHINE} -MACHINE_ARCH= ${XMACHINE_ARCH} - -M= ${.CURDIR}/arch/${MACHINE_ARCH} - -CPPFLAGS= -I$M ${KERNCPPFLAGS} - -.if exists ($M/Makefile.inc) -.PATH: $M -.include "$M/Makefile.inc" -.endif - -.if (${MACHINE_ARCH} != "alpha" && ${MACHINE} != "sgi" && \ - ${MACHINE_ARCH} != "sparc64") && ${MACHINE} != "amd64" && \ - ${MACHINE} != "hppa64" -# Quad support -SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ - lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ - subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c -.endif - -# Other stuff -SRCS+= getsn.c srandom.c strchr.c - -# Files to clean up -CLEANFILES+= lib${LIB}.o lib${LIB}.po - -# mcount cannot be compiled with profiling -mcount.po: mcount.o - cp mcount.o mcount.po - -install: - -.include <bsd.lib.mk> - -lib${LIB}.o:: ${OBJS} - @echo building standard ${LIB} library - @rm -f lib${LIB}.o - @${LD} -r -o lib${LIB}.o `${LORDER} ${OBJS} | tsort` - -POBJS+= ${OBJS:.o=.po} mcount.po -lib${LIB}.po:: ${POBJS} - @echo building profiled ${LIB} library - @rm -f lib${LIB}.po - @${LD} -r -o lib${LIB}.po `${LORDER} ${POBJS} | tsort` diff --git a/sys/lib/libkern/Makefile.inc b/sys/lib/libkern/Makefile.inc deleted file mode 100644 index 06121fc85a4..00000000000 --- a/sys/lib/libkern/Makefile.inc +++ /dev/null @@ -1,52 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.11 2000/06/29 16:28:29 mickey Exp $ -# $NetBSD: Makefile.inc,v 1.22 1996/09/30 15:54:35 ws Exp $ -# -# NOTE: $S must correspond to the top of the 'sys' tree - -KERNDIR= $S/lib/libkern - -KERNDST?= ${.OBJDIR}/lib/kern -KERN_AS?= obj - -.if (${KERN_AS} == "library") -KERNLIB= ${KERNDST}/libkern.a -KERNLIB_PROF= ${KERNDST}/libkern_p.a -.else -KERNLIB= ${KERNDST}/libkern.o -KERNLIB_PROF= ${KERNDST}/libkern.po -.endif - -KERNMAKE= \ - cd ${KERNDIR} && MAKEOBJDIR=${KERNDST} ${MAKE} \ - CC='${CC}' CFLAGS='${CFLAGS}' AS='${AS}' AFLAGS='${AFLAGS}' \ - LD='${LD}' STRIP='${STRIP}' CPP='${CPP}' STRIP='${STRIP}' \ - AR='${AR}' NM='${NM}' LORDER='${LORDER}' XMACHINE='${MACHINE}' \ - XMACHINE_ARCH='${MACHINE_ARCH}' KERNDIR=${KERNDIR} \ - KERNCPPFLAGS='${CPPFLAGS:S@^-I.@-I../../.@g}' - -${KERNLIB}: .NOTMAIN __always_make_kernlib - @echo making sure the kern library is up to date... -.if (${KERN_AS} == "library") - @${KERNMAKE} libkern.a -.else - @${KERNMAKE} libkern.o -.endif - -${KERNLIB_PROF}: .NOTMAIN __always_make_kernlib - @echo making sure the profiled kern library is up to date... -.if (${KERN_AS} == "library") - @${KERNMAKE} libkern_p.a -.else - @${KERNMAKE} libkern.po -.endif - -clean:: .NOTMAIN __always_make_kernlib - @echo cleaning the kern library objects - @${KERNMAKE} clean - -depend:: .NOTMAIN __always_make_kernlib - @echo depending the kern library objects - @${KERNMAKE} depend - -__always_make_kernlib: .NOTMAIN - -mkdir -p ${KERNDST} diff --git a/sys/lib/libkern/arch/alpha/Makefile.inc b/sys/lib/libkern/arch/alpha/Makefile index 2cef95cd260..407d3c0772d 100644 --- a/sys/lib/libkern/arch/alpha/Makefile.inc +++ b/sys/lib/libkern/arch/alpha/Makefile @@ -1,55 +1,47 @@ -# $OpenBSD: Makefile.inc,v 1.13 2003/06/01 17:00:30 deraadt Exp $ +# $OpenBSD: Makefile,v 1.1 2007/11/25 18:25:34 deraadt Exp $ # $NetBSD: Makefile.inc,v 1.9 1996/08/27 00:44:24 cgd Exp $ -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.c memcmp.c memset.c \ - bcmp.c bzero.S ffs.S softfloat.c strcmp.c \ - strlcat.c strlcpy.c strlen.c strncmp.c \ - strncpy.c scanc.c skpc.c htonl.S htons.S ntohl.S ntohs.S \ - random.c strncasecmp.c +all: __divqu.S __divq.S __divlu.S __divl.S \ + __remqu.S __remq.S __remlu.S __reml.S -# `source' files built from m4 source -SRCS+= __divqu.S __divq.S __divlu.S __divl.S -SRCS+= __remqu.S __remq.S __remlu.S __reml.S -CLEANFILES+= __divqu.S __divq.S __divlu.S __divl.S -CLEANFILES+= __remqu.S __remq.S __remlu.S __reml.S - -__divqu.S: ${M}/divrem.m4 +__divqu.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divqu')define(OP,\`div')define(S,\`false')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__divq.S: ${M}/divrem.m4 +__divq.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divq')define(OP,\`div')define(S,\`true')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__divlu.S: ${M}/divrem.m4 +__divlu.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divlu')define(OP,\`div')define(S,\`false')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__divl.S: ${M}/divrem.m4 +__divl.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__divl')define(OP,\`div')define(S,\`true')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__remqu.S: ${M}/divrem.m4 +__remqu.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__remqu')define(OP,\`rem')define(S,\`false')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__remq.S: ${M}/divrem.m4 +__remq.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__remq')define(OP,\`rem')define(S,\`true')"; \ echo "define(WORDSIZE,64)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__remlu.S: ${M}/divrem.m4 +__remlu.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__remlu')define(OP,\`rem')define(S,\`false')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} -__reml.S: ${M}/divrem.m4 +__reml.S: divrem.m4 @echo 'building ${.TARGET} from ${.ALLSRC}' @(echo "define(NAME,\`__reml')define(OP,\`rem')define(S,\`true')"; \ echo "define(WORDSIZE,32)"; cat ${.ALLSRC}) | m4 > ${.TARGET} + +.include <bsd.own.mk> diff --git a/sys/lib/libkern/arch/alpha/__divl.S b/sys/lib/libkern/arch/alpha/__divl.S new file mode 100644 index 00000000000..e5d280c8d67 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__divl.S @@ -0,0 +1,190 @@ + + +/* $OpenBSD: __divl.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __divl name of function to generate + * div div=div: t10 / t11 -> t12; div=rem: t10 % t11 -> t12 + * true true=true: signed; true=false: unsigned + * 32 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__divl, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + stq t4, 32(sp) + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + /* Compute sign of result. If either is negative, this is easy. */ + or t10, t11, t4 /* not the sign, but... */ + srl t4, 32 - 1, t4 /* rather, or of high bits */ + blbc t4, Ldoit /* neither negative? do it! */ + + xor t10, t11, t4 /* THIS is the sign! */ + + srl t4, 32 - 1, t4 /* make negation the low bit. */ + + srl t10, 32 - 1, t1 /* is t10 negative? */ + blbc t1, LnegB /* no. */ + /* t10 is negative; flip it. */ + + /* top 32 bits may be random junk */ + zap t10, 0xf0, t10 + + subq zero, t10, t10 + srl t11, 32 - 1, t1 /* is t11 negative? */ + blbc t1, Ldoit /* no. */ +LnegB: + /* t11 is definitely negative, no matter how we got here. */ + + /* top 32 bits may be random junk */ + zap t11, 0xf0, t11 + + subq zero, t11, t11 +Ldoit: + + + /* + * Clear the top 32 bits of each operand, as they may + * sign extension (if negated above), or random junk. + */ + zap t10, 0xf0, t10 + zap t11, 0xf0, t11 + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<32-1 */ + mov zero, t1 + sll t3, 32-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 32-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<32-1 */ + sll t3, 32-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + + + /* Check to see if we should negate it. */ + subqv zero, t12, t3 + cmovlbs t4, t3, t12 + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + ldq t4, 32(sp) + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + + br zero, Lret_result + +END(__divl) diff --git a/sys/lib/libkern/arch/alpha/__divlu.S b/sys/lib/libkern/arch/alpha/__divlu.S new file mode 100644 index 00000000000..8058027ff44 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__divlu.S @@ -0,0 +1,158 @@ + + +/* $OpenBSD: __divlu.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __divlu name of function to generate + * div div=div: t10 / t11 -> t12; div=rem: t10 % t11 -> t12 + * false false=true: signed; false=false: unsigned + * 32 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__divlu, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + + /* + * Clear the top 32 bits of each operand, as they may + * sign extension (if negated above), or random junk. + */ + zap t10, 0xf0, t10 + zap t11, 0xf0, t11 + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<32-1 */ + mov zero, t1 + sll t3, 32-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 32-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<32-1 */ + sll t3, 32-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + + br zero, Lret_result + +END(__divlu) diff --git a/sys/lib/libkern/arch/alpha/__divq.S b/sys/lib/libkern/arch/alpha/__divq.S new file mode 100644 index 00000000000..f0bdf28e070 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__divq.S @@ -0,0 +1,177 @@ + + +/* $OpenBSD: __divq.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __divq name of function to generate + * div div=div: t10 / t11 -> t12; div=rem: t10 % t11 -> t12 + * true true=true: signed; true=false: unsigned + * 64 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__divq, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + stq t4, 32(sp) + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + /* Compute sign of result. If either is negative, this is easy. */ + or t10, t11, t4 /* not the sign, but... */ + srl t4, 64 - 1, t4 /* rather, or of high bits */ + blbc t4, Ldoit /* neither negative? do it! */ + + xor t10, t11, t4 /* THIS is the sign! */ + + srl t4, 64 - 1, t4 /* make negation the low bit. */ + + srl t10, 64 - 1, t1 /* is t10 negative? */ + blbc t1, LnegB /* no. */ + /* t10 is negative; flip it. */ + + subq zero, t10, t10 + srl t11, 64 - 1, t1 /* is t11 negative? */ + blbc t1, Ldoit /* no. */ +LnegB: + /* t11 is definitely negative, no matter how we got here. */ + + subq zero, t11, t11 +Ldoit: + + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<64-1 */ + mov zero, t1 + sll t3, 64-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 64-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<64-1 */ + sll t3, 64-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + + + /* Check to see if we should negate it. */ + subqv zero, t12, t3 + cmovlbs t4, t3, t12 + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + ldq t4, 32(sp) + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + + br zero, Lret_result + +END(__divq) diff --git a/sys/lib/libkern/arch/alpha/__divqu.S b/sys/lib/libkern/arch/alpha/__divqu.S new file mode 100644 index 00000000000..c2c0ed2fcd3 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__divqu.S @@ -0,0 +1,151 @@ + + +/* $OpenBSD: __divqu.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __divqu name of function to generate + * div div=div: t10 / t11 -> t12; div=rem: t10 % t11 -> t12 + * false false=true: signed; false=false: unsigned + * 64 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__divqu, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<64-1 */ + mov zero, t1 + sll t3, 64-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 64-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<64-1 */ + sll t3, 64-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + + br zero, Lret_result + +END(__divqu) diff --git a/sys/lib/libkern/arch/alpha/__reml.S b/sys/lib/libkern/arch/alpha/__reml.S new file mode 100644 index 00000000000..069cfa5ebec --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__reml.S @@ -0,0 +1,192 @@ + + +/* $OpenBSD: __reml.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __reml name of function to generate + * rem rem=div: t10 / t11 -> t12; rem=rem: t10 % t11 -> t12 + * true true=true: signed; true=false: unsigned + * 32 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__reml, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + stq t4, 32(sp) + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + /* Compute sign of result. If either is negative, this is easy. */ + or t10, t11, t4 /* not the sign, but... */ + srl t4, 32 - 1, t4 /* rather, or of high bits */ + blbc t4, Ldoit /* neither negative? do it! */ + + mov t10, t4 /* sign follows t10. */ + + srl t4, 32 - 1, t4 /* make negation the low bit. */ + + srl t10, 32 - 1, t1 /* is t10 negative? */ + blbc t1, LnegB /* no. */ + /* t10 is negative; flip it. */ + + /* top 32 bits may be random junk */ + zap t10, 0xf0, t10 + + subq zero, t10, t10 + srl t11, 32 - 1, t1 /* is t11 negative? */ + blbc t1, Ldoit /* no. */ +LnegB: + /* t11 is definitely negative, no matter how we got here. */ + + /* top 32 bits may be random junk */ + zap t11, 0xf0, t11 + + subq zero, t11, t11 +Ldoit: + + + /* + * Clear the top 32 bits of each operand, as they may + * sign extension (if negated above), or random junk. + */ + zap t10, 0xf0, t10 + zap t11, 0xf0, t11 + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<32-1 */ + mov zero, t1 + sll t3, 32-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 32-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<32-1 */ + sll t3, 32-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + mov t10, t12 + + + /* Check to see if we should negate it. */ + subqv zero, t12, t3 + cmovlbs t4, t3, t12 + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + ldq t4, 32(sp) + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + mov zero, t10 /* so that zero will be returned */ + + br zero, Lret_result + +END(__reml) diff --git a/sys/lib/libkern/arch/alpha/__remlu.S b/sys/lib/libkern/arch/alpha/__remlu.S new file mode 100644 index 00000000000..88d487a2a56 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__remlu.S @@ -0,0 +1,160 @@ + + +/* $OpenBSD: __remlu.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __remlu name of function to generate + * rem rem=div: t10 / t11 -> t12; rem=rem: t10 % t11 -> t12 + * false false=true: signed; false=false: unsigned + * 32 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__remlu, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + + /* + * Clear the top 32 bits of each operand, as they may + * sign extension (if negated above), or random junk. + */ + zap t10, 0xf0, t10 + zap t11, 0xf0, t11 + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<32-1 */ + mov zero, t1 + sll t3, 32-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 32-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<32-1 */ + sll t3, 32-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + mov t10, t12 + + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + mov zero, t10 /* so that zero will be returned */ + + br zero, Lret_result + +END(__remlu) diff --git a/sys/lib/libkern/arch/alpha/__remq.S b/sys/lib/libkern/arch/alpha/__remq.S new file mode 100644 index 00000000000..e289df7b3f8 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__remq.S @@ -0,0 +1,179 @@ + + +/* $OpenBSD: __remq.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __remq name of function to generate + * rem rem=div: t10 / t11 -> t12; rem=rem: t10 % t11 -> t12 + * true true=true: signed; true=false: unsigned + * 64 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__remq, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + stq t4, 32(sp) + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + /* Compute sign of result. If either is negative, this is easy. */ + or t10, t11, t4 /* not the sign, but... */ + srl t4, 64 - 1, t4 /* rather, or of high bits */ + blbc t4, Ldoit /* neither negative? do it! */ + + mov t10, t4 /* sign follows t10. */ + + srl t4, 64 - 1, t4 /* make negation the low bit. */ + + srl t10, 64 - 1, t1 /* is t10 negative? */ + blbc t1, LnegB /* no. */ + /* t10 is negative; flip it. */ + + subq zero, t10, t10 + srl t11, 64 - 1, t1 /* is t11 negative? */ + blbc t1, Ldoit /* no. */ +LnegB: + /* t11 is definitely negative, no matter how we got here. */ + + subq zero, t11, t11 +Ldoit: + + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<64-1 */ + mov zero, t1 + sll t3, 64-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 64-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<64-1 */ + sll t3, 64-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + mov t10, t12 + + + /* Check to see if we should negate it. */ + subqv zero, t12, t3 + cmovlbs t4, t3, t12 + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + ldq t4, 32(sp) + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + mov zero, t10 /* so that zero will be returned */ + + br zero, Lret_result + +END(__remq) diff --git a/sys/lib/libkern/arch/alpha/__remqu.S b/sys/lib/libkern/arch/alpha/__remqu.S new file mode 100644 index 00000000000..579dffc046f --- /dev/null +++ b/sys/lib/libkern/arch/alpha/__remqu.S @@ -0,0 +1,153 @@ + + +/* $OpenBSD: __remqu.S,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.5 1996/10/17 04:26:25 cgd Exp $ */ + +/* + * Copyright (c) 1994, 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +/* + * Division and remainder. + * + * The use of m4 is modeled after the sparc code, but the algorithm is + * simple binary long division. + * + * Note that the loops could probably benefit from unrolling. + */ + +/* + * M4 Parameters + * __remqu name of function to generate + * rem rem=div: t10 / t11 -> t12; rem=rem: t10 % t11 -> t12 + * false false=true: signed; false=false: unsigned + * 64 total number of bits + */ + + + + + + + + + + + +#include <machine/asm.h> + +LEAF(__remqu, 0) /* XXX */ + lda sp, -64(sp) + stq t0, 0(sp) + stq t1, 8(sp) + stq t2, 16(sp) + stq t3, 24(sp) + + stq t10, 40(sp) + stq t11, 48(sp) + mov zero, t12 /* Initialize result to zero */ + + + + + /* kill the special cases. */ + beq t11, Ldotrap /* division by zero! */ + + cmpult t10, t11, t2 /* t10 < t11? */ + /* t12 is already zero, from above. t10 is untouched. */ + bne t2, Lret_result + + cmpeq t10, t11, t2 /* t10 == t11? */ + cmovne t2, 1, t12 + cmovne t2, zero, t10 + bne t2, Lret_result + + /* + * Find out how many bits of zeros are at the beginning of the divisor. + */ +LBbits: + ldiq t3, 1 /* t1 = 0; t0 = 1<<64-1 */ + mov zero, t1 + sll t3, 64-1, t0 +LBloop: + and t11, t0, t2 /* if bit in t11 is set, done. */ + bne t2, LAbits + addq t1, 1, t1 /* increment t1, bit */ + srl t0, 1, t0 + cmplt t1, 64-1, t2 /* if t1 leaves one bit, done. */ + bne t2, LBloop + +LAbits: + beq t1, Ldodiv /* If t1 = 0, divide now. */ + ldiq t3, 1 /* t0 = 1<<64-1 */ + sll t3, 64-1, t0 + +LAloop: + and t10, t0, t2 /* if bit in t10 is set, done. */ + bne t2, Ldodiv + subq t1, 1, t1 /* decrement t1, bit */ + srl t0, 1, t0 + bne t1, LAloop /* If t1 != 0, loop again */ + +Ldodiv: + sll t11, t1, t11 /* t11 <<= i */ + ldiq t3, 1 + sll t3, t1, t0 + +Ldivloop: + cmpult t10, t11, t2 + or t12, t0, t3 + cmoveq t2, t3, t12 + subq t10, t11, t3 + cmoveq t2, t3, t10 + srl t0, 1, t0 + srl t11, 1, t11 + beq t10, Lret_result + bne t0, Ldivloop + +Lret_result: + mov t10, t12 + + + + ldq t0, 0(sp) + ldq t1, 8(sp) + ldq t2, 16(sp) + ldq t3, 24(sp) + + ldq t10, 40(sp) + ldq t11, 48(sp) + lda sp, 64(sp) + ret zero, (t9), 1 + +Ldotrap: + ldiq a0, -2 /* This is the signal to SIGFPE! */ + call_pal PAL_gentrap + mov zero, t10 /* so that zero will be returned */ + + br zero, Lret_result + +END(__remqu) diff --git a/sys/lib/libkern/arch/alpha/bcopy.S b/sys/lib/libkern/arch/alpha/bcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/alpha/bcopy.S diff --git a/sys/lib/libkern/arch/alpha/byte_swap_2.S b/sys/lib/libkern/arch/alpha/byte_swap_2.S deleted file mode 100644 index 29d1946200d..00000000000 --- a/sys/lib/libkern/arch/alpha/byte_swap_2.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: byte_swap_2.S,v 1.2 1996/10/31 00:43:14 niklas Exp $ */ -/* $NetBSD: byte_swap_2.S,v 1.2 1996/10/17 04:26:21 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include <machine/asm.h> - -#ifndef NAME -#define NAME byte_swap_2 -#endif - -/* - * Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.) - * - * Argument is an unsigned 2-byte integer (u_int16_t). - */ -LEAF(NAME, 1) /* a0 contains 0x0123 */ - extbl a0, 0, t0 /* t0 = 0x 23 */ - extbl a0, 1, t1 /* t1 = 0x 01 */ - sll t0, 8, t0 /* t1 = 0x23 */ - or t0, t1, v0 /* v0 = 0x2301 */ - RET -END(NAME) diff --git a/sys/lib/libkern/arch/alpha/byte_swap_4.S b/sys/lib/libkern/arch/alpha/byte_swap_4.S deleted file mode 100644 index 8a6ac788b0e..00000000000 --- a/sys/lib/libkern/arch/alpha/byte_swap_4.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: byte_swap_4.S,v 1.2 1996/10/31 00:43:15 niklas Exp $ */ -/* $NetBSD: byte_swap_4.S,v 1.2 1996/10/17 04:26:22 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include <machine/asm.h> - -#ifndef NAME -#define NAME byte_swap_4 -#endif - -/* - * Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.) - * - * Argument is an unsigned 4-byte integer (u_int32_t). - */ -LEAF(NAME, 1) /* a0 contains 0x01234567 */ - extbl a0, 0, t0 /* t0 = 0x 67 */ - extbl a0, 1, t1 /* t1 = 0x 45 */ - extbl a0, 2, t2 /* t2 = 0x 23 */ - extbl a0, 3, t3 /* t3 = 0x 01 */ - sll t0, 24, t0 /* t0 = 0x67 */ - sll t1, 16, t1 /* t1 = 0x 45 */ - sll t2, 8, t2 /* t2 = 0x 23 */ - or t3, t0, v0 /* v0 = 0x67 01 */ - or t1, t2, t1 /* t1 = 0x 4523 */ - or t1, v0, v0 /* v0 = 0x67452301 */ - RET -END(NAME) diff --git a/sys/lib/libkern/arch/alpha/htonl.S b/sys/lib/libkern/arch/alpha/htonl.S index bfa4d31d6c0..e69de29bb2d 100644 --- a/sys/lib/libkern/arch/alpha/htonl.S +++ b/sys/lib/libkern/arch/alpha/htonl.S @@ -1,33 +0,0 @@ -/* $OpenBSD: htonl.S,v 1.2 1996/10/31 00:43:19 niklas Exp $ */ -/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:46:41 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME htonl - -#include "byte_swap_4.S" diff --git a/sys/lib/libkern/arch/alpha/htons.S b/sys/lib/libkern/arch/alpha/htons.S index 66ccd0cd684..e69de29bb2d 100644 --- a/sys/lib/libkern/arch/alpha/htons.S +++ b/sys/lib/libkern/arch/alpha/htons.S @@ -1,33 +0,0 @@ -/* $OpenBSD: htons.S,v 1.2 1996/10/31 00:43:20 niklas Exp $ */ -/* $NetBSD: htons.S,v 1.1 1996/04/17 22:46:43 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME htons - -#include "byte_swap_2.S" diff --git a/sys/lib/libkern/arch/alpha/memcpy.S b/sys/lib/libkern/arch/alpha/memcpy.S new file mode 100644 index 00000000000..c1783be24fc --- /dev/null +++ b/sys/lib/libkern/arch/alpha/memcpy.S @@ -0,0 +1 @@ +/* In locore */ diff --git a/sys/lib/libkern/arch/alpha/memmove.S b/sys/lib/libkern/arch/alpha/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/alpha/memmove.S diff --git a/sys/lib/libkern/arch/alpha/ntohl.S b/sys/lib/libkern/arch/alpha/ntohl.S deleted file mode 100644 index 5109d6d8a2e..00000000000 --- a/sys/lib/libkern/arch/alpha/ntohl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.2 1996/10/31 00:43:21 niklas Exp $ */ -/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:46:45 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME ntohl - -#include "byte_swap_4.S" diff --git a/sys/lib/libkern/arch/alpha/ntohs.S b/sys/lib/libkern/arch/alpha/ntohs.S deleted file mode 100644 index 4e2213ba827..00000000000 --- a/sys/lib/libkern/arch/alpha/ntohs.S +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.2 1996/10/31 00:43:22 niklas Exp $ */ -/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:46:46 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME ntohs - -#include "byte_swap_2.S" diff --git a/sys/lib/libkern/arch/alpha/ovbcopy.S b/sys/lib/libkern/arch/alpha/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/alpha/ovbcopy.S diff --git a/sys/lib/libkern/arch/amd64/Makefile.inc b/sys/lib/libkern/arch/amd64/Makefile.inc deleted file mode 100644 index be83971422a..00000000000 --- a/sys/lib/libkern/arch/amd64/Makefile.inc +++ /dev/null @@ -1,14 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2002/11/25 00:55:22 fvdl Exp $ - -SRCS+= imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - byte_swap_2.S byte_swap_4.S \ - bcmp.S bcopy.S bzero.S ffs.S \ - memchr.S memcmp.S memcpy.S memmove.S memset.S \ - ovbcopy.S \ - strchr.S strcmp.S \ - strlcpy.c strlcat.c strlen.S \ - strncasecmp.c strncmp.c strncpy.c strrchr.S \ - scanc.S skpc.S random.c -# bswap64.c strcasecmp.c strncasecmp.c \ strtoul.c \ - -CFLAGS+=-mcmodel=kernel diff --git a/sys/lib/libkern/arch/amd64/byte_swap_4.S b/sys/lib/libkern/arch/amd64/htonl.S index f6a961e38f5..b9b121597f6 100644 --- a/sys/lib/libkern/arch/amd64/byte_swap_4.S +++ b/sys/lib/libkern/arch/amd64/htonl.S @@ -39,13 +39,10 @@ */ #include <machine/asm.h> -#if defined(LIBC_SCCS) - RCSID("$NetBSD: byte_swap_4.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $") -#endif -_ENTRY(_C_LABEL(bswap32)) -_ENTRY(_C_LABEL(ntohl)) _ENTRY(_C_LABEL(htonl)) +_ENTRY(_C_LABEL(ntohl)) +_ENTRY(_C_LABEL(bswap32)) _PROF_PROLOGUE movl %edi,%eax bswap %eax diff --git a/sys/lib/libkern/arch/amd64/byte_swap_2.S b/sys/lib/libkern/arch/amd64/htons.S index 19ed5e27812..a35b67b2951 100644 --- a/sys/lib/libkern/arch/amd64/byte_swap_2.S +++ b/sys/lib/libkern/arch/amd64/htons.S @@ -39,13 +39,10 @@ */ #include <machine/asm.h> -#if defined(LIBC_SCCS) - RCSID("$NetBSD: byte_swap_2.S,v 1.1 2001/06/19 00:22:45 fvdl Exp $") -#endif -_ENTRY(_C_LABEL(bswap16)) -_ENTRY(_C_LABEL(ntohs)) _ENTRY(_C_LABEL(htons)) +_ENTRY(_C_LABEL(ntohs)) +_ENTRY(_C_LABEL(bswap16)) _PROF_PROLOGUE movl %edi,%eax xchgb %ah,%al diff --git a/sys/lib/libkern/arch/amd64/index.S b/sys/lib/libkern/arch/amd64/index.S index 60754f266f0..e69de29bb2d 100644 --- a/sys/lib/libkern/arch/amd64/index.S +++ b/sys/lib/libkern/arch/amd64/index.S @@ -1,29 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: index.S,v 1.1 2001/06/19 00:22:46 fvdl Exp $") -#endif - -#ifdef STRCHR -ENTRY(strchr) -#else -ENTRY(index) -#endif - movq %rdi,%rax - movb %sil,%cl -L1: - movb (%rax),%dl - cmpb %dl,%cl /* found char? */ - je L2 - incq %rax - testb %dl,%dl /* null terminator? */ - jnz L1 - xorq %rax,%rax -L2: - ret diff --git a/sys/lib/libkern/arch/amd64/rindex.S b/sys/lib/libkern/arch/amd64/rindex.S index 6ba7c52a11f..e69de29bb2d 100644 --- a/sys/lib/libkern/arch/amd64/rindex.S +++ b/sys/lib/libkern/arch/amd64/rindex.S @@ -1,29 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> - */ - -#include <machine/asm.h> - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: rindex.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $") -#endif - -#ifdef STRRCHR -ENTRY(strrchr) -#else -ENTRY(rindex) -#endif - movb %sil,%cl - xorq %rax,%rax /* init pointer to null */ -L1: - movb (%rdi),%dl - cmpb %dl,%cl - jne L2 - movq %rdi,%rax -L2: - incq %rdi - testb %dl,%dl /* null terminator??? */ - jnz L1 - ret diff --git a/sys/lib/libkern/arch/amd64/strchr.S b/sys/lib/libkern/arch/amd64/strchr.S index 91fd708891f..058c56a5358 100644 --- a/sys/lib/libkern/arch/amd64/strchr.S +++ b/sys/lib/libkern/arch/amd64/strchr.S @@ -1,4 +1,21 @@ -/* $NetBSD: strchr.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $ */ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> + */ -#define STRCHR -#include "index.S" +#include <machine/asm.h> + +ENTRY(strchr) + movq %rdi,%rax + movb %sil,%cl +L1: + movb (%rax),%dl + cmpb %dl,%cl /* found char? */ + je L2 + incq %rax + testb %dl,%dl /* null terminator? */ + jnz L1 + xorq %rax,%rax +L2: + ret diff --git a/sys/lib/libkern/arch/amd64/strrchr.S b/sys/lib/libkern/arch/amd64/strrchr.S index 9b23edfb435..097b4f1f699 100644 --- a/sys/lib/libkern/arch/amd64/strrchr.S +++ b/sys/lib/libkern/arch/amd64/strrchr.S @@ -1,4 +1,21 @@ -/* $NetBSD: strrchr.S,v 1.1 2001/06/19 00:22:47 fvdl Exp $ */ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com> + */ -#define STRRCHR -#include "rindex.S" +#include <machine/asm.h> + +ENTRY(strrchr) + movb %sil,%cl + xorq %rax,%rax /* init pointer to null */ +L1: + movb (%rdi),%dl + cmpb %dl,%cl + jne L2 + movq %rdi,%rax +L2: + incq %rdi + testb %dl,%dl /* null terminator??? */ + jnz L1 + ret diff --git a/sys/lib/libkern/arch/arm/Makefile.inc b/sys/lib/libkern/arch/arm/Makefile.inc deleted file mode 100644 index 6cd3abb42f2..00000000000 --- a/sys/lib/libkern/arch/arm/Makefile.inc +++ /dev/null @@ -1,28 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.2 2004/02/01 05:47:10 drahn Exp $ -# $NetBSD: Makefile.inc,v 1.3 2001/11/20 00:29:19 chris Exp $ - -SRCS+= __main.c byte_swap_2.S byte_swap_4.S \ - bcmp.c ffs.c imax.c imin.c lmax.c lmin.c max.c min.c random.c scanc.c \ - skpc.c strcmp.c strlen.c strncmp.c strncasecmp.c \ - strlcat.c strlcpy.c \ - strncpy.c ulmax.c ulmin.c - - -SRCS+= bcopy.S divsi3.S -SRCS+= memchr.c memcmp.c memcpy.S memset.S - -OBJS+= bzero.o -CLEANFILES+= bzero.o - -bzero.o: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bzero.po: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - diff --git a/sys/lib/libkern/arch/arm/byte_swap_4.S b/sys/lib/libkern/arch/arm/htonl.S index 703d006a76b..d350ca1d048 100644 --- a/sys/lib/libkern/arch/arm/byte_swap_4.S +++ b/sys/lib/libkern/arch/arm/htonl.S @@ -1,4 +1,4 @@ -/* $OpenBSD: byte_swap_4.S,v 1.2 2004/02/01 05:47:10 drahn Exp $ */ +/* $OpenBSD: htonl.S,v 1.1 2007/11/25 18:25:35 deraadt Exp $ */ /* $NetBSD: byte_swap_4.S,v 1.1 2000/12/29 20:51:57 bjh21 Exp $ */ /*- @@ -39,9 +39,9 @@ #include <machine/asm.h> -_ENTRY(_C_LABEL(bswap32)) -_ENTRY(_C_LABEL(ntohl)) _ENTRY(_C_LABEL(htonl)) +_ENTRY(_C_LABEL(ntohl)) +_ENTRY(_C_LABEL(bswap32)) _PROF_PROLOGUE eor r1, r0, r0, ror #16 bic r1, r1, #0x00FF0000 diff --git a/sys/lib/libkern/arch/arm/byte_swap_2.S b/sys/lib/libkern/arch/arm/htons.S index 7cacb0f447d..3dd79755f31 100644 --- a/sys/lib/libkern/arch/arm/byte_swap_2.S +++ b/sys/lib/libkern/arch/arm/htons.S @@ -1,4 +1,4 @@ -/* $OpenBSD: byte_swap_2.S,v 1.2 2004/02/01 05:47:10 drahn Exp $ */ +/* $OpenBSD: htons.S,v 1.1 2007/11/25 18:25:35 deraadt Exp $ */ /* $NetBSD: byte_swap_2.S,v 1.1.20.1 2002/07/02 06:50:59 lukem Exp $ */ /*- @@ -39,9 +39,9 @@ #include <machine/asm.h> -_ENTRY(_C_LABEL(bswap16)) -_ENTRY(_C_LABEL(ntohs)) _ENTRY(_C_LABEL(htons)) +_ENTRY(_C_LABEL(ntohs)) +_ENTRY(_C_LABEL(bswap16)) _PROF_PROLOGUE and r1, r0, #0xff mov r0, r0, lsr #8 diff --git a/sys/lib/libkern/arch/arm/ovbcopy.S b/sys/lib/libkern/arch/arm/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/arm/ovbcopy.S diff --git a/sys/lib/libkern/arch/hppa/Makefile b/sys/lib/libkern/arch/hppa/Makefile new file mode 100644 index 00000000000..59fa4860c13 --- /dev/null +++ b/sys/lib/libkern/arch/hppa/Makefile @@ -0,0 +1,14 @@ +# $OpenBSD: Makefile,v 1.1 2007/11/25 18:25:35 deraadt Exp $ + +all: ${.CURDIR}/bcopy.S ${.CURDIR}/spcopy.S + +${.CURDIR}/bcopy.S: bcopy.m4 + @echo 'building ${.TARGET} from ${.ALLSRC}' + @m4 -DNAME=bcopy ${.ALLSRC} > ${.TARGET} + +${.CURDIR}/spcopy.S: bcopy.m4 + @echo 'building ${.TARGET} from ${.ALLSRC}' + @m4 -DNAME=spcopy ${.ALLSRC} > ${.TARGET} + +.include <bsd.own.mk> +.include <bsd.obj.mk> diff --git a/sys/lib/libkern/arch/hppa/Makefile.inc b/sys/lib/libkern/arch/hppa/Makefile.inc deleted file mode 100644 index 47bd03f41f1..00000000000 --- a/sys/lib/libkern/arch/hppa/Makefile.inc +++ /dev/null @@ -1,33 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.17 2003/06/01 17:00:30 deraadt Exp $ - -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - random.c ashrdi3.c divdi3.c strncpy.c strncmp.c strcmp.c memchr.c \ - memcmp.c memset.c strlen.c strlcpy.c strlcat.c \ - skpc.c strncasecmp.c \ - bcmp.c scanc.c ffs.c - -SRCS+= milli.S -OBJS+= bzero.o - -SRCS+= bcopy.S spcopy.S -CLEANFILES+= bcopy.S spcopy.S bzero.o - -bzero.o: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -X -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bzero.po: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -p -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -p -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -X -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bcopy.S: ${M}/bcopy.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @m4 -DNAME=bcopy ${.ALLSRC} > ${.TARGET} - -spcopy.S: ${M}/bcopy.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @m4 -DNAME=spcopy ${.ALLSRC} > ${.TARGET} diff --git a/sys/lib/libkern/arch/hppa/bcopy.S b/sys/lib/libkern/arch/hppa/bcopy.S new file mode 100644 index 00000000000..809fa2b7986 --- /dev/null +++ b/sys/lib/libkern/arch/hppa/bcopy.S @@ -0,0 +1,159 @@ +/* This is a generated file. DO NOT EDIT. */ +/* + * Generated from: + * + * OpenBSD: bcopy.m4 + */ +/* + * Copyright (c) 1999 Michael Shalayeff + * 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. + * + * 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. + * + */ + + + +#undef _LOCORE +#define _LOCORE +#include <machine/asm.h> +#include <machine/frame.h> + +LEAF_ENTRY(memcpy) +ALTENTRY(memmove) + copy arg0, t1 + copy arg1, arg0 + copy t1, arg1 + copy arg0, ret0 +ALTENTRY(ovbcopy) +ALTENTRY(bcopy) + comb,>,n arg1, arg0, $bcopy.reverse + + comib,>=,n 15, arg2, $bcopy_f.byte + + extru arg0, 31, 2, t3 + extru arg1, 31, 2, t4 + add arg2, t4, arg2 + comb,<> t3, t4, $bcopy_f.unaligned + dep r0, 31, 2, arg0 + + addi -16, arg2, arg2 +$bcopy_f.loop16a + ldws,ma 4(sr0, arg0), t1 + ldws,ma 4(sr0, arg0), t2 + ldws,ma 4(sr0, arg0), t3 + ldws,ma 4(sr0, arg0), t4 + stbys,b,m t1, 4(sr0, arg1) + stws,ma t2, 4(sr0, arg1) + stws,ma t3, 4(sr0, arg1) + addib,>= -16, arg2, $bcopy_f.loop16a + stws,ma t4, 4(sr0, arg1) + + addib,<,n 12, arg2, $bcopy_f.cleanup +$bcopy_f.word + ldws,ma 4(sr0, arg0), t1 + addib,>= -4, arg2, $bcopy_f.word + stws,ma t1, 4(sr0, arg1) + +$bcopy_f.cleanup + addib,=,n 4, arg2, $bcopy_f.done + ldws 0(sr0, arg0), t1 + add arg1, arg2, arg1 + b $bcopy_f.done + stbys,e t1, 0(sr0, arg1) + +$bcopy_f.unaligned + sub,>= t4, t3, t2 + ldwm 4(sr0, arg0), ret1 + zdep t2, 28, 29, t1 + mtsar t1 + + addi -16, arg2, arg2 +$bcopy_f.loop16u + ldws,ma 4(sr0, arg0), t1 + ldws,ma 4(sr0, arg0), t2 + ldws,ma 4(sr0, arg0), t3 + ldws,ma 4(sr0, arg0), t4 + vshd ret1, t1, r31 + stbys,b,m r31, 4(sr0, arg1) + vshd t1, t2, r31 + stws,ma r31, 4(sr0, arg1) + vshd t2, t3, r31 + stws,ma r31, 4(sr0, arg1) + vshd t3, t4, r31 + stws,ma r31, 4(sr0, arg1) + addib,>= -16, arg2, $bcopy_f.loop16u + copy t4, ret1 + + addib,<,n 12, arg2, $bcopy_f.cleanup_un +$bcopy_f.word_un + ldws,ma 4(sr0, arg0), t1 + vshd ret1, t1, t2 + addib,< -4, arg2, $bcopy_f.cleanup1_un + stws,ma t2, 4(sr0, arg1) + ldws,ma 4(sr0, arg0), ret1 + vshd t1, ret1, t2 + addib,>= -4, arg2, $bcopy_f.word_un + stws,ma t2, 4(sr0, arg1) + +$bcopy_f.cleanup_un + addib,<=,n 4, arg2, $bcopy_f.done + mfctl sar, t4 + add arg1, arg2, arg1 + extru t4, 28, 2, t4 + sub,<= arg2, t4, r0 + ldws,ma 4(sr0, arg0), t1 + vshd ret1, t1, t2 + b $bcopy_f.done + stbys,e t2, 0(sr0, arg1) + +$bcopy_f.cleanup1_un + b $bcopy_f.cleanup_un + copy t1, ret1 + +$bcopy_f.byte + comb,>=,n r0, arg2, $bcopy_f.done +$bcopy_f.byte_loop + ldbs,ma 1(sr0, arg0), t1 + addib,<> -1, arg2, $bcopy_f.byte_loop + stbs,ma t1, 1(sr0, arg1) +$bcopy_f.done + + bv 0(rp) + nop +$bcopy.reverse + add arg0, arg2, arg0 + add arg1, arg2, arg1 + + +$bcopy_r.byte + comb,>=,n r0, arg2, $bcopy_r.done +$bcopy_r.byte_loop + ldbs,mb -1(sr0, arg0), t1 + addib,<> -1, arg2, $bcopy_r.byte_loop + stbs,mb t1, -1(sr0, arg1) +$bcopy_r.done + + bv 0(rp) + nop +EXIT(memcpy) + + .end diff --git a/sys/lib/libkern/arch/hppa/memcpy.S b/sys/lib/libkern/arch/hppa/memcpy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/hppa/memcpy.S diff --git a/sys/lib/libkern/arch/hppa/memmove.S b/sys/lib/libkern/arch/hppa/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/hppa/memmove.S diff --git a/sys/lib/libkern/arch/hppa/ovbcopy.S b/sys/lib/libkern/arch/hppa/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/hppa/ovbcopy.S diff --git a/sys/lib/libkern/arch/hppa/spcopy.S b/sys/lib/libkern/arch/hppa/spcopy.S new file mode 100644 index 00000000000..f84960757bc --- /dev/null +++ b/sys/lib/libkern/arch/hppa/spcopy.S @@ -0,0 +1,180 @@ +/* This is a generated file. DO NOT EDIT. */ +/* + * Generated from: + * + * OpenBSD: bcopy.m4 + */ +/* + * Copyright (c) 1999 Michael Shalayeff + * 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. + * + * 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. + * + */ + + + +#undef _LOCORE +#define _LOCORE +#include <machine/asm.h> +#include <machine/frame.h> + + +#ifdef _KERNEL +#include <assym.h> + +/* + * int spcopy (pa_space_t ssp, const void *src, pa_space_t dsp, void *dst, + * size_t size) + * do a space to space bcopy. + * + * assumes that spaces do not clash, otherwise we lose + */ + .import curproc, data + .import cpu_info_primary, data + .import copy_on_fault, code + +#define curproc (cpu_info_primary + CI_CURPROC) + +LEAF_ENTRY(spcopy) + ldw HPPA_FRAME_ARG(4)(sp), ret0 + sub,<> r0, ret0, r0 + bv r0(rp) + nop + + ldo 64(sp), sp + stw rp, HPPA_FRAME_CRP(sp) + /* setup fault handler */ + ldil L%curproc, t1 + ldw R%curproc(t1), t3 + ldil L%copy_on_fault, t2 + ldw P_ADDR(t3), r2 + ldo R%copy_on_fault(t2), t2 + ldw PCB_ONFAULT+U_PCB(r2), r1 + stw t2, PCB_ONFAULT+U_PCB(r2) + + mtsp arg0, sr1 + mtsp arg2, sr2 + + + comib,>=,n 15, ret0, $spcopy.byte + + extru arg1, 31, 2, t3 + extru arg3, 31, 2, t4 + add ret0, t4, ret0 + comb,<> t3, t4, $spcopy.unaligned + dep r0, 31, 2, arg1 + + addi -16, ret0, ret0 +$spcopy.loop16a + ldws,ma 4(sr1, arg1), t1 + ldws,ma 4(sr1, arg1), t2 + ldws,ma 4(sr1, arg1), t3 + ldws,ma 4(sr1, arg1), t4 + stbys,b,m t1, 4(sr2, arg3) + stws,ma t2, 4(sr2, arg3) + stws,ma t3, 4(sr2, arg3) + addib,>= -16, ret0, $spcopy.loop16a + stws,ma t4, 4(sr2, arg3) + + addib,<,n 12, ret0, $spcopy.cleanup +$spcopy.word + ldws,ma 4(sr1, arg1), t1 + addib,>= -4, ret0, $spcopy.word + stws,ma t1, 4(sr2, arg3) + +$spcopy.cleanup + addib,=,n 4, ret0, $spcopy.done + ldws 0(sr1, arg1), t1 + add arg3, ret0, arg3 + b $spcopy.done + stbys,e t1, 0(sr2, arg3) + +$spcopy.unaligned + sub,>= t4, t3, t2 + ldwm 4(sr1, arg1), ret1 + zdep t2, 28, 29, t1 + mtsar t1 + + addi -16, ret0, ret0 +$spcopy.loop16u + ldws,ma 4(sr1, arg1), t1 + ldws,ma 4(sr1, arg1), t2 + ldws,ma 4(sr1, arg1), t3 + ldws,ma 4(sr1, arg1), t4 + vshd ret1, t1, r31 + stbys,b,m r31, 4(sr2, arg3) + vshd t1, t2, r31 + stws,ma r31, 4(sr2, arg3) + vshd t2, t3, r31 + stws,ma r31, 4(sr2, arg3) + vshd t3, t4, r31 + stws,ma r31, 4(sr2, arg3) + addib,>= -16, ret0, $spcopy.loop16u + copy t4, ret1 + + addib,<,n 12, ret0, $spcopy.cleanup_un +$spcopy.word_un + ldws,ma 4(sr1, arg1), t1 + vshd ret1, t1, t2 + addib,< -4, ret0, $spcopy.cleanup1_un + stws,ma t2, 4(sr2, arg3) + ldws,ma 4(sr1, arg1), ret1 + vshd t1, ret1, t2 + addib,>= -4, ret0, $spcopy.word_un + stws,ma t2, 4(sr2, arg3) + +$spcopy.cleanup_un + addib,<=,n 4, ret0, $spcopy.done + mfctl sar, t4 + add arg3, ret0, arg3 + extru t4, 28, 2, t4 + sub,<= ret0, t4, r0 + ldws,ma 4(sr1, arg1), t1 + vshd ret1, t1, t2 + b $spcopy.done + stbys,e t2, 0(sr2, arg3) + +$spcopy.cleanup1_un + b $spcopy.cleanup_un + copy t1, ret1 + +$spcopy.byte + comb,>=,n r0, ret0, $spcopy.done +$spcopy.byte_loop + ldbs,ma 1(sr1, arg1), t1 + addib,<> -1, ret0, $spcopy.byte_loop + stbs,ma t1, 1(sr2, arg3) +$spcopy.done + + + mtsp r0, sr1 + mtsp r0, sr2 + /* reset fault handler */ + stw r1, PCB_ONFAULT+U_PCB(r2) + ldw HPPA_FRAME_CRP(sp), rp + ldo -64(sp), sp + bv 0(rp) + copy r0, ret0 +EXIT(spcopy) +#endif + + .end diff --git a/sys/lib/libkern/arch/hppa64/Makefile.inc b/sys/lib/libkern/arch/hppa64/Makefile.inc deleted file mode 100644 index 7afa148c046..00000000000 --- a/sys/lib/libkern/arch/hppa64/Makefile.inc +++ /dev/null @@ -1,34 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.2 2007/10/13 19:28:14 kettenis Exp $ - -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - random.c strncpy.c strncmp.c strcmp.c memchr.c \ - memcmp.c memset.c strlen.c strlcpy.c strlcat.c \ - skpc.c strncasecmp.c \ - bcmp.c scanc.c ffs.c -SRCS+= divdi3.c moddi3.c muldi3.c qdivrem.c udivdi3.c umoddi3.c - -SRCS+= milli.S -OBJS+= bzero.o - -SRCS+= bcopy.S spcopy.S -CLEANFILES+= bcopy.S spcopy.S bzero.o - -bzero.o: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -X -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bzero.po: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -p -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -p -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -X -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bcopy.S: ${M}/bcopy.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @m4 -DNAME=bcopy ${.ALLSRC} > ${.TARGET} - -spcopy.S: ${M}/bcopy.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @m4 -DNAME=spcopy ${.ALLSRC} > ${.TARGET} diff --git a/sys/lib/libkern/arch/i386/Makefile.inc b/sys/lib/libkern/arch/i386/Makefile.inc deleted file mode 100644 index 6b8a7fc41b8..00000000000 --- a/sys/lib/libkern/arch/i386/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.9 2007/05/04 22:24:34 deraadt Exp $ -# $NetBSD: Makefile.inc,v 1.10 1996/04/13 01:17:41 cgd Exp $ - -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.S memcmp.S \ - bcmp.S ffs.S memset.S strcmp.S strlcat.c strlcpy.c \ - strlen.S strncmp.c \ - strncpy.c scanc.S skpc.S htonl.S htons.S ntohl.S ntohs.S \ - strncasecmp.c diff --git a/sys/lib/libkern/arch/i386/bcopy.S b/sys/lib/libkern/arch/i386/bcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/i386/bcopy.S diff --git a/sys/lib/libkern/arch/i386/bzero.S b/sys/lib/libkern/arch/i386/bzero.S index 2d1a1b1e59f..3bf97192de3 100644 --- a/sys/lib/libkern/arch/i386/bzero.S +++ b/sys/lib/libkern/arch/i386/bzero.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bzero.S,v 1.3 2007/05/25 20:32:29 krw Exp $ */ +/* $OpenBSD: bzero.S,v 1.4 2007/11/25 18:25:35 deraadt Exp $ */ /* * Written by J.T. Conklin <jtc@netbsd.org>. @@ -7,6 +7,7 @@ #include <machine/asm.h> +#ifndef _KERNEL ENTRY(bzero) pushl %edi movl 8(%esp),%edi @@ -42,3 +43,4 @@ L1: movl %edx,%ecx /* zero remainder by bytes */ popl %edi ret +#endif diff --git a/sys/lib/libkern/arch/i386/htonl.S b/sys/lib/libkern/arch/i386/htonl.S index 243efbe3b60..1d44d676ca0 100644 --- a/sys/lib/libkern/arch/i386/htonl.S +++ b/sys/lib/libkern/arch/i386/htonl.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htonl.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ +/* $OpenBSD: htonl.S,v 1.4 2007/11/25 18:25:35 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -36,8 +36,10 @@ #include <machine/asm.h> -/* netorder = htonl(hostorder) */ +/* netorder = htonl(hostorder) AND hostorder = ntohl(netorder) */ +ENTRY(ntohl) ENTRY(htonl) +ENTRY(swap32) movl 4(%esp),%eax rorw $8,%ax roll $16,%eax diff --git a/sys/lib/libkern/arch/i386/htons.S b/sys/lib/libkern/arch/i386/htons.S index ecb6ae18f12..d563ce8e642 100644 --- a/sys/lib/libkern/arch/i386/htons.S +++ b/sys/lib/libkern/arch/i386/htons.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htons.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ +/* $OpenBSD: htons.S,v 1.4 2007/11/25 18:25:35 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -36,8 +36,10 @@ #include <machine/asm.h> -/* netorder = htons(hostorder) */ +/* netorder = htons(hostorder) AND hostorder = ntohs(netorder) */ ENTRY(htons) +ENTRY(ntohs) +ENTRY(swap16) movzwl 4(%esp),%eax rorw $8,%ax ret diff --git a/sys/lib/libkern/arch/i386/memcpy.S b/sys/lib/libkern/arch/i386/memcpy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/i386/memcpy.S diff --git a/sys/lib/libkern/arch/i386/memmove.S b/sys/lib/libkern/arch/i386/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/i386/memmove.S diff --git a/sys/lib/libkern/arch/i386/ntohl.S b/sys/lib/libkern/arch/i386/ntohl.S deleted file mode 100644 index f4a069905aa..00000000000 --- a/sys/lib/libkern/arch/i386/ntohl.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - */ - -#include <machine/asm.h> - -/* hostorder = ntohl(netorder) */ -ENTRY(ntohl) - movl 4(%esp),%eax - rorw $8,%ax - roll $16,%eax - rorw $8,%ax - ret diff --git a/sys/lib/libkern/arch/i386/ntohs.S b/sys/lib/libkern/arch/i386/ntohs.S deleted file mode 100644 index a18aa154ab7..00000000000 --- a/sys/lib/libkern/arch/i386/ntohs.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * from: @(#)ntohs.s 5.2 (Berkeley) 12/17/90 - * $Id: ntohs.S,v 1.3 2003/06/02 23:28:08 millert Exp $ - */ - -#include <machine/asm.h> - -/* hostorder = ntohs(netorder) */ -ENTRY(ntohs) - movzwl 4(%esp),%eax - rorw $8,%ax - ret diff --git a/sys/lib/libkern/arch/i386/ovbcopy.S b/sys/lib/libkern/arch/i386/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/i386/ovbcopy.S diff --git a/sys/lib/libkern/arch/m68k/Makefile.inc b/sys/lib/libkern/arch/m68k/Makefile.inc deleted file mode 100644 index 9b52295e01e..00000000000 --- a/sys/lib/libkern/arch/m68k/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.10 2007/05/04 22:24:34 deraadt 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 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 \ - strncasecmp.c diff --git a/sys/lib/libkern/arch/m68k/bcopy.S b/sys/lib/libkern/arch/m68k/bcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/m68k/bcopy.S diff --git a/sys/lib/libkern/arch/m68k/htonl.S b/sys/lib/libkern/arch/m68k/htonl.S index 9400cd6b08a..22d8aaca2c1 100644 --- a/sys/lib/libkern/arch/m68k/htonl.S +++ b/sys/lib/libkern/arch/m68k/htonl.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htonl.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ +/* $OpenBSD: htonl.S,v 1.4 2007/11/25 18:25:35 deraadt Exp $ */ /* $NetBSD: htonl.S,v 1.2 1994/10/26 06:39:27 cgd Exp $ */ /*- @@ -34,18 +34,12 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) - .text -#ifdef notdef - .asciz "@(#)htonl.s 5.1 (Berkeley) 5/12/90" -#endif - .asciz "$OpenBSD: htonl.S,v 1.3 2003/06/02 23:28:08 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - /* netorder = htonl(hostorder) */ #include "DEFS.h" +ALTENTRY(ntohl, _htonl) +ALTENTRY(bswap32, _htonl) ENTRY(htonl) movl sp@(4),d0 rts diff --git a/sys/lib/libkern/arch/m68k/htons.S b/sys/lib/libkern/arch/m68k/htons.S index bc36d9fe707..d9b4a308931 100644 --- a/sys/lib/libkern/arch/m68k/htons.S +++ b/sys/lib/libkern/arch/m68k/htons.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htons.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ +/* $OpenBSD: htons.S,v 1.4 2007/11/25 18:25:35 deraadt Exp $ */ /* $NetBSD: htons.S,v 1.2 1994/10/26 06:39:27 cgd Exp $ */ /*- @@ -34,18 +34,12 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) - .text -#ifdef notdef - .asciz "@(#)htons.s 5.1 (Berkeley) 5/12/90" -#endif - .asciz "$OpenBSD: htons.S,v 1.3 2003/06/02 23:28:08 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - /* hostorder = htons(netorder) */ #include "DEFS.h" +ALTENTRY(ntohs, _htons) +ALTENTRY(bswap16, _htons) ENTRY(htons) clrl d0 movw sp@(6),d0 diff --git a/sys/lib/libkern/arch/m68k/memcpy.S b/sys/lib/libkern/arch/m68k/memcpy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/m68k/memcpy.S diff --git a/sys/lib/libkern/arch/m68k/memmove.S b/sys/lib/libkern/arch/m68k/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/m68k/memmove.S diff --git a/sys/lib/libkern/arch/m68k/ntohl.S b/sys/lib/libkern/arch/m68k/ntohl.S deleted file mode 100644 index f9fd525abfb..00000000000 --- a/sys/lib/libkern/arch/m68k/ntohl.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ -/* $NetBSD: ntohl.S,v 1.2 1994/10/26 06:39:29 cgd Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text -#ifdef notdef - .asciz "@(#)ntohl.s 5.1 (Berkeley) 5/12/90" -#endif - .asciz "$OpenBSD: ntohl.S,v 1.3 2003/06/02 23:28:08 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - movl sp@(4),d0 - rts diff --git a/sys/lib/libkern/arch/m68k/ntohs.S b/sys/lib/libkern/arch/m68k/ntohs.S deleted file mode 100644 index c399ae54a94..00000000000 --- a/sys/lib/libkern/arch/m68k/ntohs.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.3 2003/06/02 23:28:08 millert Exp $ */ -/* $NetBSD: ntohs.S,v 1.2 1994/10/26 06:39:30 cgd Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .text -#ifdef notdef - .asciz "@(#)ntohs.s 5.1 (Berkeley) 5/12/90" -#endif - .asciz "$OpenBSD: ntohs.S,v 1.3 2003/06/02 23:28:08 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - clrl d0 - movw sp@(6),d0 - rts diff --git a/sys/lib/libkern/arch/m68k/ovbcopy.S b/sys/lib/libkern/arch/m68k/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/m68k/ovbcopy.S diff --git a/sys/lib/libkern/arch/m88k/Makefile.inc b/sys/lib/libkern/arch/m88k/Makefile.inc deleted file mode 100644 index 74bbefb2a4a..00000000000 --- a/sys/lib/libkern/arch/m88k/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.9 2006/11/17 22:32:38 miod Exp $ - -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.c memcmp.c memset.c bcmp.c random.c \ - strcmp.c strlcat.c strlcpy.c strlen.c strncmp.c \ - strncpy.c scanc.c skpc.c strncasecmp.c ffs.c - -SRCS+= bcopy.S bzero.S memcpy.S memmove.S ovbcopy.S diff --git a/sys/lib/libkern/arch/mips64/Makefile.inc b/sys/lib/libkern/arch/mips64/Makefile.inc deleted file mode 100644 index 218798c2d1f..00000000000 --- a/sys/lib/libkern/arch/mips64/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1 2004/08/11 10:29:59 pefo Exp $ -# $NetBSD: Makefile.inc,v 1.4 1996/04/13 01:17:46 cgd Exp $ -# -# There are likely more that we will notice when we go native - -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.c memcmp.c memset.c strcmp.c \ - bcmp.S bcopy.S bzero.S strcmp.c strlcat.c strlcpy.c \ - ffs.S htonl.S \ - htons.S strcmp.S strlen.S strncmp.c random.c scanc.c skpc.c strncpy.c \ - strncasecmp.c - diff --git a/sys/lib/libkern/arch/powerpc/Makefile.inc b/sys/lib/libkern/arch/powerpc/Makefile.inc deleted file mode 100644 index bfb028f3e51..00000000000 --- a/sys/lib/libkern/arch/powerpc/Makefile.inc +++ /dev/null @@ -1,28 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.13 2007/05/04 22:24:34 deraadt Exp $ -# $NetBSD: Makefile.inc,v 1.6 1994/10/26 06:39:03 cgd Exp $ - -CFLAGS += -D_KERNEL - -SRCS+= __main.c __eabi.c \ - imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.c memcmp.c memset.c \ - bcmp.c ffs.c strcmp.c strlcat.c strlcpy.c \ - strlen.c strncmp.c \ - strncpy.c scanc.c skpc.c \ - memcpy.c random.c strncasecmp.c - -OBJS+= bzero.o -CLEANFILES+= bzero.o - -bzero.o: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bzero.po: ${KERNDIR}/memset.c - @echo "${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${KERNDIR}/memset.c -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - diff --git a/sys/lib/libkern/arch/powerpc/memmove.S b/sys/lib/libkern/arch/powerpc/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/powerpc/memmove.S diff --git a/sys/lib/libkern/arch/powerpc/ovbcopy.S b/sys/lib/libkern/arch/powerpc/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/powerpc/ovbcopy.S diff --git a/sys/lib/libkern/arch/sh/Makefile.inc b/sys/lib/libkern/arch/sh/Makefile.inc deleted file mode 100644 index 91ea18eece9..00000000000 --- a/sys/lib/libkern/arch/sh/Makefile.inc +++ /dev/null @@ -1,50 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1 2006/10/06 21:19:15 mickey Exp $ - -SRCS+= __main.c \ - bcmp.c imax.c imin.c lmax.c lmin.c max.c min.c random.c scanc.c \ - skpc.c strcmp.c strlen.c strncmp.c strncasecmp.c \ - strlcat.c strlcpy.c \ - strncpy.c ulmax.c ulmin.c - -SRCS+= ffs.S movstr_i4.S sdivsi3.S udivsi3.S -SRCS+= memchr.c memcmp.c memcpy.S memset.S - -OBJS+= bzero.o bcopy.o memmove.o -CLEANFILES+= bzero.o bcopy.o memmove.o - -bzero.o: ${M}/memset.S - @echo "${COMPILE.c} -DBZERO ${M}/memset.S -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${M}/memset.S -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bzero.po: ${M}/memset.S - @echo "${COMPILE.c} -DBZERO ${M}/memset.S -o ${.TARGET}" - @${COMPILE.c} -DBZERO ${M}/memset.S -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bcopy.o: ${M}/memcpy.S - @echo "${COMPILE.c} -DBCOPY ${M}/memcpy.S -o ${.TARGET}" - @${COMPILE.c} -DBCOPY ${M}/memcpy.S -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -bcopy.po: ${M}/memcpy.S - @echo "${COMPILE.c} -DBCOPY ${M}/memcpy.S -o ${.TARGET}" - @${COMPILE.c} -DBCOPY ${M}/memcpy.S -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -memmove.o: ${M}/memcpy.S - @echo "${COMPILE.c} -DMEMMOVE ${M}/memcpy.S -o ${.TARGET}" - @${COMPILE.c} -DMEMMOVE ${M}/memcpy.S -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - -memmove.po: ${M}/memcpy.S - @echo "${COMPILE.c} -DMEMMOVE ${M}/memcpy.S -o ${.TARGET}" - @${COMPILE.c} -DMEMMOVE ${M}/memcpy.S -o ${.TARGET}.o - @${LD} -x -r ${.TARGET}.o -o ${.TARGET} - @rm -f ${.TARGET}.o - diff --git a/sys/lib/libkern/arch/sh/bcopy.S b/sys/lib/libkern/arch/sh/bcopy.S new file mode 100644 index 00000000000..09b4a2a5c54 --- /dev/null +++ b/sys/lib/libkern/arch/sh/bcopy.S @@ -0,0 +1,2 @@ +#define BCOPY +#include "memcpy.S" diff --git a/sys/lib/libkern/arch/sh/memmove.S b/sys/lib/libkern/arch/sh/memmove.S new file mode 100644 index 00000000000..beda60b986a --- /dev/null +++ b/sys/lib/libkern/arch/sh/memmove.S @@ -0,0 +1,2 @@ +#define MEMMOVE +#include "memcpy.S" diff --git a/sys/lib/libkern/arch/sh/ovbcopy.S b/sys/lib/libkern/arch/sh/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sh/ovbcopy.S diff --git a/sys/lib/libkern/arch/sparc/Makefile.inc b/sys/lib/libkern/arch/sparc/Makefile index b2c73360f51..a7da47aa6ec 100644 --- a/sys/lib/libkern/arch/sparc/Makefile.inc +++ b/sys/lib/libkern/arch/sparc/Makefile @@ -1,20 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.11 2003/06/01 17:00:31 deraadt Exp $ +# $OpenBSD: Makefile,v 1.1 2007/11/25 18:25:36 deraadt Exp $ # $NetBSD: Makefile.inc,v 1.12 1996/04/23 23:05:22 christos Exp $ -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.c memcmp.c memset.c \ - bcmp.c bzero.S strcmp.c strlcat.c strlcpy.c \ - strlen.S strncmp.c \ - strncpy.c htonl.S htons.S ntohl.S ntohs.S scanc.c skpc.c \ - strncasecmp.c - -SRCS+= rem.S sdiv.S udiv.S urem.S -SRCS+= saveregs.S - -# `source' files built from m4 source -# the name `div.o' is taken for the ANSI C `div' function, hence sdiv here -SRCS+= rem.S sdiv.S udiv.S urem.S -CLEANFILES+=rem.S sdiv.S udiv.S urem.S +all: rem.S sdiv.S udiv.S urem.S sdiv.S: divrem.m4 echo 'building ${.TARGET} from ${.ALLSRC}' @@ -40,3 +27,4 @@ urem.S: divrem.m4 cat ${.ALLSRC}) | m4 > ${.TARGET} @chmod 444 ${.TARGET} +.include <bsd.own.mk> diff --git a/sys/lib/libkern/arch/sparc/bcopy.S b/sys/lib/libkern/arch/sparc/bcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc/bcopy.S diff --git a/sys/lib/libkern/arch/sparc/ffs.S b/sys/lib/libkern/arch/sparc/ffs.S index 9dade81b105..c4371332c4d 100644 --- a/sys/lib/libkern/arch/sparc/ffs.S +++ b/sys/lib/libkern/arch/sparc/ffs.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs.S,v 1.4 2007/11/24 19:43:36 deraadt Exp $ */ +/* $OpenBSD: ffs.S,v 1.5 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: ffs.S,v 1.2 1994/10/26 06:39:57 cgd Exp $ */ /* @@ -38,6 +38,7 @@ #include "DEFS.h" +#ifndef _KERNEL /* * ffs returns the number of the rightmost bit set in its argument, * i.e., the lowest value such that (x & (ffs(x) - 1)) is nonzero. @@ -105,3 +106,4 @@ ffstab: .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* d0-df */ .byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* e0-ef */ .byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* f0-ff */ +#endif diff --git a/sys/lib/libkern/arch/sparc/htonl.S b/sys/lib/libkern/arch/sparc/htonl.S index 368d4e926da..ccc691839c0 100644 --- a/sys/lib/libkern/arch/sparc/htonl.S +++ b/sys/lib/libkern/arch/sparc/htonl.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htonl.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: htonl.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: htonl.S,v 1.2 1994/10/26 06:39:58 cgd Exp $ */ /* @@ -36,17 +36,12 @@ * Header: htonl.s,v 1.1 92/06/25 12:47:05 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)htonl.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$OpenBSD: htonl.S,v 1.3 2003/06/02 23:28:09 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - /* netorder = htonl(hostorder) */ #include "DEFS.h" +_ENTRY(bswap32) +_ENTRY(ntohl) ENTRY(htonl) retl nop diff --git a/sys/lib/libkern/arch/sparc/htons.S b/sys/lib/libkern/arch/sparc/htons.S index f37b16bf22a..d490c75bdd3 100644 --- a/sys/lib/libkern/arch/sparc/htons.S +++ b/sys/lib/libkern/arch/sparc/htons.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htons.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: htons.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 @@ -35,17 +35,12 @@ * Header: htons.s,v 1.1 92/06/25 12:47:05 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)htons.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$OpenBSD: htons.S,v 1.3 2003/06/02 23:28:09 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - /* netorder = htons(hostorder) */ #include "DEFS.h" +_ENTRY(bswap16) +_ENTRY(ntohs) ENTRY(htons) sethi %hi(0xffff0000), %o1 retl diff --git a/sys/lib/libkern/arch/sparc/memcpy.S b/sys/lib/libkern/arch/sparc/memcpy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc/memcpy.S diff --git a/sys/lib/libkern/arch/sparc/memmove.S b/sys/lib/libkern/arch/sparc/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc/memmove.S diff --git a/sys/lib/libkern/arch/sparc/ntohl.S b/sys/lib/libkern/arch/sparc/ntohl.S deleted file mode 100644 index 85259e4d213..00000000000 --- a/sys/lib/libkern/arch/sparc/ntohl.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ -/* $NetBSD: ntohl.S,v 1.2 1994/10/26 06:40:03 cgd Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * Header: ntohl.s,v 1.1 92/06/25 12:47:06 torek Exp - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)ntohl.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$OpenBSD: ntohl.S,v 1.3 2003/06/02 23:28:09 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - retl - nop diff --git a/sys/lib/libkern/arch/sparc/ntohs.S b/sys/lib/libkern/arch/sparc/ntohs.S deleted file mode 100644 index 185ab5dd935..00000000000 --- a/sys/lib/libkern/arch/sparc/ntohs.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ -/* $NetBSD: ntohs.S,v 1.2 1994/10/26 06:40:05 cgd Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * Header: ntohs.s,v 1.1 92/06/25 12:47:07 torek Exp - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)ntohs.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$OpenBSD: ntohs.S,v 1.3 2003/06/02 23:28:09 millert Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - sethi %hi(0xffff0000), %o1 - retl - andn %o0, %o1, %o0 diff --git a/sys/lib/libkern/arch/sparc/ovbcopy.S b/sys/lib/libkern/arch/sparc/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc/ovbcopy.S diff --git a/sys/lib/libkern/arch/sparc/random.S b/sys/lib/libkern/arch/sparc/random.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc/random.S diff --git a/sys/lib/libkern/arch/sparc/rem.S b/sys/lib/libkern/arch/sparc/rem.S new file mode 100644 index 00000000000..76f774de0be --- /dev/null +++ b/sys/lib/libkern/arch/sparc/rem.S @@ -0,0 +1,434 @@ + +/* $OpenBSD: rem.S,v 1.1 2007/11/25 18:25:36 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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. 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 BY THE REGENTS AND CONTRIBUTORS `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 REGENTS OR CONTRIBUTORS 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. + * + * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp + */ + +/* + * Division and remainder, from Appendix E of the Sparc Version 8 + * Architecture Manual, with fixes from Gordon Irlam. + */ + +/* + * Input: dividend and divisor in %o0 and %o1 respectively. + * + * m4 parameters: + * .rem name of function to generate + * _C_LABEL(_rem) secondary name of function to generate + * rem rem=div => %o0 / %o1; rem=rem => %o0 % %o1 + * true true=true => signed; true=false => unsigned + * + * Algorithm parameters: + * N how many bits per iteration we try to get (4) + * WORDSIZE total number of bits (32) + * + * Derived constants: + * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken) + * TOPBITS number of bits in the top decade of a number + * + * Important variables: + * Q the partial quotient under development (initially 0) + * R the remainder so far, initially the dividend + * ITER number of main division loop iterations required; + * equal to ceil(log2(quotient) / N). Note that this + * is the log base (2^N) of the quotient. + * V the current comparand, initially divisor*2^(ITER*N-1) + * + * Cost: + * Current estimate for non-large dividend is + * ceil(log2(quotient) / N) * (10 + 7N/2) + C + * A large dividend is one greater than 2^(31-TOPBITS) and takes a + * different path, as the upper bits of the quotient must be developed + * one bit at a time. + */ + + + + + + + + + + + + + +/* m4 reminder: d => if a is b, then c, else d */ + + + + +/* + * This is the recursive definition for developing quotient digits. + * + * Parameters: + * $1 the current depth, 1 <= $1 <= 4 + * $2 the current accumulation of quotient bits + * 4 max depth + * + * We add a new bit to $2 and either recurse or insert the bits in + * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above; + * the condition codes are expected to reflect the input %o3, and are + * modified to reflect the output %o3. + */ + + +#include "DEFS.h" +#include <machine/trap.h> +#include <machine/asm.h> + + .globl _C_LABEL(_rem) +_C_LABEL(_rem): +FUNC(.rem) + ! compute sign of result; if neither is negative, no problem + orcc %o1, %o0, %g0 ! either negative? + bge 2f ! no, go do the divide + mov %o0, %g6 ! compute sign in any case + tst %o1 + bge 1f + tst %o0 + ! %o1 is definitely negative; %o0 might also be negative + bge 2f ! if %o0 not negative... + neg %o1 ! in any case, make %o1 nonneg +1: ! %o0 is negative, %o1 is nonnegative + neg %o0 ! make %o0 nonnegative +2: + + ! Ready to divide. Compute size of quotient; scale comparand. + orcc %o1, %g0, %o5 + bnz 1f + mov %o0, %o3 + + ! Divide by zero trap. If it returns, return 0 (about as + ! wrong as possible, but that is what SunOS does...). + t ST_DIV0 + retl + clr %o0 + +1: + cmp %o3, %o5 ! if %o1 exceeds %o0, done + blu Lgot_result ! (and algorithm fails otherwise) + clr %o2 + sethi %hi(1 << (32 - 4 - 1)), %g1 + cmp %o3, %g1 + blu Lnot_really_big + clr %o4 + + ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! as our usual N-at-a-shot divide step will cause overflow and havoc. + ! The number of bits in the result here is N*ITER+SC, where SC <= N. + ! Compute ITER in an unorthodox manner: know we need to shift V into + ! the top decade: so do not even bother to compare to R. + 1: + cmp %o5, %g1 + bgeu 3f + mov 1, %g7 + sll %o5, 4, %o5 + b 1b + inc %o4 + + ! Now compute %g7. + 2: addcc %o5, %o5, %o5 + bcc Lnot_too_big + inc %g7 + + ! We get here if the %o1 overflowed while shifting. + ! This means that %o3 has the high-order bit set. + ! Restore %o5 and subtract from %o3. + sll %g1, 4, %g1 ! high order bit + srl %o5, 1, %o5 ! rest of %o5 + add %o5, %g1, %o5 + b Ldo_single_div + dec %g7 + + Lnot_too_big: + 3: cmp %o5, %o3 + blu 2b + nop + be Ldo_single_div + nop + /* NB: these are commented out in the V8-Sparc manual as well */ + /* (I do not understand this) */ + ! %o5 > %o3: went too far: back up 1 step + ! srl %o5, 1, %o5 + ! dec %g7 + ! do single-bit divide steps + ! + ! We have to be careful here. We know that %o3 >= %o5, so we can do the + ! first divide step without thinking. BUT, the others are conditional, + ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high- + ! order bit set in the first step, just falling into the regular + ! division loop will mess up the first time around. + ! So we unroll slightly... + Ldo_single_div: + deccc %g7 + bl Lend_regular_divide + nop + sub %o3, %o5, %o3 + mov 1, %o2 + b Lend_single_divloop + nop + Lsingle_divloop: + sll %o2, 1, %o2 + bl 1f + srl %o5, 1, %o5 + ! %o3 >= 0 + sub %o3, %o5, %o3 + b 2f + inc %o2 + 1: ! %o3 < 0 + add %o3, %o5, %o3 + dec %o2 + 2: + Lend_single_divloop: + deccc %g7 + bge Lsingle_divloop + tst %o3 + b,a Lend_regular_divide + +Lnot_really_big: +1: + sll %o5, 4, %o5 + cmp %o5, %o3 + bleu 1b + inccc %o4 + be Lgot_result + dec %o4 + + tst %o3 ! set up for initial iteration +Ldivloop: + sll %o2, 4, %o2 + ! depth 1, accumulated bits 0 + bl L.1.16 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 2, accumulated bits 1 + bl L.2.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits 3 + bl L.3.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 7 + bl L.4.23 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (7*2+1), %o2 + +L.4.23: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (7*2-1), %o2 + + +L.3.19: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 5 + bl L.4.21 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (5*2+1), %o2 + +L.4.21: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (5*2-1), %o2 + + + +L.2.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits 1 + bl L.3.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 3 + bl L.4.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (3*2+1), %o2 + +L.4.19: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (3*2-1), %o2 + + +L.3.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 1 + bl L.4.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (1*2+1), %o2 + +L.4.17: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (1*2-1), %o2 + + + + +L.1.16: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 2, accumulated bits -1 + bl L.2.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits -1 + bl L.3.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -1 + bl L.4.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2+1), %o2 + +L.4.15: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2-1), %o2 + + +L.3.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -3 + bl L.4.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2+1), %o2 + +L.4.13: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2-1), %o2 + + + +L.2.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits -3 + bl L.3.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -5 + bl L.4.11 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2+1), %o2 + +L.4.11: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2-1), %o2 + + +L.3.13: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -7 + bl L.4.9 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2+1), %o2 + +L.4.9: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2-1), %o2 + + + + + 9: +Lend_regular_divide: + deccc %o4 + bge Ldivloop + tst %o3 + bl,a Lgot_result + ! non-restoring fixup here (one instruction only!) + add %o3, %o1, %o3 + + +Lgot_result: + ! check to see if answer should be < 0 + tst %g6 + bl,a 1f + neg %o3 +1: + retl + mov %o3, %o0 diff --git a/sys/lib/libkern/arch/sparc/sdiv.S b/sys/lib/libkern/arch/sparc/sdiv.S new file mode 100644 index 00000000000..f8df34329eb --- /dev/null +++ b/sys/lib/libkern/arch/sparc/sdiv.S @@ -0,0 +1,434 @@ + +/* $OpenBSD: sdiv.S,v 1.1 2007/11/25 18:25:36 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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. 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 BY THE REGENTS AND CONTRIBUTORS `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 REGENTS OR CONTRIBUTORS 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. + * + * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp + */ + +/* + * Division and remainder, from Appendix E of the Sparc Version 8 + * Architecture Manual, with fixes from Gordon Irlam. + */ + +/* + * Input: dividend and divisor in %o0 and %o1 respectively. + * + * m4 parameters: + * .div name of function to generate + * _C_LABEL(_div) secondary name of function to generate + * div div=div => %o0 / %o1; div=rem => %o0 % %o1 + * true true=true => signed; true=false => unsigned + * + * Algorithm parameters: + * N how many bits per iteration we try to get (4) + * WORDSIZE total number of bits (32) + * + * Derived constants: + * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken) + * TOPBITS number of bits in the top decade of a number + * + * Important variables: + * Q the partial quotient under development (initially 0) + * R the remainder so far, initially the dividend + * ITER number of main division loop iterations required; + * equal to ceil(log2(quotient) / N). Note that this + * is the log base (2^N) of the quotient. + * V the current comparand, initially divisor*2^(ITER*N-1) + * + * Cost: + * Current estimate for non-large dividend is + * ceil(log2(quotient) / N) * (10 + 7N/2) + C + * A large dividend is one greater than 2^(31-TOPBITS) and takes a + * different path, as the upper bits of the quotient must be developed + * one bit at a time. + */ + + + + + + + + + + + + + +/* m4 reminder: d => if a is b, then c, else d */ + + + + +/* + * This is the recursive definition for developing quotient digits. + * + * Parameters: + * $1 the current depth, 1 <= $1 <= 4 + * $2 the current accumulation of quotient bits + * 4 max depth + * + * We add a new bit to $2 and either recurse or insert the bits in + * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above; + * the condition codes are expected to reflect the input %o3, and are + * modified to reflect the output %o3. + */ + + +#include "DEFS.h" +#include <machine/trap.h> +#include <machine/asm.h> + + .globl _C_LABEL(_div) +_C_LABEL(_div): +FUNC(.div) + ! compute sign of result; if neither is negative, no problem + orcc %o1, %o0, %g0 ! either negative? + bge 2f ! no, go do the divide + xor %o1, %o0, %g6 ! compute sign in any case + tst %o1 + bge 1f + tst %o0 + ! %o1 is definitely negative; %o0 might also be negative + bge 2f ! if %o0 not negative... + neg %o1 ! in any case, make %o1 nonneg +1: ! %o0 is negative, %o1 is nonnegative + neg %o0 ! make %o0 nonnegative +2: + + ! Ready to divide. Compute size of quotient; scale comparand. + orcc %o1, %g0, %o5 + bnz 1f + mov %o0, %o3 + + ! Divide by zero trap. If it returns, return 0 (about as + ! wrong as possible, but that is what SunOS does...). + t ST_DIV0 + retl + clr %o0 + +1: + cmp %o3, %o5 ! if %o1 exceeds %o0, done + blu Lgot_result ! (and algorithm fails otherwise) + clr %o2 + sethi %hi(1 << (32 - 4 - 1)), %g1 + cmp %o3, %g1 + blu Lnot_really_big + clr %o4 + + ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! as our usual N-at-a-shot divide step will cause overflow and havoc. + ! The number of bits in the result here is N*ITER+SC, where SC <= N. + ! Compute ITER in an unorthodox manner: know we need to shift V into + ! the top decade: so do not even bother to compare to R. + 1: + cmp %o5, %g1 + bgeu 3f + mov 1, %g7 + sll %o5, 4, %o5 + b 1b + inc %o4 + + ! Now compute %g7. + 2: addcc %o5, %o5, %o5 + bcc Lnot_too_big + inc %g7 + + ! We get here if the %o1 overflowed while shifting. + ! This means that %o3 has the high-order bit set. + ! Restore %o5 and subtract from %o3. + sll %g1, 4, %g1 ! high order bit + srl %o5, 1, %o5 ! rest of %o5 + add %o5, %g1, %o5 + b Ldo_single_div + dec %g7 + + Lnot_too_big: + 3: cmp %o5, %o3 + blu 2b + nop + be Ldo_single_div + nop + /* NB: these are commented out in the V8-Sparc manual as well */ + /* (I do not understand this) */ + ! %o5 > %o3: went too far: back up 1 step + ! srl %o5, 1, %o5 + ! dec %g7 + ! do single-bit divide steps + ! + ! We have to be careful here. We know that %o3 >= %o5, so we can do the + ! first divide step without thinking. BUT, the others are conditional, + ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high- + ! order bit set in the first step, just falling into the regular + ! division loop will mess up the first time around. + ! So we unroll slightly... + Ldo_single_div: + deccc %g7 + bl Lend_regular_divide + nop + sub %o3, %o5, %o3 + mov 1, %o2 + b Lend_single_divloop + nop + Lsingle_divloop: + sll %o2, 1, %o2 + bl 1f + srl %o5, 1, %o5 + ! %o3 >= 0 + sub %o3, %o5, %o3 + b 2f + inc %o2 + 1: ! %o3 < 0 + add %o3, %o5, %o3 + dec %o2 + 2: + Lend_single_divloop: + deccc %g7 + bge Lsingle_divloop + tst %o3 + b,a Lend_regular_divide + +Lnot_really_big: +1: + sll %o5, 4, %o5 + cmp %o5, %o3 + bleu 1b + inccc %o4 + be Lgot_result + dec %o4 + + tst %o3 ! set up for initial iteration +Ldivloop: + sll %o2, 4, %o2 + ! depth 1, accumulated bits 0 + bl L.1.16 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 2, accumulated bits 1 + bl L.2.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits 3 + bl L.3.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 7 + bl L.4.23 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (7*2+1), %o2 + +L.4.23: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (7*2-1), %o2 + + +L.3.19: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 5 + bl L.4.21 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (5*2+1), %o2 + +L.4.21: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (5*2-1), %o2 + + + +L.2.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits 1 + bl L.3.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 3 + bl L.4.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (3*2+1), %o2 + +L.4.19: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (3*2-1), %o2 + + +L.3.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 1 + bl L.4.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (1*2+1), %o2 + +L.4.17: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (1*2-1), %o2 + + + + +L.1.16: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 2, accumulated bits -1 + bl L.2.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits -1 + bl L.3.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -1 + bl L.4.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2+1), %o2 + +L.4.15: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2-1), %o2 + + +L.3.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -3 + bl L.4.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2+1), %o2 + +L.4.13: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2-1), %o2 + + + +L.2.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits -3 + bl L.3.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -5 + bl L.4.11 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2+1), %o2 + +L.4.11: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2-1), %o2 + + +L.3.13: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -7 + bl L.4.9 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2+1), %o2 + +L.4.9: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2-1), %o2 + + + + + 9: +Lend_regular_divide: + deccc %o4 + bge Ldivloop + tst %o3 + bl,a Lgot_result + ! non-restoring fixup here (one instruction only!) + dec %o2 + + +Lgot_result: + ! check to see if answer should be < 0 + tst %g6 + bl,a 1f + neg %o2 +1: + retl + mov %o2, %o0 diff --git a/sys/lib/libkern/arch/sparc/udiv.S b/sys/lib/libkern/arch/sparc/udiv.S new file mode 100644 index 00000000000..c39eb76f72b --- /dev/null +++ b/sys/lib/libkern/arch/sparc/udiv.S @@ -0,0 +1,417 @@ + +/* $OpenBSD: udiv.S,v 1.1 2007/11/25 18:25:36 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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. 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 BY THE REGENTS AND CONTRIBUTORS `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 REGENTS OR CONTRIBUTORS 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. + * + * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp + */ + +/* + * Division and remainder, from Appendix E of the Sparc Version 8 + * Architecture Manual, with fixes from Gordon Irlam. + */ + +/* + * Input: dividend and divisor in %o0 and %o1 respectively. + * + * m4 parameters: + * .udiv name of function to generate + * _C_LABEL(_udiv) secondary name of function to generate + * div div=div => %o0 / %o1; div=rem => %o0 % %o1 + * false false=true => signed; false=false => unsigned + * + * Algorithm parameters: + * N how many bits per iteration we try to get (4) + * WORDSIZE total number of bits (32) + * + * Derived constants: + * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken) + * TOPBITS number of bits in the top decade of a number + * + * Important variables: + * Q the partial quotient under development (initially 0) + * R the remainder so far, initially the dividend + * ITER number of main division loop iterations required; + * equal to ceil(log2(quotient) / N). Note that this + * is the log base (2^N) of the quotient. + * V the current comparand, initially divisor*2^(ITER*N-1) + * + * Cost: + * Current estimate for non-large dividend is + * ceil(log2(quotient) / N) * (10 + 7N/2) + C + * A large dividend is one greater than 2^(31-TOPBITS) and takes a + * different path, as the upper bits of the quotient must be developed + * one bit at a time. + */ + + + + + + + + + + + + + +/* m4 reminder: d => if a is b, then c, else d */ + + + + +/* + * This is the recursive definition for developing quotient digits. + * + * Parameters: + * $1 the current depth, 1 <= $1 <= 4 + * $2 the current accumulation of quotient bits + * 4 max depth + * + * We add a new bit to $2 and either recurse or insert the bits in + * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above; + * the condition codes are expected to reflect the input %o3, and are + * modified to reflect the output %o3. + */ + + +#include "DEFS.h" +#include <machine/trap.h> +#include <machine/asm.h> + + .globl _C_LABEL(_udiv) +_C_LABEL(_udiv): +FUNC(.udiv) + + ! Ready to divide. Compute size of quotient; scale comparand. + orcc %o1, %g0, %o5 + bnz 1f + mov %o0, %o3 + + ! Divide by zero trap. If it returns, return 0 (about as + ! wrong as possible, but that is what SunOS does...). + t ST_DIV0 + retl + clr %o0 + +1: + cmp %o3, %o5 ! if %o1 exceeds %o0, done + blu Lgot_result ! (and algorithm fails otherwise) + clr %o2 + sethi %hi(1 << (32 - 4 - 1)), %g1 + cmp %o3, %g1 + blu Lnot_really_big + clr %o4 + + ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! as our usual N-at-a-shot divide step will cause overflow and havoc. + ! The number of bits in the result here is N*ITER+SC, where SC <= N. + ! Compute ITER in an unorthodox manner: know we need to shift V into + ! the top decade: so do not even bother to compare to R. + 1: + cmp %o5, %g1 + bgeu 3f + mov 1, %g7 + sll %o5, 4, %o5 + b 1b + inc %o4 + + ! Now compute %g7. + 2: addcc %o5, %o5, %o5 + bcc Lnot_too_big + inc %g7 + + ! We get here if the %o1 overflowed while shifting. + ! This means that %o3 has the high-order bit set. + ! Restore %o5 and subtract from %o3. + sll %g1, 4, %g1 ! high order bit + srl %o5, 1, %o5 ! rest of %o5 + add %o5, %g1, %o5 + b Ldo_single_div + dec %g7 + + Lnot_too_big: + 3: cmp %o5, %o3 + blu 2b + nop + be Ldo_single_div + nop + /* NB: these are commented out in the V8-Sparc manual as well */ + /* (I do not understand this) */ + ! %o5 > %o3: went too far: back up 1 step + ! srl %o5, 1, %o5 + ! dec %g7 + ! do single-bit divide steps + ! + ! We have to be careful here. We know that %o3 >= %o5, so we can do the + ! first divide step without thinking. BUT, the others are conditional, + ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high- + ! order bit set in the first step, just falling into the regular + ! division loop will mess up the first time around. + ! So we unroll slightly... + Ldo_single_div: + deccc %g7 + bl Lend_regular_divide + nop + sub %o3, %o5, %o3 + mov 1, %o2 + b Lend_single_divloop + nop + Lsingle_divloop: + sll %o2, 1, %o2 + bl 1f + srl %o5, 1, %o5 + ! %o3 >= 0 + sub %o3, %o5, %o3 + b 2f + inc %o2 + 1: ! %o3 < 0 + add %o3, %o5, %o3 + dec %o2 + 2: + Lend_single_divloop: + deccc %g7 + bge Lsingle_divloop + tst %o3 + b,a Lend_regular_divide + +Lnot_really_big: +1: + sll %o5, 4, %o5 + cmp %o5, %o3 + bleu 1b + inccc %o4 + be Lgot_result + dec %o4 + + tst %o3 ! set up for initial iteration +Ldivloop: + sll %o2, 4, %o2 + ! depth 1, accumulated bits 0 + bl L.1.16 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 2, accumulated bits 1 + bl L.2.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits 3 + bl L.3.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 7 + bl L.4.23 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (7*2+1), %o2 + +L.4.23: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (7*2-1), %o2 + + +L.3.19: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 5 + bl L.4.21 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (5*2+1), %o2 + +L.4.21: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (5*2-1), %o2 + + + +L.2.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits 1 + bl L.3.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 3 + bl L.4.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (3*2+1), %o2 + +L.4.19: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (3*2-1), %o2 + + +L.3.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 1 + bl L.4.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (1*2+1), %o2 + +L.4.17: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (1*2-1), %o2 + + + + +L.1.16: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 2, accumulated bits -1 + bl L.2.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits -1 + bl L.3.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -1 + bl L.4.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2+1), %o2 + +L.4.15: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2-1), %o2 + + +L.3.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -3 + bl L.4.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2+1), %o2 + +L.4.13: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2-1), %o2 + + + +L.2.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits -3 + bl L.3.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -5 + bl L.4.11 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2+1), %o2 + +L.4.11: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2-1), %o2 + + +L.3.13: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -7 + bl L.4.9 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2+1), %o2 + +L.4.9: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2-1), %o2 + + + + + 9: +Lend_regular_divide: + deccc %o4 + bge Ldivloop + tst %o3 + bl,a Lgot_result + ! non-restoring fixup here (one instruction only!) + dec %o2 + + +Lgot_result: + + retl + mov %o2, %o0 diff --git a/sys/lib/libkern/arch/sparc/urem.S b/sys/lib/libkern/arch/sparc/urem.S new file mode 100644 index 00000000000..e6ecff3eb4f --- /dev/null +++ b/sys/lib/libkern/arch/sparc/urem.S @@ -0,0 +1,417 @@ + +/* $OpenBSD: urem.S,v 1.1 2007/11/25 18:25:36 deraadt Exp $ */ +/* $NetBSD: divrem.m4,v 1.3 1995/04/22 09:37:39 pk Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * 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. 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 BY THE REGENTS AND CONTRIBUTORS `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 REGENTS OR CONTRIBUTORS 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. + * + * Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp + */ + +/* + * Division and remainder, from Appendix E of the Sparc Version 8 + * Architecture Manual, with fixes from Gordon Irlam. + */ + +/* + * Input: dividend and divisor in %o0 and %o1 respectively. + * + * m4 parameters: + * .urem name of function to generate + * _C_LABEL(_urem) secondary name of function to generate + * rem rem=div => %o0 / %o1; rem=rem => %o0 % %o1 + * false false=true => signed; false=false => unsigned + * + * Algorithm parameters: + * N how many bits per iteration we try to get (4) + * WORDSIZE total number of bits (32) + * + * Derived constants: + * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken) + * TOPBITS number of bits in the top decade of a number + * + * Important variables: + * Q the partial quotient under development (initially 0) + * R the remainder so far, initially the dividend + * ITER number of main division loop iterations required; + * equal to ceil(log2(quotient) / N). Note that this + * is the log base (2^N) of the quotient. + * V the current comparand, initially divisor*2^(ITER*N-1) + * + * Cost: + * Current estimate for non-large dividend is + * ceil(log2(quotient) / N) * (10 + 7N/2) + C + * A large dividend is one greater than 2^(31-TOPBITS) and takes a + * different path, as the upper bits of the quotient must be developed + * one bit at a time. + */ + + + + + + + + + + + + + +/* m4 reminder: d => if a is b, then c, else d */ + + + + +/* + * This is the recursive definition for developing quotient digits. + * + * Parameters: + * $1 the current depth, 1 <= $1 <= 4 + * $2 the current accumulation of quotient bits + * 4 max depth + * + * We add a new bit to $2 and either recurse or insert the bits in + * the quotient. %o3, %o2, and %o5 are inputs and outputs as defined above; + * the condition codes are expected to reflect the input %o3, and are + * modified to reflect the output %o3. + */ + + +#include "DEFS.h" +#include <machine/trap.h> +#include <machine/asm.h> + + .globl _C_LABEL(_urem) +_C_LABEL(_urem): +FUNC(.urem) + + ! Ready to divide. Compute size of quotient; scale comparand. + orcc %o1, %g0, %o5 + bnz 1f + mov %o0, %o3 + + ! Divide by zero trap. If it returns, return 0 (about as + ! wrong as possible, but that is what SunOS does...). + t ST_DIV0 + retl + clr %o0 + +1: + cmp %o3, %o5 ! if %o1 exceeds %o0, done + blu Lgot_result ! (and algorithm fails otherwise) + clr %o2 + sethi %hi(1 << (32 - 4 - 1)), %g1 + cmp %o3, %g1 + blu Lnot_really_big + clr %o4 + + ! Here the dividend is >= 2^(31-N) or so. We must be careful here, + ! as our usual N-at-a-shot divide step will cause overflow and havoc. + ! The number of bits in the result here is N*ITER+SC, where SC <= N. + ! Compute ITER in an unorthodox manner: know we need to shift V into + ! the top decade: so do not even bother to compare to R. + 1: + cmp %o5, %g1 + bgeu 3f + mov 1, %g7 + sll %o5, 4, %o5 + b 1b + inc %o4 + + ! Now compute %g7. + 2: addcc %o5, %o5, %o5 + bcc Lnot_too_big + inc %g7 + + ! We get here if the %o1 overflowed while shifting. + ! This means that %o3 has the high-order bit set. + ! Restore %o5 and subtract from %o3. + sll %g1, 4, %g1 ! high order bit + srl %o5, 1, %o5 ! rest of %o5 + add %o5, %g1, %o5 + b Ldo_single_div + dec %g7 + + Lnot_too_big: + 3: cmp %o5, %o3 + blu 2b + nop + be Ldo_single_div + nop + /* NB: these are commented out in the V8-Sparc manual as well */ + /* (I do not understand this) */ + ! %o5 > %o3: went too far: back up 1 step + ! srl %o5, 1, %o5 + ! dec %g7 + ! do single-bit divide steps + ! + ! We have to be careful here. We know that %o3 >= %o5, so we can do the + ! first divide step without thinking. BUT, the others are conditional, + ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high- + ! order bit set in the first step, just falling into the regular + ! division loop will mess up the first time around. + ! So we unroll slightly... + Ldo_single_div: + deccc %g7 + bl Lend_regular_divide + nop + sub %o3, %o5, %o3 + mov 1, %o2 + b Lend_single_divloop + nop + Lsingle_divloop: + sll %o2, 1, %o2 + bl 1f + srl %o5, 1, %o5 + ! %o3 >= 0 + sub %o3, %o5, %o3 + b 2f + inc %o2 + 1: ! %o3 < 0 + add %o3, %o5, %o3 + dec %o2 + 2: + Lend_single_divloop: + deccc %g7 + bge Lsingle_divloop + tst %o3 + b,a Lend_regular_divide + +Lnot_really_big: +1: + sll %o5, 4, %o5 + cmp %o5, %o3 + bleu 1b + inccc %o4 + be Lgot_result + dec %o4 + + tst %o3 ! set up for initial iteration +Ldivloop: + sll %o2, 4, %o2 + ! depth 1, accumulated bits 0 + bl L.1.16 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 2, accumulated bits 1 + bl L.2.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits 3 + bl L.3.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 7 + bl L.4.23 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (7*2+1), %o2 + +L.4.23: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (7*2-1), %o2 + + +L.3.19: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 5 + bl L.4.21 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (5*2+1), %o2 + +L.4.21: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (5*2-1), %o2 + + + +L.2.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits 1 + bl L.3.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits 3 + bl L.4.19 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (3*2+1), %o2 + +L.4.19: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (3*2-1), %o2 + + +L.3.17: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits 1 + bl L.4.17 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (1*2+1), %o2 + +L.4.17: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (1*2-1), %o2 + + + + +L.1.16: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 2, accumulated bits -1 + bl L.2.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 3, accumulated bits -1 + bl L.3.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -1 + bl L.4.15 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2+1), %o2 + +L.4.15: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-1*2-1), %o2 + + +L.3.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -3 + bl L.4.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2+1), %o2 + +L.4.13: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-3*2-1), %o2 + + + +L.2.15: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 3, accumulated bits -3 + bl L.3.13 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + ! depth 4, accumulated bits -5 + bl L.4.11 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2+1), %o2 + +L.4.11: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-5*2-1), %o2 + + +L.3.13: + ! remainder is negative + addcc %o3,%o5,%o3 + ! depth 4, accumulated bits -7 + bl L.4.9 + srl %o5,1,%o5 + ! remainder is positive + subcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2+1), %o2 + +L.4.9: + ! remainder is negative + addcc %o3,%o5,%o3 + b 9f + add %o2, (-7*2-1), %o2 + + + + + 9: +Lend_regular_divide: + deccc %o4 + bge Ldivloop + tst %o3 + bl,a Lgot_result + ! non-restoring fixup here (one instruction only!) + add %o3, %o1, %o3 + + +Lgot_result: + + retl + mov %o3, %o0 diff --git a/sys/lib/libkern/arch/sparc64/Makefile.inc b/sys/lib/libkern/arch/sparc64/Makefile.inc deleted file mode 100644 index 60ec5985400..00000000000 --- a/sys/lib/libkern/arch/sparc64/Makefile.inc +++ /dev/null @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.5 2003/06/01 17:00:31 deraadt Exp $ -# $NetBSD: Makefile.inc,v 1.4 2000/11/01 19:37:20 thorpej Exp $ - -SRCS+= __main.c \ - imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - bcmp.c ffs.S \ - memchr.c memcmp.c \ - strcmp.c strlen.S strlcpy.c strlcat.c \ - strncasecmp.c strncmp.c strncpy.c \ - scanc.c skpc.c \ - htonl.S htons.S ntohl.S ntohs.S diff --git a/sys/lib/libkern/arch/sparc64/_setjmp.S b/sys/lib/libkern/arch/sparc64/_setjmp.S index ee4a2080302..b2a8bcad120 100644 --- a/sys/lib/libkern/arch/sparc64/_setjmp.S +++ b/sys/lib/libkern/arch/sparc64/_setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: _setjmp.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: _setjmp.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: _setjmp.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ /* @@ -36,13 +36,6 @@ * Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: _setjmp.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - /* * C library -- _setjmp, _longjmp * diff --git a/sys/lib/libkern/arch/sparc64/bcopy.S b/sys/lib/libkern/arch/sparc64/bcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc64/bcopy.S diff --git a/sys/lib/libkern/arch/sparc64/bzero.S b/sys/lib/libkern/arch/sparc64/bzero.S index 4515d22182d..e69de29bb2d 100644 --- a/sys/lib/libkern/arch/sparc64/bzero.S +++ b/sys/lib/libkern/arch/sparc64/bzero.S @@ -1,162 +0,0 @@ -/* $OpenBSD: bzero.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ -/* $NetBSD: bzero.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * Header: bzero.s,v 1.1 92/06/25 12:52:46 torek Exp - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)bzero.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: bzero.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - -#include "DEFS.h" - -/* - * bzero(addr, len) - * - * We should unroll the loop, but at the moment this would - * gain nothing since the `std' instructions are what limits us. - * - * I just changed all the `std's to `stx's. It still needs proper - * optimization using the block load/store ASIs. - */ -ENTRY(bzero) -#ifdef NOT_DEBUG - save %sp, -176, %sp - mov %i0, %o1 - set 9f, %o0 - call prom_printf - mov %i1, %o2 - ba 8f - restore -9: .asciz "bzero(%p,%x)\r\n" - .align 4 -8: -#endif - ! %o0 = addr, %o1 = len - - ! Optimize a common case: addr and len are both multiples of 8. - or %o0, %o1, %o2 - andcc %o2, 7, %g0 ! ((addr | len) & 7) != 0? - bnz 1f ! if so, cannot optimize - clr %g1 ! in any case, we want g1=0 - - /* `Good' operands, can just store doubles. */ -0: - deccc 8, %o1 ! while ((len -= 8) >= 0) - bge,a 0b - stx %g0, [%o0 + %o1] ! *(quad *)(addr + len) = 0; - retl - nop - - /* - * Either the address is unaligned, or the count is not a - * multiple of 8, or both. We will have to align the address - * in order to use anything `better' than stb. - */ -1: - cmp %o1, 15 ! len >= 15? - bge,a Lstd ! yes, use std - andcc %o0, 1, %g0 ! (but first check alignment) - - ! not enough to bother: do byte-at-a-time loop. -2: - deccc %o1 ! while (--len >= 0) - bge,a 2b - stb %g0, [%o0 + %o1] ! addr[len] = 0; - retl - nop - -Lstd: - /* - * There are at least 15 bytes to zero. - * We may have to zero some initial stuff to align - * the address. - */ - bz,a 1f ! if (addr & 1) { - andcc %o0, 2, %g0 - stb %g0, [%o0] ! *addr = 0; - inc %o0 ! addr++; - dec %o1 ! len--; - andcc %o0, 2, %g0 ! } -1: - bz,a 1f ! if (addr & 2) { - andcc %o0, 4, %g0 - sth %g0, [%o0] ! *(short *)addr = 0; - inc 2, %o0 ! addr += 2; - dec 2, %o1 ! len -= 2; - andcc %o0, 4, %g0 ! } -1: - bz 1f ! if (addr & 4) { - dec 8, %o1 - st %g0, [%o0] ! *(int *)addr = 0; - inc 4, %o0 ! addr += 4; - dec 4, %o1 ! len -= 4; - ! } - /* - * Address is double word aligned; len is 8 less than - * the number of bytes remaining (i.e., len is 0 if - * the remaining count is 8, 1 if it is 9, etc.). - */ -1: - stx %g0, [%o0] ! do { -2: ! *(quad *)addr = 0; - inc 8, %o0 ! addr += 8; - deccc 8, %o1 ! } while ((len -= 8) >= 0); - bge,a 2b - stx %g0, [%o0] - - /* - * Len is in [-8..-1] where -8 => done, -7 => 1 byte to zero, - * -6 => two bytes, etc. Mop up this remainder, if any. - */ - andcc %o1, 4, %g0 - bz 1f ! if (len & 4) { - andcc %o1, 2, %g0 - st %g0, [%o0] ! *(int *)addr = 0; - inc 4, %o0 ! addr += 4; -1: - bz 1f ! if (len & 2) { - andcc %o1, 1, %g0 - sth %g0, [%o0] ! *(short *)addr = 0; - inc 2, %o0 ! addr += 2; -1: - bnz,a 1f ! if (len & 1) - stb %g0, [%o0] ! *addr = 0; -1: - retl - nop diff --git a/sys/lib/libkern/arch/sparc64/ffs.S b/sys/lib/libkern/arch/sparc64/ffs.S index 935b5c609d6..4edbb2e100e 100644 --- a/sys/lib/libkern/arch/sparc64/ffs.S +++ b/sys/lib/libkern/arch/sparc64/ffs.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: ffs.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: ffs.S,v 1.2 1998/11/26 19:32:10 eeh Exp $ */ /* @@ -36,13 +36,6 @@ * Header: ffs.s,v 1.3 92/07/07 00:23:57 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)ffs.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: ffs.S,v 1.2 1998/11/26 19:32:10 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - #include "DEFS.h" /* diff --git a/sys/lib/libkern/arch/sparc64/htonl.S b/sys/lib/libkern/arch/sparc64/htonl.S index bd92c1da76a..f88e87f0ee6 100644 --- a/sys/lib/libkern/arch/sparc64/htonl.S +++ b/sys/lib/libkern/arch/sparc64/htonl.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htonl.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: htonl.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: htonl.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ /* @@ -36,13 +36,6 @@ * Header: htonl.s,v 1.1 92/06/25 12:47:05 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)htonl.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: htonl.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - /* netorder = htonl(hostorder) */ #include "DEFS.h" diff --git a/sys/lib/libkern/arch/sparc64/htons.S b/sys/lib/libkern/arch/sparc64/htons.S index 943a04d4c9e..64d718ebb46 100644 --- a/sys/lib/libkern/arch/sparc64/htons.S +++ b/sys/lib/libkern/arch/sparc64/htons.S @@ -1,4 +1,4 @@ -/* $OpenBSD: htons.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: htons.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -34,13 +34,6 @@ * Header: htons.s,v 1.1 92/06/25 12:47:05 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)htons.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: htons.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - /* netorder = htons(hostorder) */ #include "DEFS.h" diff --git a/sys/lib/libkern/arch/sparc64/memcpy.S b/sys/lib/libkern/arch/sparc64/memcpy.S new file mode 100644 index 00000000000..c1783be24fc --- /dev/null +++ b/sys/lib/libkern/arch/sparc64/memcpy.S @@ -0,0 +1 @@ +/* In locore */ diff --git a/sys/lib/libkern/arch/sparc64/memmove.S b/sys/lib/libkern/arch/sparc64/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc64/memmove.S diff --git a/sys/lib/libkern/arch/sparc64/memset.S b/sys/lib/libkern/arch/sparc64/memset.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc64/memset.S diff --git a/sys/lib/libkern/arch/sparc64/ntohl.S b/sys/lib/libkern/arch/sparc64/ntohl.S deleted file mode 100644 index 6c13f9bd4bd..00000000000 --- a/sys/lib/libkern/arch/sparc64/ntohl.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ -/* $NetBSD: ntohl.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * Header: ntohl.s,v 1.1 92/06/25 12:47:06 torek Exp - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)ntohl.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: ntohl.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohl(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohl) - retl - nop diff --git a/sys/lib/libkern/arch/sparc64/ntohs.S b/sys/lib/libkern/arch/sparc64/ntohs.S deleted file mode 100644 index e36932e8f7a..00000000000 --- a/sys/lib/libkern/arch/sparc64/ntohs.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ -/* $NetBSD: ntohs.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. 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 BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. - * - * Header: ntohs.s,v 1.1 92/06/25 12:47:07 torek Exp - */ - -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)ntohs.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: ntohs.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - -/* hostorder = ntohs(netorder) */ - -#include "DEFS.h" - -ENTRY(ntohs) - sethi %hi(0xffff0000), %o1 - retl - andn %o0, %o1, %o0 diff --git a/sys/lib/libkern/arch/sparc64/ovbcopy.S b/sys/lib/libkern/arch/sparc64/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/sparc64/ovbcopy.S diff --git a/sys/lib/libkern/arch/sparc64/random.S b/sys/lib/libkern/arch/sparc64/random.S index a5d554cedf3..e69de29bb2d 100644 --- a/sys/lib/libkern/arch/sparc64/random.S +++ b/sys/lib/libkern/arch/sparc64/random.S @@ -1,89 +0,0 @@ -/* $OpenBSD: random.S,v 1.2 2001/08/20 20:15:29 jason Exp $ */ -/* $NetBSD: random.S,v 1.1.1.1 1998/06/20 05:18:14 eeh 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 -randseed: - .long 1 - .text -ENTRY(random) - sethi %hi(16807), %o1 - wr %o1, %lo(16807), %y - sethi %hi(randseed), %g1 - ld [%g1 + %lo(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(randseed)] -1: - or %o1, %lo(0x7fffffff), %o1 - add %o0, 1, %o0 - and %o1, %o0, %o0 - retl - st %o0, [%g1 + %lo(randseed)] diff --git a/sys/lib/libkern/arch/sparc64/setjmp.S b/sys/lib/libkern/arch/sparc64/setjmp.S index 38df5a781ee..a94b179f54a 100644 --- a/sys/lib/libkern/arch/sparc64/setjmp.S +++ b/sys/lib/libkern/arch/sparc64/setjmp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: setjmp.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: setjmp.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: setjmp.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ /* @@ -36,13 +36,6 @@ * Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: setjmp.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - /* * C library -- setjmp, longjmp * diff --git a/sys/lib/libkern/arch/sparc64/strlen.S b/sys/lib/libkern/arch/sparc64/strlen.S index 7f8fb0cd467..091cdc70f36 100644 --- a/sys/lib/libkern/arch/sparc64/strlen.S +++ b/sys/lib/libkern/arch/sparc64/strlen.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strlen.S,v 1.3 2003/06/02 23:28:09 millert Exp $ */ +/* $OpenBSD: strlen.S,v 1.4 2007/11/25 18:25:36 deraadt Exp $ */ /* $NetBSD: strlen.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $ */ /* @@ -36,13 +36,6 @@ * Header: strlen.s,v 1.1 92/06/25 12:52:47 torek Exp */ -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef - .asciz "@(#)strlen.s 8.1 (Berkeley) 6/4/93" -#endif - .asciz "$NetBSD: strlen.S,v 1.1.1.1 1998/06/20 05:18:14 eeh Exp $" -#endif /* LIBC_SCCS and not lint */ - #include "DEFS.h" ENTRY(strlen) diff --git a/sys/lib/libkern/arch/vax/Makefile.inc b/sys/lib/libkern/arch/vax/Makefile.inc deleted file mode 100644 index 2ca3980045d..00000000000 --- a/sys/lib/libkern/arch/vax/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.7 2003/06/01 17:00:32 deraadt Exp $ -# $NetBSD: Makefile.inc,v 1.2 1996/04/13 01:17:58 cgd Exp $ - -SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - memchr.c memcmp.c \ - strcmp.c strlcat.c strlcpy.c strlen.c strncmp.c \ - strncpy.c scanc.c skpc.c strncasecmp.c diff --git a/sys/lib/libkern/arch/vax/bcmp.S b/sys/lib/libkern/arch/vax/bcmp.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/vax/bcmp.S diff --git a/sys/lib/libkern/arch/vax/bcopy.S b/sys/lib/libkern/arch/vax/bcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/vax/bcopy.S diff --git a/sys/lib/libkern/arch/vax/bzero.S b/sys/lib/libkern/arch/vax/bzero.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/vax/bzero.S diff --git a/sys/lib/libkern/arch/vax/memmove.S b/sys/lib/libkern/arch/vax/memmove.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/vax/memmove.S diff --git a/sys/lib/libkern/arch/vax/ovbcopy.S b/sys/lib/libkern/arch/vax/ovbcopy.S new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/lib/libkern/arch/vax/ovbcopy.S diff --git a/sys/lib/libkern/arch/powerpc/memcpy.c b/sys/lib/libkern/memcpy.c index f0c53b47de8..b843b0abf86 100644 --- a/sys/lib/libkern/arch/powerpc/memcpy.c +++ b/sys/lib/libkern/memcpy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memcpy.c,v 1.2 2003/06/02 23:28:08 millert Exp $ */ +/* $OpenBSD: memcpy.c,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ /* $NetBSD: bcopy.c,v 1.5 1995/04/22 13:46:50 cgd Exp $ */ /*- diff --git a/sys/lib/libkern/ntohl.c b/sys/lib/libkern/ntohl.c deleted file mode 100644 index 08176301eea..00000000000 --- a/sys/lib/libkern/ntohl.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: ntohl.c,v 1.5 2004/11/28 07:23:41 mickey Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <machine/endian.h> - -#undef ntohl - -u_int32_t -ntohl(x) - u_int32_t x; -{ -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *)&x; - return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); -#else - return x; -#endif -} diff --git a/sys/lib/libkern/ntohs.c b/sys/lib/libkern/ntohs.c deleted file mode 100644 index 1de67f63cad..00000000000 --- a/sys/lib/libkern/ntohs.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Written by J.T. Conklin <jtc@netbsd.org>. - * Public domain. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: ntohs.c,v 1.5 2004/11/28 07:23:41 mickey Exp $"; -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> -#include <machine/endian.h> - -#undef ntohs - -u_int16_t -ntohs(u_int16_t x) -{ -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *) &x; - return (u_int16_t)(s[0] << 8 | s[1]); -#else - return x; -#endif -} diff --git a/sys/lib/libkern/strchr.c b/sys/lib/libkern/strchr.c index d4ede9b8e9d..9af2ea0ac5c 100644 --- a/sys/lib/libkern/strchr.c +++ b/sys/lib/libkern/strchr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.c,v 1.3 2004/05/06 01:12:05 deraadt Exp $ */ +/* $OpenBSD: strchr.c,v 1.4 2007/11/25 18:25:34 deraadt Exp $ */ /* * Copyright (c) 2004 Daniel Hartmeier @@ -30,10 +30,6 @@ * */ -#if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strchr.c,v 1.3 2004/05/06 01:12:05 deraadt Exp $"; -#endif /* LIBC_SCCS and not lint */ - #include <sys/types.h> #if !defined(_KERNEL) && !defined(_STANDALONE) #include <string.h> @@ -52,16 +48,3 @@ strchr(const char *s, int c) } return (NULL); } - -char * -strrchr(const char *s, int c) -{ - char *t = NULL; - - while (*s) { - if (*s == c) - t = (char *)s; - s++; - } - return (t); -} diff --git a/sys/lib/libkern/strrchr.c b/sys/lib/libkern/strrchr.c new file mode 100644 index 00000000000..05ac5b7ff5f --- /dev/null +++ b/sys/lib/libkern/strrchr.c @@ -0,0 +1,52 @@ +/* $OpenBSD: strrchr.c,v 1.1 2007/11/25 18:25:34 deraadt Exp $ */ + +/* + * Copyright (c) 2004 Daniel Hartmeier + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "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 + * COPYRIGHT HOLDERS OR CONTRIBUTORS 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. + * + */ + +#include <sys/types.h> +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include <string.h> +#else +#include <lib/libkern/libkern.h> +#define NULL ((char *)0) +#endif + +char * +strrchr(const char *s, int c) +{ + char *t = NULL; + + while (*s) { + if (*s == c) + t = (char *)s; + s++; + } + return (t); +} |