diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
commit | d6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch) | |
tree | ece253b876159b39c620e62b6c9b1174642e070e /lib/libc/arch/vax/gen |
initial import of NetBSD tree
Diffstat (limited to 'lib/libc/arch/vax/gen')
-rw-r--r-- | lib/libc/arch/vax/gen/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/_setjmp.S | 102 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/alloca.S | 50 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/fabs.S | 48 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/frexp.c | 67 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/infinity.c | 13 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/isinf.c | 51 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/ldexp.S | 90 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/modf.S | 56 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/setjmp.S | 97 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/udiv.S | 96 | ||||
-rw-r--r-- | lib/libc/arch/vax/gen/urem.S | 96 |
12 files changed, 770 insertions, 0 deletions
diff --git a/lib/libc/arch/vax/gen/Makefile.inc b/lib/libc/arch/vax/gen/Makefile.inc new file mode 100644 index 00000000000..9be4a93fec1 --- /dev/null +++ b/lib/libc/arch/vax/gen/Makefile.inc @@ -0,0 +1,4 @@ +# $NetBSD: Makefile.inc,v 1.1 1995/04/17 12:23:36 ragge Exp $ + +SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c ldexp.S \ + modf.S setjmp.S udiv.S urem.S alloca.S diff --git a/lib/libc/arch/vax/gen/_setjmp.S b/lib/libc/arch/vax/gen/_setjmp.S new file mode 100644 index 00000000000..dc69060289f --- /dev/null +++ b/lib/libc/arch/vax/gen/_setjmp.S @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: _setjmp.S,v 1.1 1995/04/17 12:23:37 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +/* + * C library -- _setjmp, _longjmp + * + * _longjmp(a,v) + * will generate a "return(v)" from + * the last call to + * _setjmp(a) + * by restoring registers from the stack, + * The previous signal state is NOT restored. + */ + +#include "DEFS.h" + +ENTRY(_setjmp, 0) + movl 4(ap),r0 + movl 12(fp),(r0) # save frame pointer of caller + movl 16(fp),4(r0) # save pc of caller + clrl r0 + ret + +ENTRY(_longjmp, 0) + movl 8(ap),r0 # return(v) + movl 4(ap),r1 # fetch buffer + tstl (r1) + beql botch +loop: + bitw $1,6(fp) # r0 saved? + beql 1f + movl r0,20(fp) + bitw $2,6(fp) # was r1 saved? + beql 2f + movl r1,24(fp) + brb 2f +1: + bitw $2,6(fp) # was r1 saved? + beql 2f + movl r1,20(fp) +2: + cmpl (r1),12(fp) + beql done + blssu botch + movl $loop,16(fp) + ret # pop another frame + +done: + cmpb *16(fp),reiins # returning to an "rei"? + bneq 1f + movab 3f,16(fp) # do return w/ psl-pc pop + brw 2f +1: + movab 4f,16(fp) # do standard return +2: + ret # unwind stack before signals enabled +3: + addl2 $8,sp # compensate for PSL-PC push +4: + jmp *4(r1) # done, return.... + +botch: + calls $0,_longjmperror + halt + + .data +reiins: rei diff --git a/lib/libc/arch/vax/gen/alloca.S b/lib/libc/arch/vax/gen/alloca.S new file mode 100644 index 00000000000..a1f47915d23 --- /dev/null +++ b/lib/libc/arch/vax/gen/alloca.S @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)alloca.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: alloca.S,v 1.1 1995/04/17 12:23:38 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +#include "DEFS.h" + +ENTRY(alloca, 0) + movl 4(ap),r0 # get allocation size + movl 16(fp),r2 # save return address before we smash it + movab here,16(fp) + ret +here: + subl2 r0,sp # create stack space + bicl2 $3,sp # align to longword boundary + movl sp,r0 + jmp (r2) diff --git a/lib/libc/arch/vax/gen/fabs.S b/lib/libc/arch/vax/gen/fabs.S new file mode 100644 index 00000000000..b50bd9aab2e --- /dev/null +++ b/lib/libc/arch/vax/gen/fabs.S @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)fabs.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: fabs.S,v 1.1 1995/04/17 12:23:39 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +/* fabs - floating absolute value */ + +#include "DEFS.h" + +ENTRY(fabs, 0) + movd 4(ap),r0 + bgeq 1f + mnegd r0,r0 +1: + ret diff --git a/lib/libc/arch/vax/gen/frexp.c b/lib/libc/arch/vax/gen/frexp.c new file mode 100644 index 00000000000..80d5a359bcd --- /dev/null +++ b/lib/libc/arch/vax/gen/frexp.c @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* static char sccsid[] = "@(#)frexp.c 8.1 (Berkeley) 6/4/93"; */ +static char rcsid[] = "$NetBSD: frexp.c,v 1.1 1995/04/17 12:23:40 ragge Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <math.h> + +double +frexp(value, eptr) + double value; + int *eptr; +{ + union { + double v; + struct { + u_int u_mant1 : 7; + u_int u_exp : 8; + u_int u_sign : 1; + u_int u_mant2 : 16; + u_int u_mant3 : 32; + } s; + } u; + + if (value) { + u.v = value; + *eptr = u.s.u_exp - 128; + u.s.u_exp = 128; + return(u.v); + } else { + *eptr = 0; + return((double)0); + } +} diff --git a/lib/libc/arch/vax/gen/infinity.c b/lib/libc/arch/vax/gen/infinity.c new file mode 100644 index 00000000000..1193b65bc7a --- /dev/null +++ b/lib/libc/arch/vax/gen/infinity.c @@ -0,0 +1,13 @@ +#ifndef lint +static char rcsid[] = "$Id: infinity.c,v 1.1 1995/10/18 08:41:43 deraadt Exp $"; +#endif /* not lint */ +/* + * XXX - THIS IS (probably) COMPLETELY WRONG ON VAX!!! + */ + +/* infinity.c */ + +#include <math.h> + +/* bytes for +Infinity on a 387 */ +char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; diff --git a/lib/libc/arch/vax/gen/isinf.c b/lib/libc/arch/vax/gen/isinf.c new file mode 100644 index 00000000000..7bacdb07d46 --- /dev/null +++ b/lib/libc/arch/vax/gen/isinf.c @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; */ +static char rcsid[] = "$NetBSD: isinf.c,v 1.1 1995/04/17 12:23:43 ragge Exp $"; +#endif /* LIBC_SCCS and not lint */ + +/* ARGSUSED */ +isnan(d) + double d; +{ + return(0); +} + +/* ARGSUSED */ +isinf(d) + double d; +{ + return(0); +} diff --git a/lib/libc/arch/vax/gen/ldexp.S b/lib/libc/arch/vax/gen/ldexp.S new file mode 100644 index 00000000000..8875fcd3e81 --- /dev/null +++ b/lib/libc/arch/vax/gen/ldexp.S @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /*.asciz "@(#)ldexp.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: ldexp.S,v 1.2 1995/06/01 01:11:41 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +/* + * double ldexp (value, exp) + * double value; + * int exp; + * + * Ldexp returns value*2**exp, if that result is in range. + * If underflow occurs, it returns zero. If overflow occurs, + * it returns a value of appropriate sign and largest + * possible magnitude. In case of either overflow or underflow, + * errno is set to ERANGE. Note that errno is not modified if + * no error occurs. + */ + +#include "DEFS.h" + +/* + * don't include errno.h, ANSI C says it defines errno. + * + * #include <errno.h> + */ +#define ERANGE 34 + + .globl _errno + +ENTRY(ldexp, 0) + movd 4(ap),r0 /* fetch "value" */ + extzv $7,$8,r0,r2 /* r2 := biased exponent */ + jeql 1f /* if zero, done */ + + addl2 12(ap),r2 /* r2 := new biased exponent */ + jleq 2f /* if <= 0, underflow */ + cmpl r2,$256 /* otherwise check if too big */ + jgeq 3f /* jump if overflow */ + insv r2,$7,$8,r0 /* put exponent back in result */ +1: + ret +2: + clrd r0 + jbr 1f +3: + movd huge,r0 /* largest possible floating magnitude */ + jbc $15,4(ap),1f /* jump if argument was positive */ + mnegd r0,r0 /* if arg < 0, make result negative */ +1: + movl $ ERANGE,_errno + ret + + .data +huge: .word 0x7fff /* the largest number that can */ + .word 0xffff /* be represented in a long floating */ + .word 0xffff /* number. This is given in hex in order */ + .word 0xffff /* to avoid floating conversions */ diff --git a/lib/libc/arch/vax/gen/modf.S b/lib/libc/arch/vax/gen/modf.S new file mode 100644 index 00000000000..26b9cb501cc --- /dev/null +++ b/lib/libc/arch/vax/gen/modf.S @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: modf.S,v 1.1 1995/04/17 12:23:45 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +/* + * double modf (value, iptr) + * double value, *iptr; + * + * Modf returns the fractional part of "value", + * and stores the integer part indirectly through "iptr". + */ + +#include "DEFS.h" + +ENTRY(modf, 0) + emodd 4(ap),$0,$0f1.0,r2,r0 + jvs 1f # integer overflow + cvtld r2,*12(ap) + ret +1: + subd3 r0,4(ap),*12(ap) + ret diff --git a/lib/libc/arch/vax/gen/setjmp.S b/lib/libc/arch/vax/gen/setjmp.S new file mode 100644 index 00000000000..789b7e29963 --- /dev/null +++ b/lib/libc/arch/vax/gen/setjmp.S @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: setjmp.S,v 1.1 1995/04/17 12:23:46 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +/* + * C library -- setjmp, longjmp + * + * longjmp(a,v) + * will generate a "return(v)" from + * the last call to + * setjmp(a) + * by restoring registers from the stack, + * and a struct sigcontext, see <signal.h> + */ + +#include "DEFS.h" + +ENTRY(setjmp, R6) + movl 4(ap),r6 # construct sigcontext + subl2 $12,sp # space for current struct sigstack + pushl sp # get current values + pushl $0 # no new values + calls $4,_sigaltstack # pop args plus signal stack value + movl (sp)+,(r6)+ # save onsigstack status of caller + pushl $0 + calls $1,_sigblock # get signal mask + movl r0,(r6)+ # save signal mask of caller + movl (ap),r0 + moval 4(ap)[r0],(r6)+ # save sp of caller + movl 12(fp),(r6)+ # save frame pointer of caller + movl 8(fp),(r6)+ # save argument pointer of caller + movl 16(fp),(r6)+ # save pc of caller + movpsl (r6) # save psl of caller + movw 4(fp),(r6) + clrl r0 + ret + +ENTRY(longjmp, 0) + movl 8(ap),r0 # return(v) + movl 4(ap),r1 # fetch buffer + tstl 12(r1) + beql botch +loop: + cmpl 12(r1),fp # are we there yet? + beql done + blssu botch + moval 20(fp),r2 + blbc 6(fp),1f # was r0 saved? + movl r0,(r2)+ +1: + bbc $1,6(fp),2f # was r1 saved? + movl r1,(r2) +2: + movl $loop,16(fp) + ret # pop another frame + +done: + pushl r1 # pointer to sigcontext + calls $1,_sigreturn # restore previous context + # we should never return +botch: + calls $0,_longjmperror + halt diff --git a/lib/libc/arch/vax/gen/udiv.S b/lib/libc/arch/vax/gen/udiv.S new file mode 100644 index 00000000000..dc42f2fe752 --- /dev/null +++ b/lib/libc/arch/vax/gen/udiv.S @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Donn Seeley at UUNET Technologies, Inc. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)udiv.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: udiv.S,v 1.1 1995/04/17 12:23:47 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +/* + * Unsigned division, PCC flavor. + * udiv() takes an ordinary dividend/divisor pair; + * audiv() takes a pointer to a dividend and an ordinary divisor. + */ + +#include "DEFS.h" + +#define DIVIDEND 4(ap) +#define DIVISOR 8(ap) + +ASENTRY(udiv,0) + movl DIVISOR,r2 + jlss Leasy # big divisor: settle by comparison + movl DIVIDEND,r0 + jlss Lhard # big dividend: extended division + divl2 r2,r0 # small divisor and dividend: signed division + ret +Lhard: + clrl r1 + ediv r2,r0,r0,r1 + ret +Leasy: + cmpl DIVIDEND,r2 + jgequ Lone # if dividend is as big or bigger, return 1 + clrl r0 # else return 0 + ret +Lone: + movl $1,r0 + ret + +ASENTRY(audiv,0) + movl DIVIDEND,r3 + movl DIVISOR,r2 + jlss La_easy # big divisor: settle by comparison + movl (r3),r0 + jlss La_hard # big dividend: extended division + divl2 r2,r0 # small divisor and dividend: signed division + movl r0,(r3) # leave the value of the assignment in r0 + ret +La_hard: + clrl r1 + ediv r2,r0,r0,r1 + movl r0,(r3) + ret +La_easy: + cmpl (r3),r2 + jgequ La_one # if dividend is as big or bigger, return 1 + clrl r0 # else return 0 + clrl (r3) + ret +La_one: + movl $1,r0 + movl r0,(r3) + ret diff --git a/lib/libc/arch/vax/gen/urem.S b/lib/libc/arch/vax/gen/urem.S new file mode 100644 index 00000000000..615b065ace4 --- /dev/null +++ b/lib/libc/arch/vax/gen/urem.S @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Donn Seeley at UUNET Technologies, Inc. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) + /* .asciz "@(#)urem.s 8.1 (Berkeley) 6/4/93" */ + .asciz "$NetBSD: urem.S,v 1.1 1995/04/17 12:23:48 ragge Exp $" +#endif /* LIBC_SCCS and not lint */ + +#include "DEFS.h" + +/* + * Unsigned modulus, PCC flavor. + * urem() takes an ordinary dividend/divisor pair; + * aurem() takes a pointer to a dividend and an ordinary divisor. + */ + +#define DIVIDEND 4(ap) +#define DIVISOR 8(ap) + +ASENTRY(urem,0) + movl DIVISOR,r2 + jlss Leasy # big divisor: settle by comparison + movl DIVIDEND,r0 + jlss Lhard # big dividend: need extended division + divl3 r2,r0,r1 # small divisor and dividend: signed modulus + mull2 r2,r1 + subl2 r1,r0 + ret +Lhard: + clrl r1 + ediv r2,r0,r1,r0 + ret +Leasy: + subl3 r2,DIVIDEND,r0 + jcc Ldifference # if divisor goes in once, return difference + movl DIVIDEND,r0 # if divisor is bigger, return dividend +Ldifference: + ret + +ASENTRY(aurem,0) + movl DIVIDEND,r3 + movl DIVISOR,r2 + jlss La_easy # big divisor: settle by comparison + movl (r3),r0 + jlss La_hard # big dividend: need extended division + divl3 r2,r0,r1 # small divisor and dividend: signed modulus + mull2 r2,r1 + subl2 r1,r0 + movl r0,(r3) # leave the value of the assignment in r0 + ret +La_hard: + clrl r1 + ediv r2,r0,r1,r0 + movl r0,(r3) + ret +La_easy: + subl3 r2,(r3),r0 + jcs La_dividend # if divisor is bigger, leave dividend alone + movl r0,(r3) # if divisor goes in once, store difference + ret +La_dividend: + movl (r3),r0 + ret |