From: Sascha Wildner Date: Thu, 30 Jul 2015 17:35:45 +0000 (+0200) Subject: i386 removal, part 26/x: Remove i386 specific lib/libc/quad. X-Git-Tag: v4.3.1~6 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/f32ed374dd2e99875dbe3008a30ac6fa60a300c3 i386 removal, part 26/x: Remove i386 specific lib/libc/quad. None of the platforms which lead to it being compiled into FreeBSD's libc look too interesting, so remove it. Also remove copies of a number of those functions residing in libkern and stop compiling one of these files into libstand. Libstand also has a quad.h header. Shrink it together to what is actually needed (not much), while here. --- diff --git a/lib/libc/Makefile b/lib/libc/Makefile index 88e55733d9..ce8ee18ca4 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -21,16 +21,13 @@ VERSION_DEF= ${.CURDIR}/Versions.def SYMBOL_MAPS= ${CMAPS} .endif -KQSRCS= 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 KSRCS= bcmp.c ffs.c index.c mcount.c rindex.c strcat.c strcmp.c strcpy.c \ strlen.c strncpy.c libkern: libkern.gen libkern.${MACHINE_ARCH} -libkern.gen: ${KQSRCS} ${KSRCS} - cp -p ${.CURDIR}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern +libkern.gen: ${KSRCS} + cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern libkern.${MACHINE_ARCH}:: ${KMSRCS} .if defined(KMSRCS) && !empty(KMSRCS) diff --git a/lib/libc/Makefile.inc b/lib/libc/Makefile.inc index c94c6db78c..fc05846672 100644 --- a/lib/libc/Makefile.inc +++ b/lib/libc/Makefile.inc @@ -26,9 +26,6 @@ WARNS=2 .include "${.CURDIR}/../libc/locale/Makefile.inc" .include "${.CURDIR}/../libc/net/Makefile.inc" .include "${.CURDIR}/../libc/nls/Makefile.inc" -.if ${MACHINE_ARCH} != "x86_64" -.include "${.CURDIR}/../libc/quad/Makefile.inc" -.endif .include "${.CURDIR}/../libc/regex/Makefile.inc" .include "${.CURDIR}/../libc/resolv/Makefile.inc" .include "${.CURDIR}/../libc/stdio/Makefile.inc" diff --git a/lib/libc/quad/Makefile.inc b/lib/libc/quad/Makefile.inc deleted file mode 100644 index 4eb7ff730a..0000000000 --- a/lib/libc/quad/Makefile.inc +++ /dev/null @@ -1,13 +0,0 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD: src/lib/libc/quad/Makefile.inc,v 1.8 1999/08/28 00:00:27 peter Exp $ - -CMAPS+= ${.CURDIR}/quad/Symbol.map - -# Quad support, if needed -.PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/quad ${.CURDIR}/../libc/quad - -SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c fixdfdi.c \ - fixsfdi.c fixunsdfdi.c fixunssfdi.c floatdidf.c floatdisf.c \ - floatunsdidf.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 diff --git a/lib/libc/quad/Symbol.map b/lib/libc/quad/Symbol.map deleted file mode 100644 index 0fd72c6691..0000000000 --- a/lib/libc/quad/Symbol.map +++ /dev/null @@ -1,9 +0,0 @@ -DFprivate_1.0 { - __cmpdi2; - __divdi3; - __moddi3; - __qdivrem; - __ucmpdi2; - __udivdi3; - __umoddi3; -}; diff --git a/lib/libc/quad/TESTS/Makefile b/lib/libc/quad/TESTS/Makefile deleted file mode 100644 index 5834f21e80..0000000000 --- a/lib/libc/quad/TESTS/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# @(#)Makefile 8.1 (Berkeley) 6/4/93 - -all: mul divrem - -MUL= mul.c ../muldi3.c -mul: ${MUL} - gcc -g -DSPARC_XXX ${MUL} -o ${.TARGET} - -DIVREM= divrem.c ../qdivrem.c -divrem: ${DIVREM} - gcc -g -DSPARC_XXX ${DIVREM} -o ${.TARGET} diff --git a/lib/libc/quad/TESTS/divrem.c b/lib/libc/quad/TESTS/divrem.c deleted file mode 100644 index f205c30fea..0000000000 --- a/lib/libc/quad/TESTS/divrem.c +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#) Copyright (c) 1992, 1993 The Regents of the University of California. All rights reserved. - * @(#)divrem.c 8.1 (Berkeley) 6/4/93 - */ - -#include - -main() -{ - union { long long q; unsigned long v[2]; } a, b, q, r; - char buf[300]; - extern long long __qdivrem(unsigned long long, unsigned long long, - unsigned long long *); - - for (;;) { - printf("> "); - if (fgets(buf, sizeof buf, stdin) == NULL) - break; - if (sscanf(buf, "%lu:%lu %lu:%lu", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 && - sscanf(buf, "0x%lx:%lx 0x%lx:%lx", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) { - printf("eh?\n"); - continue; - } - q.q = __qdivrem(a.q, b.q, &r.q); - printf("%lx:%lx /%% %lx:%lx => q=%lx:%lx r=%lx:%lx\n", - a.v[0], a.v[1], b.v[0], b.v[1], - q.v[0], q.v[1], r.v[0], r.v[1]); - printf(" = %lX%08lX / %lX%08lX => %lX%08lX\n\ - = %lX%08lX %% %lX%08lX => %lX%08lX\n", - a.v[0], a.v[1], b.v[0], b.v[1], q.v[0], q.v[1], - a.v[0], a.v[1], b.v[0], b.v[1], r.v[0], r.v[1]); - } - exit(0); -} diff --git a/lib/libc/quad/TESTS/mul.c b/lib/libc/quad/TESTS/mul.c deleted file mode 100644 index 9085f10a54..0000000000 --- a/lib/libc/quad/TESTS/mul.c +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#) Copyright (c) 1992, 1993 The Regents of the University of California. All rights reserved. - * @(#)mul.c 8.1 (Berkeley) 6/4/93 - */ - -#include - -main() -{ - union { long long q; unsigned long v[2]; } a, b, m; - char buf[300]; - extern long long __muldi3(long long, long long); - - for (;;) { - printf("> "); - if (fgets(buf, sizeof buf, stdin) == NULL) - break; - if (sscanf(buf, "%lu:%lu %lu:%lu", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 && - sscanf(buf, "0x%lx:%lx 0x%lx:%lx", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) { - printf("eh?\n"); - continue; - } - m.q = __muldi3(a.q, b.q); - printf("%lx:%lx * %lx:%lx => %lx:%lx\n", - a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]); - printf(" = %lX%08lX * %lX%08lX => %lX%08lX\n", - a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]); - } - exit(0); -} diff --git a/lib/libc/quad/adddi3.c b/lib/libc/quad/adddi3.c deleted file mode 100644 index 69a5212ae1..0000000000 --- a/lib/libc/quad/adddi3.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * 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. - * - * @(#)adddi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/adddi3.c,v 1.3 2007/01/09 00:28:02 imp Exp $ - */ - -#include "quad.h" - -/* - * Add two quads. This is trivial since a one-bit carry from a single - * u_long addition x+y occurs if and only if the sum x+y is less than - * either x or y (the choice to compare with x or y is arbitrary). - */ -quad_t -__adddi3(quad_t a, quad_t b) -{ - union uu aa, bb, sum; - - aa.q = a; - bb.q = b; - sum.ul[L] = aa.ul[L] + bb.ul[L]; - sum.ul[H] = aa.ul[H] + bb.ul[H] + (sum.ul[L] < bb.ul[L]); - return (sum.q); -} diff --git a/lib/libc/quad/anddi3.c b/lib/libc/quad/anddi3.c deleted file mode 100644 index ad5f53ac01..0000000000 --- a/lib/libc/quad/anddi3.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * @(#)anddi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/anddi3.c,v 1.3 2007/01/09 00:28:02 imp Exp $ - */ - -#include "quad.h" - -/* - * Return a & b, in quad. - */ -quad_t -__anddi3(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - aa.ul[0] &= bb.ul[0]; - aa.ul[1] &= bb.ul[1]; - return (aa.q); -} diff --git a/lib/libc/quad/ashldi3.c b/lib/libc/quad/ashldi3.c deleted file mode 100644 index 2bc905c8cb..0000000000 --- a/lib/libc/quad/ashldi3.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * 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. - * - * @(#)ashldi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/ashldi3.c,v 1.3 2007/01/09 00:28:02 imp Exp $ - */ - -#include "quad.h" - -/* - * Shift a (signed) quad value left (arithmetic shift left). - * This is the same as logical shift left! - */ -quad_t -__ashldi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - aa.ul[H] = shift >= QUAD_BITS ? 0 : - aa.ul[L] << (shift - LONG_BITS); - aa.ul[L] = 0; - } else if (shift > 0) { - aa.ul[H] = (aa.ul[H] << shift) | - (aa.ul[L] >> (LONG_BITS - shift)); - aa.ul[L] <<= shift; - } - return (aa.q); -} diff --git a/lib/libc/quad/ashrdi3.c b/lib/libc/quad/ashrdi3.c deleted file mode 100644 index 7aae2273d0..0000000000 --- a/lib/libc/quad/ashrdi3.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * 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. - * - * @(#)ashrdi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/ashrdi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Shift a (signed) quad value right (arithmetic shift right). - */ -quad_t -__ashrdi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - long s; - - /* - * Smear bits rightward using the machine's right-shift - * method, whether that is sign extension or zero fill, - * to get the `sign word' s. Note that shifting by - * LONG_BITS is undefined, so we shift (LONG_BITS-1), - * then 1 more, to get our answer. - */ - s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1; - aa.ul[L] = shift >= QUAD_BITS ? s : - aa.sl[H] >> (shift - LONG_BITS); - aa.ul[H] = s; - } else if (shift > 0) { - aa.ul[L] = (aa.ul[L] >> shift) | - (aa.ul[H] << (LONG_BITS - shift)); - aa.sl[H] >>= shift; - } - return (aa.q); -} diff --git a/lib/libc/quad/cmpdi2.c b/lib/libc/quad/cmpdi2.c deleted file mode 100644 index 802e19157a..0000000000 --- a/lib/libc/quad/cmpdi2.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * 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. - * - * @(#)cmpdi2.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/cmpdi2.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/cmpdi2.c,v 1.3 2005/11/13 02:13:52 swildner Exp $ - */ - -#include "quad.h" - -/* - * Return 0, 1, or 2 as a <, =, > b respectively. - * Both a and b are considered signed---which means only the high word is - * signed. - */ -int -__cmpdi2(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 : - aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1); -} diff --git a/lib/libc/quad/divdi3.c b/lib/libc/quad/divdi3.c deleted file mode 100644 index a4c4a53764..0000000000 --- a/lib/libc/quad/divdi3.c +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * 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. - * - * @(#)divdi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/divdi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/divdi3.c,v 1.3 2005/11/13 02:13:52 swildner Exp $ - */ - -#include "quad.h" - -/* - * Divide two signed quads. - * ??? if -1/2 should produce -1 on this machine, this code is wrong - */ -quad_t -__divdi3(quad_t a, quad_t b) -{ - u_quad_t ua, ub, uq; - int neg; - - if (a < 0) - ua = -(u_quad_t)a, neg = 1; - else - ua = a, neg = 0; - if (b < 0) - ub = -(u_quad_t)b, neg ^= 1; - else - ub = b; - uq = __qdivrem(ua, ub, (u_quad_t *)0); - return (neg ? -uq : uq); -} diff --git a/lib/libc/quad/fixdfdi.c b/lib/libc/quad/fixdfdi.c deleted file mode 100644 index 299e08302c..0000000000 --- a/lib/libc/quad/fixdfdi.c +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * 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. - * - * @(#)fixdfdi.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/fixdfdi.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Convert double to (signed) quad. - * We clamp anything that is out of range. - */ -quad_t -__fixdfdi(double x) -{ - if (x < 0) - if (x <= QUAD_MIN) - return (QUAD_MIN); - else - return ((quad_t)-(u_quad_t)-x); - else - if (x >= QUAD_MAX) - return (QUAD_MAX); - else - return ((quad_t)(u_quad_t)x); -} diff --git a/lib/libc/quad/fixsfdi.c b/lib/libc/quad/fixsfdi.c deleted file mode 100644 index eb39be80af..0000000000 --- a/lib/libc/quad/fixsfdi.c +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * Copyright (c) 1992 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. - * - * @(#)fixsfdi.c 5.1 (Berkeley) 7/7/92 - * $FreeBSD: src/lib/libc/quad/fixsfdi.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Convert float to (signed) quad. - * We clamp anything that is out of range. - * - * N.B.: must use new ANSI syntax (sorry). - */ -long long -__fixsfdi(float x) -{ - if (x < 0) - if (x <= QUAD_MIN) - return (QUAD_MIN); - else - return ((quad_t)-(u_quad_t)-x); - else - if (x >= QUAD_MAX) - return (QUAD_MAX); - else - return ((quad_t)(u_quad_t)x); -} diff --git a/lib/libc/quad/fixunsdfdi.c b/lib/libc/quad/fixunsdfdi.c deleted file mode 100644 index 4e71eaea1e..0000000000 --- a/lib/libc/quad/fixunsdfdi.c +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * 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. - * - * @(#)fixunsdfdi.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/fixunsdfdi.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -#define ONE_FOURTH (1 << (LONG_BITS - 2)) -#define ONE_HALF (ONE_FOURTH * 2.0) -#define ONE (ONE_FOURTH * 4.0) - -/* - * Convert double to (unsigned) quad. - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - */ -u_quad_t -__fixunsdfdi(double x) -{ - double toppart; - union uu t; - - if (x < 0) - return (UQUAD_MAX); /* ??? should be 0? ERANGE??? */ -#ifdef notdef /* this falls afoul of a GCC bug */ - if (x >= UQUAD_MAX) - return (UQUAD_MAX); -#else /* so we wire in 2^64-1 instead */ - if (x >= 18446744073709551615.0) - return (UQUAD_MAX); -#endif - /* - * Get the upper part of the result. Note that the divide - * may round up; we want to avoid this if possible, so we - * subtract `1/2' first. - */ - toppart = (x - ONE_HALF) / ONE; - /* - * Now build a u_quad_t out of the top part. The difference - * between x and this is the bottom part (this may introduce - * a few fuzzy bits, but what the heck). With any luck this - * difference will be nonnegative: x should wind up in the - * range [0..ULONG_MAX]. For paranoia, we assume [LONG_MIN.. - * 2*ULONG_MAX] instead. - */ - t.ul[H] = (unsigned long)toppart; - t.ul[L] = 0; - x -= (double)t.uq; - if (x < 0) { - t.ul[H]--; - x += ULONG_MAX; - } - if (x > ULONG_MAX) { - t.ul[H]++; - x -= ULONG_MAX; - } - t.ul[L] = (u_long)x; - return (t.uq); -} diff --git a/lib/libc/quad/fixunssfdi.c b/lib/libc/quad/fixunssfdi.c deleted file mode 100644 index 6462b26bdb..0000000000 --- a/lib/libc/quad/fixunssfdi.c +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * 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. - * - * @(#)fixunssfdi.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/fixunssfdi.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -#define ONE_FOURTH (1 << (LONG_BITS - 2)) -#define ONE_HALF (ONE_FOURTH * 2.0) -#define ONE (ONE_FOURTH * 4.0) - -/* - * Convert float to (unsigned) quad. We do most of our work in double, - * out of sheer paranoia. - * - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - * - * N.B.: must use new ANSI syntax (sorry). - */ -u_quad_t -__fixunssfdi(float f) -{ - double x, toppart; - union uu t; - - if (f < 0) - return (UQUAD_MAX); /* ??? should be 0? ERANGE??? */ -#ifdef notdef /* this falls afoul of a GCC bug */ - if (f >= UQUAD_MAX) - return (UQUAD_MAX); -#else /* so we wire in 2^64-1 instead */ - if (f >= 18446744073709551615.0) - return (UQUAD_MAX); -#endif - x = f; - /* - * Get the upper part of the result. Note that the divide - * may round up; we want to avoid this if possible, so we - * subtract `1/2' first. - */ - toppart = (x - ONE_HALF) / ONE; - /* - * Now build a u_quad_t out of the top part. The difference - * between x and this is the bottom part (this may introduce - * a few fuzzy bits, but what the heck). With any luck this - * difference will be nonnegative: x should wind up in the - * range [0..ULONG_MAX]. For paranoia, we assume [LONG_MIN.. - * 2*ULONG_MAX] instead. - */ - t.ul[H] = (unsigned long)toppart; - t.ul[L] = 0; - x -= (double)t.uq; - if (x < 0) { - t.ul[H]--; - x += ULONG_MAX; - } - if (x > ULONG_MAX) { - t.ul[H]++; - x -= ULONG_MAX; - } - t.ul[L] = (u_long)x; - return (t.uq); -} diff --git a/lib/libc/quad/floatdidf.c b/lib/libc/quad/floatdidf.c deleted file mode 100644 index 9c132c35c1..0000000000 --- a/lib/libc/quad/floatdidf.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * 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. - * - * @(#)floatdidf.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/floatdidf.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Convert (signed) quad to double. - */ -double -__floatdidf(quad_t x) -{ - double d; - union uu u; - int neg; - - /* - * Get an unsigned number first, by negating if necessary. - */ - if (x < 0) - u.q = -x, neg = 1; - else - u.q = x, neg = 0; - - /* - * Now u.ul[H] has the factor of 2^32 (or whatever) and u.ul[L] - * has the units. Ideally we could just set d, add LONG_BITS to - * its exponent, and then add the units, but this is portable - * code and does not know how to get at an exponent. Machine- - * specific code may be able to do this more efficiently. - */ - d = (double)u.ul[H] * ((1 << (LONG_BITS - 2)) * 4.0); - d += u.ul[L]; - - return (neg ? -d : d); -} diff --git a/lib/libc/quad/floatdisf.c b/lib/libc/quad/floatdisf.c deleted file mode 100644 index 7b4197a5bf..0000000000 --- a/lib/libc/quad/floatdisf.c +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * 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. - * - * @(#)floatdisf.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/floatdisf.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Convert (signed) quad to float. - */ -float -__floatdisf(quad_t x) -{ - float f; - union uu u; - int neg; - - /* - * Get an unsigned number first, by negating if necessary. - */ - if (x < 0) - u.q = -x, neg = 1; - else - u.q = x, neg = 0; - - /* - * Now u.ul[H] has the factor of 2^32 (or whatever) and u.ul[L] - * has the units. Ideally we could just set f, add LONG_BITS to - * its exponent, and then add the units, but this is portable - * code and does not know how to get at an exponent. Machine- - * specific code may be able to do this more efficiently. - * - * Using double here may be excessive paranoia. - */ - f = (double)u.ul[H] * ((1 << (LONG_BITS - 2)) * 4.0); - f += u.ul[L]; - - return (neg ? -f : f); -} diff --git a/lib/libc/quad/floatunsdidf.c b/lib/libc/quad/floatunsdidf.c deleted file mode 100644 index cfe66c9c8f..0000000000 --- a/lib/libc/quad/floatunsdidf.c +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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. - * - * @(#)floatunsdidf.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/floatunsdidf.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Convert (unsigned) quad to double. - * This is exactly like floatdidf.c except that negatives never occur. - */ -double -__floatunsdidf(u_quad_t x) -{ - double d; - union uu u; - - u.uq = x; - d = (double)u.ul[H] * ((1 << (LONG_BITS - 2)) * 4.0); - d += u.ul[L]; - return (d); -} diff --git a/lib/libc/quad/iordi3.c b/lib/libc/quad/iordi3.c deleted file mode 100644 index bb321503f1..0000000000 --- a/lib/libc/quad/iordi3.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * @(#)iordi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/iordi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Return a | b, in quad. - */ -quad_t -__iordi3(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - aa.ul[0] |= bb.ul[0]; - aa.ul[1] |= bb.ul[1]; - return (aa.q); -} diff --git a/lib/libc/quad/lshldi3.c b/lib/libc/quad/lshldi3.c deleted file mode 100644 index fb2b19c940..0000000000 --- a/lib/libc/quad/lshldi3.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * 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. - * - * @(#)lshldi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/lshldi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Shift an (unsigned) quad value left (logical shift left). - * This is the same as arithmetic shift left! - */ -quad_t -__lshldi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - aa.ul[H] = shift >= QUAD_BITS ? 0 : - aa.ul[L] << (shift - LONG_BITS); - aa.ul[L] = 0; - } else if (shift > 0) { - aa.ul[H] = (aa.ul[H] << shift) | - (aa.ul[L] >> (LONG_BITS - shift)); - aa.ul[L] <<= shift; - } - return (aa.q); -} diff --git a/lib/libc/quad/lshrdi3.c b/lib/libc/quad/lshrdi3.c deleted file mode 100644 index 4bdfea283f..0000000000 --- a/lib/libc/quad/lshrdi3.c +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * 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. - * - * @(#)lshrdi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/lshrdi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Shift an (unsigned) quad value right (logical shift right). - */ -quad_t -__lshrdi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - aa.ul[L] = shift >= QUAD_BITS ? 0 : - aa.ul[H] >> (shift - LONG_BITS); - aa.ul[H] = 0; - } else if (shift > 0) { - aa.ul[L] = (aa.ul[L] >> shift) | - (aa.ul[H] << (LONG_BITS - shift)); - aa.ul[H] >>= shift; - } - return (aa.q); -} diff --git a/lib/libc/quad/moddi3.c b/lib/libc/quad/moddi3.c deleted file mode 100644 index a177a23004..0000000000 --- a/lib/libc/quad/moddi3.c +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * 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. - * - * @(#)moddi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/moddi3.c,v 1.4 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/moddi3.c,v 1.3 2005/11/13 02:13:52 swildner Exp $ - */ - -#include "quad.h" - -/* - * Return remainder after dividing two signed quads. - * - * XXX - * If -1/2 should produce -1 on this machine, this code is wrong. - */ -quad_t -__moddi3(quad_t a, quad_t b) -{ - u_quad_t ua, ub, ur; - int neg; - - if (a < 0) - ua = -(u_quad_t)a, neg = 1; - else - ua = a, neg = 0; - if (b < 0) - ub = -(u_quad_t)b; - else - ub = b; - __qdivrem(ua, ub, &ur); - return (neg ? -ur : ur); -} diff --git a/lib/libc/quad/muldi3.c b/lib/libc/quad/muldi3.c deleted file mode 100644 index 1d22e67620..0000000000 --- a/lib/libc/quad/muldi3.c +++ /dev/null @@ -1,241 +0,0 @@ -/*- - * 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. - * - * @(#)muldi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/muldi3.c,v 1.4 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/muldi3.c,v 1.3 2004/10/25 19:38:01 drhodus Exp $ - */ - -#include "quad.h" - -/* - * Multiply two quads. - * - * Our algorithm is based on the following. Split incoming quad values - * u and v (where u,v >= 0) into - * - * u = 2^n u1 * u0 (n = number of bits in `u_long', usu. 32) - * - * and - * - * v = 2^n v1 * v0 - * - * Then - * - * uv = 2^2n u1 v1 + 2^n u1 v0 + 2^n v1 u0 + u0 v0 - * = 2^2n u1 v1 + 2^n (u1 v0 + v1 u0) + u0 v0 - * - * Now add 2^n u1 v1 to the first term and subtract it from the middle, - * and add 2^n u0 v0 to the last term and subtract it from the middle. - * This gives: - * - * uv = (2^2n + 2^n) (u1 v1) + - * (2^n) (u1 v0 - u1 v1 + u0 v1 - u0 v0) + - * (2^n + 1) (u0 v0) - * - * Factoring the middle a bit gives us: - * - * uv = (2^2n + 2^n) (u1 v1) + [u1v1 = high] - * (2^n) (u1 - u0) (v0 - v1) + [(u1-u0)... = mid] - * (2^n + 1) (u0 v0) [u0v0 = low] - * - * The terms (u1 v1), (u1 - u0) (v0 - v1), and (u0 v0) can all be done - * in just half the precision of the original. (Note that either or both - * of (u1 - u0) or (v0 - v1) may be negative.) - * - * This algorithm is from Knuth vol. 2 (2nd ed), section 4.3.3, p. 278. - * - * Since C does not give us a `long * long = quad' operator, we split - * our input quads into two longs, then split the two longs into two - * shorts. We can then calculate `short * short = long' in native - * arithmetic. - * - * Our product should, strictly speaking, be a `long quad', with 128 - * bits, but we are going to discard the upper 64. In other words, - * we are not interested in uv, but rather in (uv mod 2^2n). This - * makes some of the terms above vanish, and we get: - * - * (2^n)(high) + (2^n)(mid) + (2^n + 1)(low) - * - * or - * - * (2^n)(high + mid + low) + low - * - * Furthermore, `high' and `mid' can be computed mod 2^n, as any factor - * of 2^n in either one will also vanish. Only `low' need be computed - * mod 2^2n, and only because of the final term above. - */ -static quad_t __lmulq(u_long, u_long); - -quad_t -__muldi3(quad_t a, quad_t b) -{ - union uu u, v, low, prod; - u_long high, mid, udiff, vdiff; - int negall, negmid; -#define u1 u.ul[H] -#define u0 u.ul[L] -#define v1 v.ul[H] -#define v0 v.ul[L] - - /* - * Get u and v such that u, v >= 0. When this is finished, - * u1, u0, v1, and v0 will be directly accessible through the - * longword fields. - */ - if (a >= 0) - u.q = a, negall = 0; - else - u.q = -a, negall = 1; - if (b >= 0) - v.q = b; - else - v.q = -b, negall ^= 1; - - if (u1 == 0 && v1 == 0) { - /* - * An (I hope) important optimization occurs when u1 and v1 - * are both 0. This should be common since most numbers - * are small. Here the product is just u0*v0. - */ - prod.q = __lmulq(u0, v0); - } else { - /* - * Compute the three intermediate products, remembering - * whether the middle term is negative. We can discard - * any upper bits in high and mid, so we can use native - * u_long * u_long => u_long arithmetic. - */ - low.q = __lmulq(u0, v0); - - if (u1 >= u0) - negmid = 0, udiff = u1 - u0; - else - negmid = 1, udiff = u0 - u1; - if (v0 >= v1) - vdiff = v0 - v1; - else - vdiff = v1 - v0, negmid ^= 1; - mid = udiff * vdiff; - - high = u1 * v1; - - /* - * Assemble the final product. - */ - prod.ul[H] = high + (negmid ? -mid : mid) + low.ul[L] + - low.ul[H]; - prod.ul[L] = low.ul[L]; - } - return (negall ? -prod.q : prod.q); -#undef u1 -#undef u0 -#undef v1 -#undef v0 -} - -/* - * Multiply two 2N-bit longs to produce a 4N-bit quad, where N is half - * the number of bits in a long (whatever that is---the code below - * does not care as long as quad.h does its part of the bargain---but - * typically N==16). - * - * We use the same algorithm from Knuth, but this time the modulo refinement - * does not apply. On the other hand, since N is half the size of a long, - * we can get away with native multiplication---none of our input terms - * exceeds (ULONG_MAX >> 1). - * - * Note that, for u_long l, the quad-precision result - * - * l << N - * - * splits into high and low longs as HHALF(l) and LHUP(l) respectively. - */ -static quad_t -__lmulq(u_long u, u_long v) -{ - u_long u1, u0, v1, v0, udiff, vdiff, high, mid, low; - u_long prodh, prodl, was; - union uu prod; - int neg; - - u1 = HHALF(u); - u0 = LHALF(u); - v1 = HHALF(v); - v0 = LHALF(v); - - low = u0 * v0; - - /* This is the same small-number optimization as before. */ - if (u1 == 0 && v1 == 0) - return (low); - - if (u1 >= u0) - udiff = u1 - u0, neg = 0; - else - udiff = u0 - u1, neg = 1; - if (v0 >= v1) - vdiff = v0 - v1; - else - vdiff = v1 - v0, neg ^= 1; - mid = udiff * vdiff; - - high = u1 * v1; - - /* prod = (high << 2N) + (high << N); */ - prodh = high + HHALF(high); - prodl = LHUP(high); - - /* if (neg) prod -= mid << N; else prod += mid << N; */ - if (neg) { - was = prodl; - prodl -= LHUP(mid); - prodh -= HHALF(mid) + (prodl > was); - } else { - was = prodl; - prodl += LHUP(mid); - prodh += HHALF(mid) + (prodl < was); - } - - /* prod += low << N */ - was = prodl; - prodl += LHUP(low); - prodh += HHALF(low) + (prodl < was); - /* ... + low; */ - if ((prodl += low) < low) - prodh++; - - /* return 4N-bit product */ - prod.ul[H] = prodh; - prod.ul[L] = prodl; - return (prod.q); -} diff --git a/lib/libc/quad/negdi2.c b/lib/libc/quad/negdi2.c deleted file mode 100644 index 09a1c0e5d2..0000000000 --- a/lib/libc/quad/negdi2.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * 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. - * - * @(#)negdi2.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/negdi2.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Return -a (or, equivalently, 0 - a), in quad. See subdi3.c. - */ -quad_t -__negdi2(quad_t a) -{ - union uu aa, res; - - aa.q = a; - res.ul[L] = -aa.ul[L]; - res.ul[H] = -aa.ul[H] - (res.ul[L] > 0); - return (res.q); -} diff --git a/lib/libc/quad/notdi2.c b/lib/libc/quad/notdi2.c deleted file mode 100644 index a3adf60a12..0000000000 --- a/lib/libc/quad/notdi2.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * @(#)notdi2.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/notdi2.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Return ~a. For some reason gcc calls this `one's complement' rather - * than `not'. - */ -quad_t -__one_cmpldi2(quad_t a) -{ - union uu aa; - - aa.q = a; - aa.ul[0] = ~aa.ul[0]; - aa.ul[1] = ~aa.ul[1]; - return (aa.q); -} diff --git a/lib/libc/quad/qdivrem.c b/lib/libc/quad/qdivrem.c deleted file mode 100644 index e710123862..0000000000 --- a/lib/libc/quad/qdivrem.c +++ /dev/null @@ -1,274 +0,0 @@ -/*- - * 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. - * - * @(#)qdivrem.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/qdivrem.c,v 1.4 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/qdivrem.c,v 1.5 2005/11/20 09:18:37 swildner Exp $ - */ - -/* - * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), - * section 4.3.1, pp. 257--259. - */ - -#include "quad.h" - -#define B (1 << HALF_BITS) /* digit base */ - -/* Combine two `digits' to make a single two-digit number. */ -#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b)) - -/* select a type for digits in base B: use unsigned short if they fit */ -#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff -typedef unsigned short digit; -#else -typedef u_long digit; -#endif - -/* - * Shift p[0]..p[len] left `sh' bits, ignoring any bits that - * `fall out' the left (there never will be any such anyway). - * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. - */ -static void -shl(digit *p, int len, int sh) -{ - int i; - - for (i = 0; i < len; i++) - p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); - p[i] = LHALF(p[i] << sh); -} - -/* - * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v. - * - * We do this in base 2-sup-HALF_BITS, so that all intermediate products - * fit within u_long. As a consequence, the maximum length dividend and - * divisor are 4 `digits' in this base (they are shorter if they have - * leading zeros). - */ -u_quad_t -__qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq) -{ - union uu tmp; - digit *u, *v, *q; - digit v1, v2; - u_long qhat, rhat, t; - int m, n, d, j, i; - digit uspace[5], vspace[5], qspace[5]; - - /* - * Take care of special cases: divide by zero, and u < v. - */ - if (vq == 0) { - /* divide by zero. */ - static volatile const unsigned int zero = 0; - - tmp.ul[H] = tmp.ul[L] = 1 / zero; - if (arq) - *arq = uq; - return (tmp.q); - } - if (uq < vq) { - if (arq) - *arq = uq; - return (0); - } - u = &uspace[0]; - v = &vspace[0]; - q = &qspace[0]; - - /* - * Break dividend and divisor into digits in base B, then - * count leading zeros to determine m and n. When done, we - * will have: - * u = (u[1]u[2]...u[m+n]) sub B - * v = (v[1]v[2]...v[n]) sub B - * v[1] != 0 - * 1 < n <= 4 (if n = 1, we use a different division algorithm) - * m >= 0 (otherwise u < v, which we already checked) - * m + n = 4 - * and thus - * m = 4 - n <= 2 - */ - tmp.uq = uq; - u[0] = 0; - u[1] = HHALF(tmp.ul[H]); - u[2] = LHALF(tmp.ul[H]); - u[3] = HHALF(tmp.ul[L]); - u[4] = LHALF(tmp.ul[L]); - tmp.uq = vq; - v[1] = HHALF(tmp.ul[H]); - v[2] = LHALF(tmp.ul[H]); - v[3] = HHALF(tmp.ul[L]); - v[4] = LHALF(tmp.ul[L]); - for (n = 4; v[1] == 0; v++) { - if (--n == 1) { - u_long rbj; /* r*B+u[j] (not root boy jim) */ - digit q1, q2, q3, q4; - - /* - * Change of plan, per exercise 16. - * r = 0; - * for j = 1..4: - * q[j] = floor((r*B + u[j]) / v), - * r = (r*B + u[j]) % v; - * We unroll this completely here. - */ - t = v[2]; /* nonzero, by definition */ - q1 = u[1] / t; - rbj = COMBINE(u[1] % t, u[2]); - q2 = rbj / t; - rbj = COMBINE(rbj % t, u[3]); - q3 = rbj / t; - rbj = COMBINE(rbj % t, u[4]); - q4 = rbj / t; - if (arq) - *arq = rbj % t; - tmp.ul[H] = COMBINE(q1, q2); - tmp.ul[L] = COMBINE(q3, q4); - return (tmp.q); - } - } - - /* - * By adjusting q once we determine m, we can guarantee that - * there is a complete four-digit quotient at &qspace[1] when - * we finally stop. - */ - for (m = 4 - n; u[1] == 0; u++) - m--; - for (i = 4 - m; --i >= 0;) - q[i] = 0; - q += 4 - m; - - /* - * Here we run Program D, translated from MIX to C and acquiring - * a few minor changes. - * - * D1: choose multiplier 1 << d to ensure v[1] >= B/2. - */ - d = 0; - for (t = v[1]; t < B / 2; t <<= 1) - d++; - if (d > 0) { - shl(&u[0], m + n, d); /* u <<= d */ - shl(&v[1], n - 1, d); /* v <<= d */ - } - /* - * D2: j = 0. - */ - j = 0; - v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ - v2 = v[2]; /* for D3 */ - do { - digit uj0, uj1, uj2; - - /* - * D3: Calculate qhat (\^q, in TeX notation). - * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and - * let rhat = (u[j]*B + u[j+1]) mod v[1]. - * While rhat < B and v[2]*qhat > rhat*B+u[j+2], - * decrement qhat and increase rhat correspondingly. - * Note that if rhat >= B, v[2]*qhat < rhat*B. - */ - uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ - uj1 = u[j + 1]; /* for D3 only */ - uj2 = u[j + 2]; /* for D3 only */ - if (uj0 == v1) { - qhat = B; - rhat = uj1; - goto qhat_too_big; - } else { - u_long n1 = COMBINE(uj0, uj1); - qhat = n1 / v1; - rhat = n1 % v1; - } - while (v2 * qhat > COMBINE(rhat, uj2)) { - qhat_too_big: - qhat--; - if ((rhat += v1) >= B) - break; - } - /* - * D4: Multiply and subtract. - * The variable `t' holds any borrows across the loop. - * We split this up so that we do not require v[0] = 0, - * and to eliminate a final special case. - */ - for (t = 0, i = n; i > 0; i--) { - t = u[i + j] - v[i] * qhat - t; - u[i + j] = LHALF(t); - t = (B - HHALF(t)) & (B - 1); - } - t = u[j] - t; - u[j] = LHALF(t); - /* - * D5: test remainder. - * There is a borrow if and only if HHALF(t) is nonzero; - * in that (rare) case, qhat was too large (by exactly 1). - * Fix it by adding v[1..n] to u[j..j+n]. - */ - if (HHALF(t)) { - qhat--; - for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ - t += u[i + j] + v[i]; - u[i + j] = LHALF(t); - t = HHALF(t); - } - u[j] = LHALF(u[j] + t); - } - q[j] = qhat; - } while (++j <= m); /* D7: loop on j. */ - - /* - * If caller wants the remainder, we have to calculate it as - * u[m..m+n] >> d (this is at most n digits and thus fits in - * u[m+1..m+n], but we may need more source digits). - */ - if (arq) { - if (d) { - for (i = m + n; i > m; --i) - u[i] = (u[i] >> d) | - LHALF(u[i - 1] << (HALF_BITS - d)); - u[i] = 0; - } - tmp.ul[H] = COMBINE(uspace[1], uspace[2]); - tmp.ul[L] = COMBINE(uspace[3], uspace[4]); - *arq = tmp.q; - } - - tmp.ul[H] = COMBINE(qspace[1], qspace[2]); - tmp.ul[L] = COMBINE(qspace[3], qspace[4]); - return (tmp.q); -} diff --git a/lib/libc/quad/quad.h b/lib/libc/quad/quad.h deleted file mode 100644 index f4c3fea0e0..0000000000 --- a/lib/libc/quad/quad.h +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * 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. - * 4. 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. - * - * @(#)quad.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/quad.h,v 1.8 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/quad.h,v 1.3 2003/11/12 20:21:25 eirikn Exp $ - */ - -/* - * Quad arithmetic. - * - * This library makes the following assumptions: - * - * - The type long long (aka quad_t) exists. - * - * - A quad variable is exactly twice as long as `long'. - * - * - The machine's arithmetic is two's complement. - * - * This library can provide 128-bit arithmetic on a machine with 128-bit - * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines - * with 48-bit longs. - */ - -#include -#include - -/* - * Depending on the desired operation, we view a `long long' (aka quad_t) in - * one or more of the following formats. - */ -union uu { - quad_t q; /* as a (signed) quad */ - quad_t uq; /* as an unsigned quad */ - long sl[2]; /* as two signed longs */ - u_long ul[2]; /* as two unsigned longs */ -}; - -/* - * Define high and low longwords. - */ -#define H _QUAD_HIGHWORD -#define L _QUAD_LOWWORD - -/* - * Total number of bits in a quad_t and in the pieces that make it up. - * These are used for shifting, and also below for halfword extraction - * and assembly. - */ -#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) -#define LONG_BITS (sizeof(long) * CHAR_BIT) -#define HALF_BITS (sizeof(long) * CHAR_BIT / 2) - -/* - * Extract high and low shortwords from longword, and move low shortword of - * longword to upper half of long, i.e., produce the upper longword of - * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x' must actually be u_long.) - * - * These are used in the multiply code, to split a longword into upper - * and lower halves, and to reassemble a product as a quad_t, shifted left - * (sizeof(long)*CHAR_BIT/2). - */ -#define HHALF(x) ((x) >> HALF_BITS) -#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) -#define LHUP(x) ((x) << HALF_BITS) - -int __cmpdi2(quad_t a, quad_t b); -quad_t __divdi3(quad_t a, quad_t b); -quad_t __moddi3(quad_t a, quad_t b); -u_quad_t __qdivrem(u_quad_t u, u_quad_t v, u_quad_t *rem); -int __ucmpdi2(u_quad_t a, u_quad_t b); -u_quad_t __udivdi3(u_quad_t a, u_quad_t b); -u_quad_t __umoddi3(u_quad_t a, u_quad_t b); - -typedef unsigned int qshift_t; diff --git a/lib/libc/quad/subdi3.c b/lib/libc/quad/subdi3.c deleted file mode 100644 index 3f9659207c..0000000000 --- a/lib/libc/quad/subdi3.c +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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. - * - * @(#)subdi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/subdi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Subtract two quad values. This is trivial since a one-bit carry - * from a single u_long difference x-y occurs if and only if (x-y) > x. - */ -quad_t -__subdi3(quad_t a, quad_t b) -{ - union uu aa, bb, diff; - - aa.q = a; - bb.q = b; - diff.ul[L] = aa.ul[L] - bb.ul[L]; - diff.ul[H] = aa.ul[H] - bb.ul[H] - (diff.ul[L] > aa.ul[L]); - return (diff.q); -} diff --git a/lib/libc/quad/ucmpdi2.c b/lib/libc/quad/ucmpdi2.c deleted file mode 100644 index 92cd453441..0000000000 --- a/lib/libc/quad/ucmpdi2.c +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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. - * - * @(#)ucmpdi2.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/ucmpdi2.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/ucmpdi2.c,v 1.3 2005/11/13 02:13:52 swildner Exp $ - */ - -#include "quad.h" - -/* - * Return 0, 1, or 2 as a <, =, > b respectively. - * Neither a nor b are considered signed. - */ -int -__ucmpdi2(u_quad_t a, u_quad_t b) -{ - union uu aa, bb; - - aa.uq = a; - bb.uq = b; - return (aa.ul[H] < bb.ul[H] ? 0 : aa.ul[H] > bb.ul[H] ? 2 : - aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1); -} diff --git a/lib/libc/quad/udivdi3.c b/lib/libc/quad/udivdi3.c deleted file mode 100644 index 8e20e4bb2f..0000000000 --- a/lib/libc/quad/udivdi3.c +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * 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. - * - * @(#)udivdi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/udivdi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/udivdi3.c,v 1.3 2005/11/13 02:13:52 swildner Exp $ - */ - -#include "quad.h" - -/* - * Divide two unsigned quads. - */ -u_quad_t -__udivdi3(u_quad_t a, u_quad_t b) -{ - - return (__qdivrem(a, b, (u_quad_t *)0)); -} diff --git a/lib/libc/quad/umoddi3.c b/lib/libc/quad/umoddi3.c deleted file mode 100644 index a0b92c70d7..0000000000 --- a/lib/libc/quad/umoddi3.c +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * 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. - * - * @(#)umoddi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/umoddi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - * $DragonFly: src/lib/libc/quad/umoddi3.c,v 1.3 2005/11/13 02:13:52 swildner Exp $ - */ - -#include "quad.h" - -/* - * Return remainder after dividing two unsigned quads. - */ -u_quad_t -__umoddi3(u_quad_t a, u_quad_t b) -{ - u_quad_t r; - - __qdivrem(a, b, &r); - return (r); -} diff --git a/lib/libc/quad/xordi3.c b/lib/libc/quad/xordi3.c deleted file mode 100644 index 4e3f9d774a..0000000000 --- a/lib/libc/quad/xordi3.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * @(#)xordi3.c 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/lib/libc/quad/xordi3.c,v 1.3 2007/01/09 00:28:03 imp Exp $ - */ - -#include "quad.h" - -/* - * Return a ^ b, in quad. - */ -quad_t -__xordi3(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - aa.ul[0] ^= bb.ul[0]; - aa.ul[1] ^= bb.ul[1]; - return (aa.q); -} diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile index 5207091518..bee036cb98 100644 --- a/lib/libstand/Makefile +++ b/lib/libstand/Makefile @@ -46,11 +46,6 @@ SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \ strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c .endif -.PATH: ${.CURDIR}/../libc/quad -.if ${MACHINE_ARCH} == "i386" -SRCS+= ucmpdi2.c -.endif - .PATH: ${.CURDIR}/../../sys/libkern SRCS+= icrc32.c diff --git a/lib/libstand/quad.h b/lib/libstand/quad.h index eb5c2f1b5d..cd6acc055f 100644 --- a/lib/libstand/quad.h +++ b/lib/libstand/quad.h @@ -36,23 +36,6 @@ * * @(#)quad.h 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libstand/quad.h,v 1.2 1999/08/28 00:05:33 peter Exp $ - * $DragonFly: src/lib/libstand/quad.h,v 1.3 2003/11/12 20:21:31 eirikn Exp $ - */ - -/* - * Quad arithmetic. - * - * This library makes the following assumptions: - * - * - The type long long (aka quad_t) exists. - * - * - A quad variable is exactly twice as long as `long'. - * - * - The machine's arithmetic is two's complement. - * - * This library can provide 128-bit arithmetic on a machine with 128-bit - * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines - * with 48-bit longs. */ #include @@ -76,42 +59,11 @@ union uu { #define H _QUAD_HIGHWORD #define L _QUAD_LOWWORD -/* - * Total number of bits in a quad_t and in the pieces that make it up. - * These are used for shifting, and also below for halfword extraction - * and assembly. - */ -#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) -#define LONG_BITS (sizeof(long) * CHAR_BIT) #define HALF_BITS (sizeof(long) * CHAR_BIT / 2) -/* - * Extract high and low shortwords from longword, and move low shortword of - * longword to upper half of long, i.e., produce the upper longword of - * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x' must actually be u_long.) - * - * These are used in the multiply code, to split a longword into upper - * and lower halves, and to reassemble a product as a quad_t, shifted left - * (sizeof(long)*CHAR_BIT/2). - */ #define HHALF(x) ((x) >> HALF_BITS) #define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) -#define LHUP(x) ((x) << HALF_BITS) - -quad_t __divdi3 (quad_t a, quad_t b); -quad_t __moddi3 (quad_t a, quad_t b); -u_quad_t __qdivrem (u_quad_t u, u_quad_t v, u_quad_t *rem); -u_quad_t __udivdi3 (u_quad_t a, u_quad_t b); -u_quad_t __umoddi3 (u_quad_t a, u_quad_t b); -/* - * XXX - * Compensate for gcc 1 vs gcc 2. Gcc 1 defines ?sh?di3's second argument - * as u_quad_t, while gcc 2 correctly uses int. Unfortunately, we still use - * both compilers. - */ -#if __GNUC__ >= 2 -typedef unsigned int qshift_t; -#else -typedef u_quad_t qshift_t; -#endif +u_quad_t __qdivrem (u_quad_t, u_quad_t, u_quad_t *); +u_quad_t __udivdi3 (u_quad_t, u_quad_t); +u_quad_t __umoddi3 (u_quad_t, u_quad_t); diff --git a/sys/conf/files b/sys/conf/files index 38e963d0b9..b827f25d14 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1823,10 +1823,8 @@ dev/sound/pcm/sound.c optional sound dev/sound/pcm/vchan.c optional sound # # These files in libkern/ are those needed by all architectures. Some -# of the files in libkern/ are only needed on some architectures, e.g., -# libkern/divdi3.c is needed by i386 but not alpha. Also, some of these -# routines may be optimized for a particular platform. In either case, -# the file should be moved to conf/files. from here. +# of the files in libkern/ are only needed on some architectures. +# In this case, the files should be moved to platform//conf/files. # libkern/arc4random.c standard libkern/bcd.c standard diff --git a/sys/libkern/adddi3.c b/sys/libkern/adddi3.c deleted file mode 100644 index 635021f5a1..0000000000 --- a/sys/libkern/adddi3.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/adddi3.c,v 1.5 1999/08/28 00:46:30 peter Exp $ - * $DragonFly: src/sys/libkern/adddi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Add two quads. This is trivial since a one-bit carry from a single - * u_long addition x+y occurs if and only if the sum x+y is less than - * either x or y (the choice to compare with x or y is arbitrary). - */ -quad_t -__adddi3(quad_t a, quad_t b) -{ - union uu aa, bb, sum; - - aa.q = a; - bb.q = b; - sum.ul[L] = aa.ul[L] + bb.ul[L]; - sum.ul[H] = aa.ul[H] + bb.ul[H] + (sum.ul[L] < bb.ul[L]); - return (sum.q); -} diff --git a/sys/libkern/anddi3.c b/sys/libkern/anddi3.c deleted file mode 100644 index 678f702229..0000000000 --- a/sys/libkern/anddi3.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/anddi3.c,v 1.5 1999/08/28 00:46:30 peter Exp $ - * $DragonFly: src/sys/libkern/anddi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Return a & b, in quad. - */ -quad_t -__anddi3(quad_t a, b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - aa.ul[0] &= bb.ul[0]; - aa.ul[1] &= bb.ul[1]; - return (aa.q); -} diff --git a/sys/libkern/ashldi3.c b/sys/libkern/ashldi3.c deleted file mode 100644 index 6c96cefcb2..0000000000 --- a/sys/libkern/ashldi3.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/ashldi3.c,v 1.5 1999/08/28 00:46:30 peter Exp $ - * $DragonFly: src/sys/libkern/ashldi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Shift a (signed) quad value left (arithmetic shift left). - * This is the same as logical shift left! - */ -quad_t -__ashldi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - aa.ul[H] = shift >= QUAD_BITS ? 0 : - aa.ul[L] << (shift - LONG_BITS); - aa.ul[L] = 0; - } else if (shift > 0) { - aa.ul[H] = (aa.ul[H] << shift) | - (aa.ul[L] >> (LONG_BITS - shift)); - aa.ul[L] <<= shift; - } - return (aa.q); -} diff --git a/sys/libkern/ashrdi3.c b/sys/libkern/ashrdi3.c deleted file mode 100644 index 068a053a39..0000000000 --- a/sys/libkern/ashrdi3.c +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/ashrdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $ - * $DragonFly: src/sys/libkern/ashrdi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Shift a (signed) quad value right (arithmetic shift right). - */ -quad_t -__ashrdi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - long s; - - /* - * Smear bits rightward using the machine's right-shift - * method, whether that is sign extension or zero fill, - * to get the `sign word' s. Note that shifting by - * LONG_BITS is undefined, so we shift (LONG_BITS-1), - * then 1 more, to get our answer. - */ - s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1; - aa.ul[L] = shift >= QUAD_BITS ? s : - aa.sl[H] >> (shift - LONG_BITS); - aa.ul[H] = s; - } else if (shift > 0) { - aa.ul[L] = (aa.ul[L] >> shift) | - (aa.ul[H] << (LONG_BITS - shift)); - aa.sl[H] >>= shift; - } - return (aa.q); -} diff --git a/sys/libkern/cmpdi2.c b/sys/libkern/cmpdi2.c deleted file mode 100644 index 2492807638..0000000000 --- a/sys/libkern/cmpdi2.c +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/cmpdi2.c,v 1.6 1999/08/28 00:46:31 peter Exp $ - * $DragonFly: src/sys/libkern/cmpdi2.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include - -/* - * Return 0, 1, or 2 as a <, =, > b respectively. - * Both a and b are considered signed---which means only the high word is - * signed. - */ -int -__cmpdi2(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - return (aa.sl[H] < bb.sl[H] ? 0 : aa.sl[H] > bb.sl[H] ? 2 : - aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1); -} diff --git a/sys/libkern/divdi3.c b/sys/libkern/divdi3.c deleted file mode 100644 index 9e57af79c2..0000000000 --- a/sys/libkern/divdi3.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $ - * $DragonFly: src/sys/libkern/divdi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include - -/* - * Divide two signed quads. - * ??? if -1/2 should produce -1 on this machine, this code is wrong - */ -quad_t -__divdi3(quad_t a, quad_t b) -{ - u_quad_t ua, ub, uq; - int neg; - - if (a < 0) - ua = -(u_quad_t)a, neg = 1; - else - ua = a, neg = 0; - if (b < 0) - ub = -(u_quad_t)b, neg ^= 1; - else - ub = b; - uq = __qdivrem(ua, ub, (u_quad_t *)0); - return (neg ? -uq : uq); -} diff --git a/sys/libkern/iordi3.c b/sys/libkern/iordi3.c deleted file mode 100644 index aee6de9a8c..0000000000 --- a/sys/libkern/iordi3.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/iordi3.c,v 1.5 1999/08/28 00:46:32 peter Exp $ - * $DragonFly: src/sys/libkern/iordi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Return a | b, in quad. - */ -quad_t -__iordi3(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - aa.ul[0] |= bb.ul[0]; - aa.ul[1] |= bb.ul[1]; - return (aa.q); -} diff --git a/sys/libkern/lshldi3.c b/sys/libkern/lshldi3.c deleted file mode 100644 index 2a009d961f..0000000000 --- a/sys/libkern/lshldi3.c +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/lshldi3.c,v 1.5 1999/08/28 00:46:33 peter Exp $ - * $DragonFly: src/sys/libkern/lshldi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Shift an (unsigned) quad value left (logical shift left). - * This is the same as arithmetic shift left! - */ -quad_t -__lshldi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - aa.ul[H] = shift >= QUAD_BITS ? 0 : - aa.ul[L] << (shift - LONG_BITS); - aa.ul[L] = 0; - } else if (shift > 0) { - aa.ul[H] = (aa.ul[H] << shift) | - (aa.ul[L] >> (LONG_BITS - shift)); - aa.ul[L] <<= shift; - } - return (aa.q); -} diff --git a/sys/libkern/lshrdi3.c b/sys/libkern/lshrdi3.c deleted file mode 100644 index 4655ab1403..0000000000 --- a/sys/libkern/lshrdi3.c +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/lshrdi3.c,v 1.5 1999/08/28 00:46:33 peter Exp $ - * $DragonFly: src/sys/libkern/lshrdi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Shift an (unsigned) quad value right (logical shift right). - */ -quad_t -__lshrdi3(quad_t a, qshift_t shift) -{ - union uu aa; - - aa.q = a; - if (shift >= LONG_BITS) { - aa.ul[L] = shift >= QUAD_BITS ? 0 : - aa.ul[H] >> (shift - LONG_BITS); - aa.ul[H] = 0; - } else if (shift > 0) { - aa.ul[L] = (aa.ul[L] >> shift) | - (aa.ul[H] << (LONG_BITS - shift)); - aa.ul[H] >>= shift; - } - return (aa.q); -} diff --git a/sys/libkern/moddi3.c b/sys/libkern/moddi3.c deleted file mode 100644 index 151bce3ce1..0000000000 --- a/sys/libkern/moddi3.c +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/moddi3.c,v 1.7 1999/08/28 00:46:34 peter Exp $ - * $DragonFly: src/sys/libkern/moddi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include - -/* - * Return remainder after dividing two signed quads. - * - * XXX - * If -1/2 should produce -1 on this machine, this code is wrong. - */ -quad_t -__moddi3(quad_t a, quad_t b) -{ - u_quad_t ua, ub, ur; - int neg; - - if (a < 0) - ua = -(u_quad_t)a, neg = 1; - else - ua = a, neg = 0; - if (b < 0) - ub = -(u_quad_t)b; - else - ub = b; - (void)__qdivrem(ua, ub, &ur); - return (neg ? -ur : ur); -} diff --git a/sys/libkern/muldi3.c b/sys/libkern/muldi3.c deleted file mode 100644 index 56b714c62a..0000000000 --- a/sys/libkern/muldi3.c +++ /dev/null @@ -1,240 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/muldi3.c,v 1.6 1999/08/28 00:46:34 peter Exp $ - * $DragonFly: src/sys/libkern/muldi3.c,v 1.4 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Multiply two quads. - * - * Our algorithm is based on the following. Split incoming quad values - * u and v (where u,v >= 0) into - * - * u = 2^n u1 * u0 (n = number of bits in `u_long', usu. 32) - * - * and - * - * v = 2^n v1 * v0 - * - * Then - * - * uv = 2^2n u1 v1 + 2^n u1 v0 + 2^n v1 u0 + u0 v0 - * = 2^2n u1 v1 + 2^n (u1 v0 + v1 u0) + u0 v0 - * - * Now add 2^n u1 v1 to the first term and subtract it from the middle, - * and add 2^n u0 v0 to the last term and subtract it from the middle. - * This gives: - * - * uv = (2^2n + 2^n) (u1 v1) + - * (2^n) (u1 v0 - u1 v1 + u0 v1 - u0 v0) + - * (2^n + 1) (u0 v0) - * - * Factoring the middle a bit gives us: - * - * uv = (2^2n + 2^n) (u1 v1) + [u1v1 = high] - * (2^n) (u1 - u0) (v0 - v1) + [(u1-u0)... = mid] - * (2^n + 1) (u0 v0) [u0v0 = low] - * - * The terms (u1 v1), (u1 - u0) (v0 - v1), and (u0 v0) can all be done - * in just half the precision of the original. (Note that either or both - * of (u1 - u0) or (v0 - v1) may be negative.) - * - * This algorithm is from Knuth vol. 2 (2nd ed), section 4.3.3, p. 278. - * - * Since C does not give us a `long * long = quad' operator, we split - * our input quads into two longs, then split the two longs into two - * shorts. We can then calculate `short * short = long' in native - * arithmetic. - * - * Our product should, strictly speaking, be a `long quad', with 128 - * bits, but we are going to discard the upper 64. In other words, - * we are not interested in uv, but rather in (uv mod 2^2n). This - * makes some of the terms above vanish, and we get: - * - * (2^n)(high) + (2^n)(mid) + (2^n + 1)(low) - * - * or - * - * (2^n)(high + mid + low) + low - * - * Furthermore, `high' and `mid' can be computed mod 2^n, as any factor - * of 2^n in either one will also vanish. Only `low' need be computed - * mod 2^2n, and only because of the final term above. - */ -static quad_t __lmulq(u_long u, u_long v); - -quad_t -__muldi3(quad_t a, quad_t b) -{ - union uu u, v, low, prod; - u_long high, mid, udiff, vdiff; - int negall, negmid; -#define u1 u.ul[H] -#define u0 u.ul[L] -#define v1 v.ul[H] -#define v0 v.ul[L] - - /* - * Get u and v such that u, v >= 0. When this is finished, - * u1, u0, v1, and v0 will be directly accessible through the - * longword fields. - */ - if (a >= 0) - u.q = a, negall = 0; - else - u.q = -a, negall = 1; - if (b >= 0) - v.q = b; - else - v.q = -b, negall ^= 1; - - if (u1 == 0 && v1 == 0) { - /* - * An (I hope) important optimization occurs when u1 and v1 - * are both 0. This should be common since most numbers - * are small. Here the product is just u0*v0. - */ - prod.q = __lmulq(u0, v0); - } else { - /* - * Compute the three intermediate products, remembering - * whether the middle term is negative. We can discard - * any upper bits in high and mid, so we can use native - * u_long * u_long => u_long arithmetic. - */ - low.q = __lmulq(u0, v0); - - if (u1 >= u0) - negmid = 0, udiff = u1 - u0; - else - negmid = 1, udiff = u0 - u1; - if (v0 >= v1) - vdiff = v0 - v1; - else - vdiff = v1 - v0, negmid ^= 1; - mid = udiff * vdiff; - - high = u1 * v1; - - /* - * Assemble the final product. - */ - prod.ul[H] = high + (negmid ? -mid : mid) + low.ul[L] + - low.ul[H]; - prod.ul[L] = low.ul[L]; - } - return (negall ? -prod.q : prod.q); -#undef u1 -#undef u0 -#undef v1 -#undef v0 -} - -/* - * Multiply two 2N-bit longs to produce a 4N-bit quad, where N is half - * the number of bits in a long (whatever that is---the code below - * does not care as long as quad.h does its part of the bargain---but - * typically N==16). - * - * We use the same algorithm from Knuth, but this time the modulo refinement - * does not apply. On the other hand, since N is half the size of a long, - * we can get away with native multiplication---none of our input terms - * exceeds (ULONG_MAX >> 1). - * - * Note that, for u_long l, the quad-precision result - * - * l << N - * - * splits into high and low longs as HHALF(l) and LHUP(l) respectively. - */ -static quad_t -__lmulq(u_long u, u_long v) -{ - u_long u1, u0, v1, v0, udiff, vdiff, high, mid, low; - u_long prodh, prodl, was; - union uu prod; - int neg; - - u1 = HHALF(u); - u0 = LHALF(u); - v1 = HHALF(v); - v0 = LHALF(v); - - low = u0 * v0; - - /* This is the same small-number optimization as before. */ - if (u1 == 0 && v1 == 0) - return (low); - - if (u1 >= u0) - udiff = u1 - u0, neg = 0; - else - udiff = u0 - u1, neg = 1; - if (v0 >= v1) - vdiff = v0 - v1; - else - vdiff = v1 - v0, neg ^= 1; - mid = udiff * vdiff; - - high = u1 * v1; - - /* prod = (high << 2N) + (high << N); */ - prodh = high + HHALF(high); - prodl = LHUP(high); - - /* if (neg) prod -= mid << N; else prod += mid << N; */ - if (neg) { - was = prodl; - prodl -= LHUP(mid); - prodh -= HHALF(mid) + (prodl > was); - } else { - was = prodl; - prodl += LHUP(mid); - prodh += HHALF(mid) + (prodl < was); - } - - /* prod += low << N */ - was = prodl; - prodl += LHUP(low); - prodh += HHALF(low) + (prodl < was); - /* ... + low; */ - if ((prodl += low) < low) - prodh++; - - /* return 4N-bit product */ - prod.ul[H] = prodh; - prod.ul[L] = prodl; - return (prod.q); -} diff --git a/sys/libkern/negdi2.c b/sys/libkern/negdi2.c deleted file mode 100644 index c25e535839..0000000000 --- a/sys/libkern/negdi2.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/negdi2.c,v 1.5 1999/08/28 00:46:34 peter Exp $ - * $DragonFly: src/sys/libkern/negdi2.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Return -a (or, equivalently, 0 - a), in quad. See subdi3.c. - */ -quad_t -__negdi2(quad_t a) -{ - union uu aa, res; - - aa.q = a; - res.ul[L] = -aa.ul[L]; - res.ul[H] = -aa.ul[H] - (res.ul[L] > 0); - return (res.q); -} diff --git a/sys/libkern/notdi2.c b/sys/libkern/notdi2.c deleted file mode 100644 index b4354bc47f..0000000000 --- a/sys/libkern/notdi2.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/notdi2.c,v 1.5 1999/08/28 00:46:35 peter Exp $ - * $DragonFly: src/sys/libkern/notdi2.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Return ~a. For some reason gcc calls this `one's complement' rather - * than `not'. - */ -quad_t -__one_cmpldi2(quad_t a) -{ - union uu aa; - - aa.q = a; - aa.ul[0] = ~aa.ul[0]; - aa.ul[1] = ~aa.ul[1]; - return (aa.q); -} diff --git a/sys/libkern/qdivrem.c b/sys/libkern/qdivrem.c deleted file mode 100644 index 38bb4bec17..0000000000 --- a/sys/libkern/qdivrem.c +++ /dev/null @@ -1,273 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/qdivrem.c,v 1.8 1999/08/28 00:46:35 peter Exp $ - * $DragonFly: src/sys/libkern/qdivrem.c,v 1.4 2004/01/26 11:09:44 joerg Exp $ - */ - -/* - * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), - * section 4.3.1, pp. 257--259. - */ - -#include - -#define B (1 << HALF_BITS) /* digit base */ - -/* Combine two `digits' to make a single two-digit number. */ -#define COMBINE(a, b) (((u_long)(a) << HALF_BITS) | (b)) - -/* select a type for digits in base B: use unsigned short if they fit */ -#if ULONG_MAX == 0xffffffff && USHRT_MAX >= 0xffff -typedef unsigned short digit; -#else -typedef u_long digit; -#endif - -/* - * Shift p[0]..p[len] left `sh' bits, ignoring any bits that - * `fall out' the left (there never will be any such anyway). - * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. - */ -static void -shl(digit *p, int len, int sh) -{ - int i; - - for (i = 0; i < len; i++) - p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh)); - p[i] = LHALF(p[i] << sh); -} - -/* - * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v. - * - * We do this in base 2-sup-HALF_BITS, so that all intermediate products - * fit within u_long. As a consequence, the maximum length dividend and - * divisor are 4 `digits' in this base (they are shorter if they have - * leading zeros). - */ -u_quad_t -__qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq) -{ - union uu tmp; - digit *u, *v, *q; - digit v1, v2; - u_long qhat, rhat, t; - int m, n, d, j, i; - digit uspace[5], vspace[5], qspace[5]; - - /* - * Take care of special cases: divide by zero, and u < v. - */ - if (vq == 0) { - /* divide by zero. */ - static volatile const unsigned int zero = 0; - - tmp.ul[H] = tmp.ul[L] = 1 / zero; - if (arq) - *arq = uq; - return (tmp.q); - } - if (uq < vq) { - if (arq) - *arq = uq; - return (0); - } - u = &uspace[0]; - v = &vspace[0]; - q = &qspace[0]; - - /* - * Break dividend and divisor into digits in base B, then - * count leading zeros to determine m and n. When done, we - * will have: - * u = (u[1]u[2]...u[m+n]) sub B - * v = (v[1]v[2]...v[n]) sub B - * v[1] != 0 - * 1 < n <= 4 (if n = 1, we use a different division algorithm) - * m >= 0 (otherwise u < v, which we already checked) - * m + n = 4 - * and thus - * m = 4 - n <= 2 - */ - tmp.uq = uq; - u[0] = 0; - u[1] = HHALF(tmp.ul[H]); - u[2] = LHALF(tmp.ul[H]); - u[3] = HHALF(tmp.ul[L]); - u[4] = LHALF(tmp.ul[L]); - tmp.uq = vq; - v[1] = HHALF(tmp.ul[H]); - v[2] = LHALF(tmp.ul[H]); - v[3] = HHALF(tmp.ul[L]); - v[4] = LHALF(tmp.ul[L]); - for (n = 4; v[1] == 0; v++) { - if (--n == 1) { - u_long rbj; /* r*B+u[j] (not root boy jim) */ - digit q1, q2, q3, q4; - - /* - * Change of plan, per exercise 16. - * r = 0; - * for j = 1..4: - * q[j] = floor((r*B + u[j]) / v), - * r = (r*B + u[j]) % v; - * We unroll this completely here. - */ - t = v[2]; /* nonzero, by definition */ - q1 = u[1] / t; - rbj = COMBINE(u[1] % t, u[2]); - q2 = rbj / t; - rbj = COMBINE(rbj % t, u[3]); - q3 = rbj / t; - rbj = COMBINE(rbj % t, u[4]); - q4 = rbj / t; - if (arq) - *arq = rbj % t; - tmp.ul[H] = COMBINE(q1, q2); - tmp.ul[L] = COMBINE(q3, q4); - return (tmp.q); - } - } - - /* - * By adjusting q once we determine m, we can guarantee that - * there is a complete four-digit quotient at &qspace[1] when - * we finally stop. - */ - for (m = 4 - n; u[1] == 0; u++) - m--; - for (i = 4 - m; --i >= 0;) - q[i] = 0; - q += 4 - m; - - /* - * Here we run Program D, translated from MIX to C and acquiring - * a few minor changes. - * - * D1: choose multiplier 1 << d to ensure v[1] >= B/2. - */ - d = 0; - for (t = v[1]; t < B / 2; t <<= 1) - d++; - if (d > 0) { - shl(&u[0], m + n, d); /* u <<= d */ - shl(&v[1], n - 1, d); /* v <<= d */ - } - /* - * D2: j = 0. - */ - j = 0; - v1 = v[1]; /* for D3 -- note that v[1..n] are constant */ - v2 = v[2]; /* for D3 */ - do { - digit uj0, uj1, uj2; - - /* - * D3: Calculate qhat (\^q, in TeX notation). - * Let qhat = min((u[j]*B + u[j+1])/v[1], B-1), and - * let rhat = (u[j]*B + u[j+1]) mod v[1]. - * While rhat < B and v[2]*qhat > rhat*B+u[j+2], - * decrement qhat and increase rhat correspondingly. - * Note that if rhat >= B, v[2]*qhat < rhat*B. - */ - uj0 = u[j + 0]; /* for D3 only -- note that u[j+...] change */ - uj1 = u[j + 1]; /* for D3 only */ - uj2 = u[j + 2]; /* for D3 only */ - if (uj0 == v1) { - qhat = B; - rhat = uj1; - goto qhat_too_big; - } else { - u_long nn = COMBINE(uj0, uj1); - qhat = nn / v1; - rhat = nn % v1; - } - while (v2 * qhat > COMBINE(rhat, uj2)) { - qhat_too_big: - qhat--; - if ((rhat += v1) >= B) - break; - } - /* - * D4: Multiply and subtract. - * The variable `t' holds any borrows across the loop. - * We split this up so that we do not require v[0] = 0, - * and to eliminate a final special case. - */ - for (t = 0, i = n; i > 0; i--) { - t = u[i + j] - v[i] * qhat - t; - u[i + j] = LHALF(t); - t = (B - HHALF(t)) & (B - 1); - } - t = u[j] - t; - u[j] = LHALF(t); - /* - * D5: test remainder. - * There is a borrow if and only if HHALF(t) is nonzero; - * in that (rare) case, qhat was too large (by exactly 1). - * Fix it by adding v[1..n] to u[j..j+n]. - */ - if (HHALF(t)) { - qhat--; - for (t = 0, i = n; i > 0; i--) { /* D6: add back. */ - t += u[i + j] + v[i]; - u[i + j] = LHALF(t); - t = HHALF(t); - } - u[j] = LHALF(u[j] + t); - } - q[j] = qhat; - } while (++j <= m); /* D7: loop on j. */ - - /* - * If caller wants the remainder, we have to calculate it as - * u[m..m+n] >> d (this is at most n digits and thus fits in - * u[m+1..m+n], but we may need more source digits). - */ - if (arq) { - if (d) { - for (i = m + n; i > m; --i) - u[i] = (u[i] >> d) | - LHALF(u[i - 1] << (HALF_BITS - d)); - u[i] = 0; - } - tmp.ul[H] = COMBINE(uspace[1], uspace[2]); - tmp.ul[L] = COMBINE(uspace[3], uspace[4]); - *arq = tmp.q; - } - - tmp.ul[H] = COMBINE(qspace[1], qspace[2]); - tmp.ul[L] = COMBINE(qspace[3], qspace[4]); - return (tmp.q); -} diff --git a/sys/libkern/quad.h b/sys/libkern/quad.h deleted file mode 100644 index f47fed7a41..0000000000 --- a/sys/libkern/quad.h +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#)quad.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD: src/sys/libkern/quad.h,v 1.9 1999/08/28 00:46:36 peter Exp $ - * $DragonFly: src/sys/libkern/quad.h,v 1.5 2003/11/09 05:15:32 dillon Exp $ - */ - -/* - * Quad arithmetic. - * - * This library makes the following assumptions: - * - * - The type long long (aka quad_t) exists. - * - * - A quad variable is exactly twice as long as `long'. - * - * - The machine's arithmetic is two's complement. - * - * This library can provide 128-bit arithmetic on a machine with 128-bit - * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines - * with 48-bit longs. - */ - -#include -#include -#include -#include - -/* - * Depending on the desired operation, we view a `long long' (aka quad_t) in - * one or more of the following formats. - */ -union uu { - quad_t q; /* as a (signed) quad */ - quad_t uq; /* as an unsigned quad */ - long sl[2]; /* as two signed longs */ - u_long ul[2]; /* as two unsigned longs */ -}; - -/* - * Define high and low longwords. - */ -#define H _QUAD_HIGHWORD -#define L _QUAD_LOWWORD - -/* - * Total number of bits in a quad_t and in the pieces that make it up. - * These are used for shifting, and also below for halfword extraction - * and assembly. - */ -#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) -#define LONG_BITS (sizeof(long) * CHAR_BIT) -#define HALF_BITS (sizeof(long) * CHAR_BIT / 2) - -/* - * Extract high and low shortwords from longword, and move low shortword of - * longword to upper half of long, i.e., produce the upper longword of - * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x' must actually be u_long.) - * - * These are used in the multiply code, to split a longword into upper - * and lower halves, and to reassemble a product as a quad_t, shifted left - * (sizeof(long)*CHAR_BIT/2). - */ -#define HHALF(x) ((x) >> HALF_BITS) -#define LHALF(x) ((x) & ((1 << HALF_BITS) - 1)) -#define LHUP(x) ((x) << HALF_BITS) - -quad_t __divdi3 (quad_t a, quad_t b); -quad_t __moddi3 (quad_t a, quad_t b); -u_quad_t __qdivrem (u_quad_t u, u_quad_t v, u_quad_t *rem); -u_quad_t __udivdi3 (u_quad_t a, u_quad_t b); -u_quad_t __umoddi3 (u_quad_t a, u_quad_t b); -int __ucmpdi2(u_quad_t a, u_quad_t b); -int __cmpdi2(quad_t a, quad_t b); - - -/* - * XXX - * Compensate for gcc 1 vs gcc 2. Gcc 1 defines ?sh?di3's second argument - * as u_quad_t, while gcc 2 correctly uses int. Unfortunately, we still use - * both compilers. - */ -#if __GNUC__ >= 2 -typedef unsigned int qshift_t; -#else -typedef u_quad_t qshift_t; -#endif diff --git a/sys/libkern/subdi3.c b/sys/libkern/subdi3.c deleted file mode 100644 index 2b25fd8d38..0000000000 --- a/sys/libkern/subdi3.c +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/subdi3.c,v 1.5 1999/08/28 00:46:38 peter Exp $ - * $DragonFly: src/sys/libkern/subdi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Subtract two quad values. This is trivial since a one-bit carry - * from a single u_long difference x-y occurs if and only if (x-y) > x. - */ -quad_t -__subdi3(quad_t a, quad_t b) -{ - union uu aa, bb, diff; - - aa.q = a; - bb.q = b; - diff.ul[L] = aa.ul[L] - bb.ul[L]; - diff.ul[H] = aa.ul[H] - bb.ul[H] - (diff.ul[L] > aa.ul[L]); - return (diff.q); -} diff --git a/sys/libkern/ucmpdi2.c b/sys/libkern/ucmpdi2.c deleted file mode 100644 index bb4b99c727..0000000000 --- a/sys/libkern/ucmpdi2.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/ucmpdi2.c,v 1.8 1999/08/28 00:46:38 peter Exp $ - * $DragonFly: src/sys/libkern/ucmpdi2.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include - -/* - * Return 0, 1, or 2 as a <, =, > b respectively. - * Neither a nor b are considered signed. - */ -int -__ucmpdi2(u_quad_t a, u_quad_t b) -{ - union uu aa, bb; - - aa.uq = a; - bb.uq = b; - return (aa.ul[H] < bb.ul[H] ? 0 : aa.ul[H] > bb.ul[H] ? 2 : - aa.ul[L] < bb.ul[L] ? 0 : aa.ul[L] > bb.ul[L] ? 2 : 1); -} diff --git a/sys/libkern/udivdi3.c b/sys/libkern/udivdi3.c deleted file mode 100644 index f18793517f..0000000000 --- a/sys/libkern/udivdi3.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/udivdi3.c,v 1.6 1999/08/28 00:46:38 peter Exp $ - * $DragonFly: src/sys/libkern/udivdi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include - -/* - * Divide two unsigned quads. - */ -u_quad_t -__udivdi3(u_quad_t a, u_quad_t b) -{ - - return (__qdivrem(a, b, (u_quad_t *)0)); -} diff --git a/sys/libkern/umoddi3.c b/sys/libkern/umoddi3.c deleted file mode 100644 index 66b507298d..0000000000 --- a/sys/libkern/umoddi3.c +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/umoddi3.c,v 1.6 1999/08/28 00:46:39 peter Exp $ - * $DragonFly: src/sys/libkern/umoddi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include - -/* - * Return remainder after dividing two unsigned quads. - */ -u_quad_t -__umoddi3(u_quad_t a, u_quad_t b) -{ - u_quad_t r; - - (void)__qdivrem(a, b, &r); - return (r); -} diff --git a/sys/libkern/xordi3.c b/sys/libkern/xordi3.c deleted file mode 100644 index c65520e653..0000000000 --- a/sys/libkern/xordi3.c +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * 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. - * - * $FreeBSD: src/sys/libkern/xordi3.c,v 1.5 1999/08/28 00:46:39 peter Exp $ - * $DragonFly: src/sys/libkern/xordi3.c,v 1.3 2004/01/26 11:09:44 joerg Exp $ - */ - -#include "quad.h" - -/* - * Return a ^ b, in quad. - */ -quad_t -__xordi3(quad_t a, quad_t b) -{ - union uu aa, bb; - - aa.q = a; - bb.q = b; - aa.ul[0] ^= bb.ul[0]; - aa.ul[1] ^= bb.ul[1]; - return (aa.q); -}