summaryrefslogtreecommitdiffstats
path: root/lib/libc/sparc64/gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/sparc64/gen')
-rw-r--r--lib/libc/sparc64/gen/Makefile.inc4
-rw-r--r--lib/libc/sparc64/gen/_setjmp.S105
-rw-r--r--lib/libc/sparc64/gen/assym.s18
-rw-r--r--lib/libc/sparc64/gen/fixunsdfsi.S102
-rw-r--r--lib/libc/sparc64/gen/flt_rounds.c26
-rw-r--r--lib/libc/sparc64/gen/fpsetmask.c27
-rw-r--r--lib/libc/sparc64/gen/infinity.c14
-rw-r--r--lib/libc/sparc64/gen/isinf.c56
-rw-r--r--lib/libc/sparc64/gen/ldexp.c155
-rw-r--r--lib/libc/sparc64/gen/modf.S187
-rw-r--r--lib/libc/sparc64/gen/setjmp.S118
-rw-r--r--lib/libc/sparc64/gen/sigsetjmp.S58
12 files changed, 870 insertions, 0 deletions
diff --git a/lib/libc/sparc64/gen/Makefile.inc b/lib/libc/sparc64/gen/Makefile.inc
new file mode 100644
index 0000000..afc3a9e
--- /dev/null
+++ b/lib/libc/sparc64/gen/Makefile.inc
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+SRCS+= _setjmp.S fixunsdfsi.S flt_rounds.c fpsetmask.c infinity.c isinf.c \
+ ldexp.c modf.S setjmp.S sigsetjmp.S
diff --git a/lib/libc/sparc64/gen/_setjmp.S b/lib/libc/sparc64/gen/_setjmp.S
new file mode 100644
index 0000000..b72d2a0
--- /dev/null
+++ b/lib/libc/sparc64/gen/_setjmp.S
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ *
+ * from: Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
+#else
+ RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if defined(SYSLIBC_RCS) && !defined(lint)
+ .text
+ .asciz "$FreeBSD$"
+#endif /* SYSLIBC_RCS and not lint */
+
+#include <machine/asm.h>
+
+#include "assym.s"
+
+ .register %g2,#ignore
+ .register %g3,#ignore
+
+/*
+ * C library -- _setjmp, _longjmp
+ *
+ * _longjmp(a,v)
+ * will generate a "return(v?v:1)" from
+ * the last call to
+ * _setjmp(a)
+ * by unwinding the call stack.
+ * The previous signal state is NOT restored.
+ */
+
+ENTRY(_setjmp)
+ stx %sp, [%o0 + _JB_SP]
+ stx %o7, [%o0 + _JB_PC]
+ stx %fp, [%o0 + _JB_FP]
+ retl
+ clr %o0
+END(_setjmp)
+
+ENTRY(_longjmp)
+ mov 1, %g1
+ movrnz %o1, %o1, %g1 ! compute v ? v : 1
+ mov %o0, %g2
+ ldx [%g2 + _JB_FP], %g3 ! fetch callers frame
+1: cmp %fp, %g3 ! compare against desired frame
+ bl,a 1b ! if below,
+ restore ! pop frame and loop
+ be,a 2f ! if there,
+ ldx [%g2 + _JB_SP], %o0 ! fetch return %sp
+
+.Lbotch:
+ call CNAME(longjmperror)
+ nop
+ call CNAME(abort)
+ nop
+ illtrap
+
+2: cmp %o0, %sp ! %sp must not decrease
+ bge,a 3f
+ mov %o0, %sp ! it is OK, put it in place
+ b,a .Lbotch
+ nop
+3: ldx [%g2 + _JB_PC], %o7 ! fetch return address
+ retl
+ mov %g1, %o0 ! return v ? v : 1;
+END(_longjmp)
diff --git a/lib/libc/sparc64/gen/assym.s b/lib/libc/sparc64/gen/assym.s
new file mode 100644
index 0000000..7b205db
--- /dev/null
+++ b/lib/libc/sparc64/gen/assym.s
@@ -0,0 +1,18 @@
+/*
+ * Offsets into into structures used from asm. Must be kept in sync with
+ * appropriate headers.
+ *
+ * $FreeBSD$
+ */
+
+#define _JB_FP 0x0
+#define _JB_PC 0x8
+#define _JB_SP 0x10
+#define _JB_SIGMASK 0x18
+#define _JB_SIGFLAG 0x28
+
+#define SIG_BLOCK 1
+#define SIG_SETMASK 3
+
+#define FSR_RD_MASK 0xc0000000
+#define FSR_RD_RD_Z 0x40000000
diff --git a/lib/libc/sparc64/gen/fixunsdfsi.S b/lib/libc/sparc64/gen/fixunsdfsi.S
new file mode 100644
index 0000000..fde0583
--- /dev/null
+++ b/lib/libc/sparc64/gen/fixunsdfsi.S
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ *
+ * from: Header: fixunsdfsi.s,v 1.3 91/10/08 00:03:15 torek Exp
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ .asciz "@(#)fixunsdfsi.s 8.1 (Berkeley) 6/4/93"
+#else
+ RCSID("$NetBSD: fixunsdfsi.S,v 1.3 2000/07/25 04:26:12 mycroft Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if defined(SYSLIBC_RCS) && !defined(lint)
+ .text
+ .asciz "$FreeBSD$"
+#endif /* SYSLIBC_RCS and not lint */
+
+/*
+ * Convert double to unsigned integer (for gcc).
+ *
+ * I have made the output for NaN agree with the Sun compiler, not
+ * that it really matters, by using `fbul,a'.
+ */
+
+
+ .align 8
+.Lbig:
+ .word 0x43e00000 ! .double 2^63
+ .word 0 ! (who me, not trust the assembler?)
+
+/*
+ * Same as above but to unsigned long
+ */
+ENTRY(__dtoul)
+ PIC_PROLOGUE(%o4, %o5)
+ sub %sp, 16, %sp
+ std %f2, [%sp + CCFSZ + SPOFF + 8]
+ SET(.Lbig, %o5, %o3)
+ ldd [%o3], %f2
+ fcmped %f0, %f2 ! d < 2^63, or NaN, or -Inf?
+ fbul,a 1f ! if so, use fdtox to convert to long
+ fdtox %f0, %f0 ! (this includes negatives!)
+
+ ! d does not fit in a long, so subtract 2^63, convert,
+ ! and add 2^63 again (sigh). Just hope the intermediate
+ ! fits (if not, the result is undefined anyway).
+
+ fsubd %f0, %f2, %f0 ! d -= 2^63
+ fdtox %f0, %f0 ! convert to long
+ std %f0, [%sp + CCFSZ + SPOFF] ! move into return reg
+ ldx [%sp + CCFSZ + SPOFF], %o0
+ sethi %hi(0x80000000), %o1
+ sllx %o1, 32, %o1
+ add %o0, %o1, %o0 ! add 2^63
+ ldd [%sp + CCFSZ + SPOFF + 8], %f2
+ retl
+ add %sp, 16, %sp
+
+1:
+ std %f0, [%sp + CCFSZ + SPOFF] ! return result
+ ldx [%sp + CCFSZ + SPOFF], %o0
+ ldd [%sp + CCFSZ + SPOFF + 8], %f2
+ retl
+ add %sp, 16, %sp
+END(__dtoul)
diff --git a/lib/libc/sparc64/gen/flt_rounds.c b/lib/libc/sparc64/gen/flt_rounds.c
new file mode 100644
index 0000000..b0b7dde
--- /dev/null
+++ b/lib/libc/sparc64/gen/flt_rounds.c
@@ -0,0 +1,26 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/float.h>
+
+static const int map[] = {
+ 1, /* round to nearest */
+ 0, /* round to zero */
+ 3, /* round to negative infinity */
+ 2 /* round to positive infinity */
+};
+
+int
+__flt_rounds()
+{
+ int x;
+
+ __asm("st %%fsr,%0" : "=m" (*&x));
+ return map[(x >> 30) & 0x03];
+}
diff --git a/lib/libc/sparc64/gen/fpsetmask.c b/lib/libc/sparc64/gen/fpsetmask.c
new file mode 100644
index 0000000..a1ef3be
--- /dev/null
+++ b/lib/libc/sparc64/gen/fpsetmask.c
@@ -0,0 +1,27 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <ieeefp.h>
+
+fp_except_t
+fpsetmask(mask)
+ fp_except_t mask;
+{
+ fp_except_t old;
+ fp_except_t new;
+
+ __asm__("st %%fsr,%0" : "=m" (*&old));
+
+ new = old;
+ new &= ~(0x1f << 23);
+ new |= ((mask & 0x1f) << 23);
+
+ __asm__("ld %0,%%fsr" : : "m" (*&new));
+
+ return (old >> 23) & 0x1f;
+}
diff --git a/lib/libc/sparc64/gen/infinity.c b/lib/libc/sparc64/gen/infinity.c
new file mode 100644
index 0000000..3a5cd47
--- /dev/null
+++ b/lib/libc/sparc64/gen/infinity.c
@@ -0,0 +1,14 @@
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: infinity.c,v 1.2 1998/11/14 19:31:02 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD$");
+
+/* infinity.c */
+
+#include <math.h>
+
+/* bytes for +Infinity on a sparc */
+char __infinity[] = { 0x7f, (char)0xf0, 0, 0, 0, 0, 0, 0 };
diff --git a/lib/libc/sparc64/gen/isinf.c b/lib/libc/sparc64/gen/isinf.c
new file mode 100644
index 0000000..996ad12
--- /dev/null
+++ b/lib/libc/sparc64/gen/isinf.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $NetBSD: isinf.c,v 1.1 1995/02/10 17:50:23 cgd Exp $
+ * from: FreeBSD: src/lib/libc/alpha/gen/isinf.c,v 1.2 2000/05/10
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <math.h>
+
+int
+isnan(d)
+ double d;
+{
+ struct ieee_double *p = (struct ieee_double *)&d;
+
+ return (p->dbl_exp == DBL_EXP_INFNAN &&
+ (p->dbl_frach || p->dbl_fracl));
+}
+
+int
+isinf(d)
+ double d;
+{
+ struct ieee_double *p = (struct ieee_double *)&d;
+
+ return (p->dbl_exp == DBL_EXP_INFNAN &&
+ !p->dbl_frach && !p->dbl_fracl);
+}
diff --git a/lib/libc/sparc64/gen/ldexp.c b/lib/libc/sparc64/gen/ldexp.c
new file mode 100644
index 0000000..3a85612
--- /dev/null
+++ b/lib/libc/sparc64/gen/ldexp.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if 0
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: ldexp.c,v 1.8 1999/08/30 18:28:26 mycroft Exp $");
+#endif /* LIBC_SCCS and not lint */
+#endif
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <errno.h>
+#include <math.h>
+
+/*
+ * Multiply the given value by 2^exp.
+ */
+double
+ldexp(val, exp)
+ double val;
+ int exp;
+{
+ int oldexp, newexp;
+ union {
+ double v;
+ struct ieee_double s;
+ } u, mul;
+
+ u.v = val;
+ oldexp = u.s.dbl_exp;
+
+ /*
+ * If input is zero, Inf or NaN, just return it.
+ */
+ if (u.v == 0.0 || oldexp == DBL_EXP_INFNAN)
+ return (val);
+
+ if (oldexp == 0) {
+ /*
+ * u.v is denormal. We must adjust it so that the exponent
+ * arithmetic below will work.
+ */
+ if (exp <= DBL_EXP_BIAS) {
+ /*
+ * Optimization: if the scaling can be done in a single
+ * multiply, or underflows, just do it now.
+ */
+ if (exp <= -DBL_FRACBITS) {
+ errno = ERANGE;
+ return (0.0);
+ }
+ mul.v = 0.0;
+ mul.s.dbl_exp = exp + DBL_EXP_BIAS;
+ u.v *= mul.v;
+ if (u.v == 0.0) {
+ errno = ERANGE;
+ return (0.0);
+ }
+ return (u.v);
+ } else {
+ /*
+ * We know that exp is very large, and therefore the
+ * result cannot be denormal (though it may be Inf).
+ * Shift u.v by just enough to make it normal.
+ */
+ mul.v = 0.0;
+ mul.s.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS;
+ u.v *= mul.v;
+ exp -= DBL_FRACBITS;
+ oldexp = u.s.dbl_exp;
+ }
+ }
+
+ /*
+ * u.v is now normalized and oldexp has been adjusted if necessary.
+ * Calculate the new exponent and check for underflow and overflow.
+ */
+ newexp = oldexp + exp;
+
+ if (newexp <= 0) {
+ /*
+ * The output number is either denormal or underflows (see
+ * comments in machine/ieee.h).
+ */
+ if (newexp <= -DBL_FRACBITS) {
+ errno = ERANGE;
+ return (0.0);
+ }
+ /*
+ * Denormalize the result. We do this with a multiply. If exp
+ * is very large, it won't fit in a double, so we have to
+ * adjust the exponent first. This is safe because we know
+ * that u.v is normal at this point.
+ */
+ if (exp <= -DBL_EXP_BIAS) {
+ u.s.dbl_exp = 1;
+ exp += oldexp - 1;
+ }
+ mul.v = 0.0;
+ mul.s.dbl_exp = exp + DBL_EXP_BIAS;
+ u.v *= mul.v;
+ return (u.v);
+ } else if (newexp >= DBL_EXP_INFNAN) {
+ /*
+ * The result overflowed; return +/-Inf.
+ */
+ u.s.dbl_exp = DBL_EXP_INFNAN;
+ u.s.dbl_frach = 0;
+ u.s.dbl_fracl = 0;
+ errno = ERANGE;
+ return (u.v);
+ } else {
+ /*
+ * The result is normal; just replace the old exponent with the
+ * new one.
+ */
+ u.s.dbl_exp = newexp;
+ return (u.v);
+ }
+}
diff --git a/lib/libc/sparc64/gen/modf.S b/lib/libc/sparc64/gen/modf.S
new file mode 100644
index 0000000..a9242d8
--- /dev/null
+++ b/lib/libc/sparc64/gen/modf.S
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ *
+ * from: Header: modf.s,v 1.3 92/06/20 00:00:54 torek Exp
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93"
+#else
+ .asciz "$NetBSD: modf.S,v 1.2 2000/07/23 07:12:22 eeh Exp $"
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if defined(SYSLIBC_RCS) && !defined(lint)
+ .text
+ .asciz "$FreeBSD$"
+#endif /* SYSLIBC_RCS and not lint */
+
+#include <machine/asm.h>
+
+#include "assym.s"
+
+/*
+ * double modf(double val, double *iptr)
+ *
+ * Returns the fractional part of `val', storing the integer part of
+ * `val' in *iptr. Both *iptr and the return value have the same sign
+ * as `val'.
+ *
+ * Method:
+ *
+ * We use the fpu's normalization hardware to compute the integer portion
+ * of the double precision argument. Sun IEEE double precision numbers
+ * have 52 bits of mantissa, 11 bits of exponent, and one bit of sign,
+ * with the sign occupying bit 31 of word 0, and the exponent bits 30:20
+ * of word 0. Thus, values >= 2^52 are by definition integers.
+ *
+ * If we take a value that is in the range [+0..2^52) and add 2^52, all
+ * of the fractional bits fall out and all of the integer bits are summed
+ * with 2^52. If we then subtract 2^52, we get those integer bits back.
+ * This must be done with rounding set to `towards 0' or `towards -inf'.
+ * `Toward -inf' fails when the value is 0 (we get -0 back)....
+ *
+ * Note that this method will work anywhere, but is machine dependent in
+ * various aspects.
+ *
+ * Stack usage:
+ * 4@[%fp + SPOFF - 4] saved %fsr
+ * 4@[%fp + SPOFF - 8] new %fsr with rounding set to `towards 0'
+ * 8@[%fp + SPOFF - 16] space for moving between %i and %f registers
+ * Register usage:
+ * %f0:f1 double val;
+ * %l0 scratch
+ * %l1 sign bit (0x80000000)
+ * %i1 double *iptr;
+ * %f2:f3 `magic number' 2^52, in fpu registers
+ * %f4:f5 double v, in fpu registers
+ * %f6:f7 double temp.
+ */
+
+ .align 8
+.Lmagic:
+ .word 0x43300000 ! sign = 0, exponent = 52 + 1023, mantissa = 0
+ .word 0 ! (i.e., .double 0r4503599627370496e+00)
+
+.L0:
+ .word 0 ! 0.0
+ .word 0
+
+ENTRY(modf)
+ save %sp, -CCFSZ - 16, %sp
+ PIC_PROLOGUE(%l6, %l7)
+
+ /*
+ * First, compute v = abs(val)
+ */
+ fabsd %f0, %f4 ! %f4:f5 = v
+ fcmped %fcc1, %f0, %f4 ! %fcc1 = (val == abs(val))
+ SET(.Lmagic, %l7, %l0)
+ ldd [%l0], %f2
+
+ /*
+ * Is %f4:f5 >= %f2:f3 ? If so, it is all integer bits.
+ * It is probably less, though.
+ */
+ fcmped %f4, %f2
+ fbuge .Lbig ! if >= (or unordered), go out
+ nop
+
+ /*
+ * v < 2^52, so add 2^52, then subtract 2^52, but do it all
+ * with rounding set towards zero. We leave any enabled
+ * traps enabled, but change the rounding mode. This might
+ * not be so good. Oh well....
+ */
+ st %fsr, [%fp + SPOFF - 4] ! %l5 = current FSR mode
+ set FSR_RD_MASK, %l3 ! %l3 = rounding direction mask
+ ld [%fp + SPOFF - 4], %l5
+ set FSR_RD_RD_Z, %l4
+ andn %l5, %l3, %l6
+ or %l6, %l4, %l6 ! round towards zero, please
+ and %l5, %l3, %l5 ! save original rounding mode
+ st %l6, [%fp + SPOFF - 8]
+ ld [%fp + SPOFF - 8], %fsr
+
+ faddd %f4, %f2, %f4 ! %f4:f5 += 2^52
+ fsubd %f4, %f2, %f4 ! %f4:f5 -= 2^52
+
+ /*
+ * Restore %fsr, but leave exceptions accrued.
+ */
+ st %fsr, [%fp + SPOFF - 4]
+ ld [%fp + SPOFF - 4], %l6
+ andn %l6, %l3, %l6 ! %l6 = %fsr & ~FSR_RD_MASK;
+ or %l5, %l6, %l5 ! %l5 |= %l6;
+ st %l5, [%fp + SPOFF - 4]
+ ld [%fp + SPOFF - 4], %fsr ! restore %fsr, leaving accrued stuff
+
+ /*
+ * Now insert the original sign in %f4:f5.
+ * %fcc1 should still have the results of (val == abs(val))
+ * from above, so we use a conditional move on %fcc1 to:
+ *
+ * %f4 = (val == abs(val)) ? %f4 : -%f4
+ *
+ */
+ fnegd %f4, %f6
+ fmovdnz %fcc1, %f6, %f4
+1:
+
+ /*
+ * The value in %f4:f5 is now the integer portion of the original
+ * argument. We need to store this in *ival (%i1), subtract it
+ * from the original value argument (%d0), and return the result.
+ */
+ std %f4, [%i1] ! *ival = %f4:f5;
+ fsubd %f0, %f4, %f0 ! %f0:f1 -= %f4:f5;
+ ret
+ restore
+
+.Lbig:
+ /*
+ * We get here if the original comparison of %f4:f5 (v) to
+ * %f2:f3 (2^52) came out `greater or unordered'. In this
+ * case the integer part is the original value, and the
+ * fractional part is 0.
+ */
+ SET(.L0, %l7, %l0)
+ std %f0, [%i1] ! *ival = val;
+ ldd [%l0], %f0 ! return 0.0;
+ ret
+ restore
+END(modf)
diff --git a/lib/libc/sparc64/gen/setjmp.S b/lib/libc/sparc64/gen/setjmp.S
new file mode 100644
index 0000000..c96bc42
--- /dev/null
+++ b/lib/libc/sparc64/gen/setjmp.S
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ *
+ * from: Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
+#else
+ RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if defined(SYSLIBC_RCS) && !defined(lint)
+ .text
+ .asciz "$FreeBSD$"
+#endif /* SYSLIBC_RCS and not lint */
+
+#include <machine/asm.h>
+
+#include "assym.s"
+
+ .register %g2,#ignore
+ .register %g3,#ignore
+
+/*
+ * C library -- setjmp, longjmp
+ *
+ * longjmp(a,v)
+ * will generate a "return(v?v:1)" from
+ * the last call to
+ * setjmp(a)
+ * by restoring the previous context.
+ */
+
+ENTRY(setjmp)
+ save %sp, -CCFSZ, %sp
+ mov SIG_BLOCK, %o0
+ clr %o1
+ call CNAME(sigprocmask)
+ add %i0, _JB_SIGMASK, %o2
+ restore
+ stx %sp, [%o0 + _JB_SP]
+ stx %o7, [%o0 + _JB_PC]
+ stx %fp, [%o0 + _JB_FP]
+ retl
+ clr %o0
+END(setjmp)
+
+ .weak CNAME(longjmp)
+ .set CNAME(longjmp),CNAME(__longjmp)
+ENTRY(__longjmp)
+ save %sp, -CCFSZ, %sp
+ mov SIG_SETMASK, %o0
+ add %i0, _JB_SIGMASK, %o1
+ call CNAME(sigprocmask)
+ clr %o2
+ restore
+ mov 1, %g1
+ movrnz %o1, %o1, %g1
+ mov %o0, %g2
+ ldx [%g2 + _JB_FP], %g3
+1: cmp %fp, %g3
+ bl,a 1b
+ restore
+ be,a 2f
+ ldx [%g2 + _JB_SP], %o0
+
+.Lbotch:
+ call CNAME(longjmperror)
+ nop
+ call CNAME(abort)
+ nop
+ illtrap
+
+2: cmp %o0, %sp
+ bge,a 3f
+ mov %o0, %sp
+ b,a .Lbotch
+ nop
+3: ldx [%g2 + _JB_PC], %o7
+ retl
+ mov %g1, %o0
+END(__longjmp)
diff --git a/lib/libc/sparc64/gen/sigsetjmp.S b/lib/libc/sparc64/gen/sigsetjmp.S
new file mode 100644
index 0000000..d7741c2
--- /dev/null
+++ b/lib/libc/sparc64/gen/sigsetjmp.S
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1995 Paul Kranenburg
+ * 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 Paul Kranenburg.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#if defined(SYSLIBC_RCS) && !defined(lint)
+ .text
+ .asciz "$FreeBSD$"
+#endif /* SYSLIBC_RCS and not lint */
+
+#include <machine/asm.h>
+
+#include "assym.s"
+
+ENTRY(sigsetjmp)
+ PIC_PROLOGUE(%o3, %o2)
+ SET(CNAME(setjmp), %o2, %o3)
+ SET(CNAME(_setjmp), %o2, %o4)
+ movrnz %o1, %o3, %o4
+ jmp %o4
+ stx %o1, [%o0 + _JB_SIGFLAG]
+END(sigsetjmp)
+
+ENTRY(siglongjmp)
+ PIC_PROLOGUE(%o3, %o2)
+ SET(CNAME(longjmp), %o2, %o3)
+ SET(CNAME(_longjmp), %o2, %o4)
+ ldx [%o0 + _JB_SIGFLAG], %o2
+ movrnz %o2, %o3, %o4
+ jmp %o4
+ nop
+END(siglongjmp)
OpenPOWER on IntegriCloud