summaryrefslogtreecommitdiff
path: root/lib/libc/arch/m88k/gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/arch/m88k/gen')
-rw-r--r--lib/libc/arch/m88k/gen/Makefile.inc12
-rw-r--r--lib/libc/arch/m88k/gen/_setjmp.S50
-rw-r--r--lib/libc/arch/m88k/gen/fabs.S14
-rw-r--r--lib/libc/arch/m88k/gen/flt_rounds.c27
-rw-r--r--lib/libc/arch/m88k/gen/fpgetmask.c16
-rw-r--r--lib/libc/arch/m88k/gen/fpgetround.c16
-rw-r--r--lib/libc/arch/m88k/gen/fpgetsticky.c16
-rw-r--r--lib/libc/arch/m88k/gen/fpsetmask.c25
-rw-r--r--lib/libc/arch/m88k/gen/fpsetround.c25
-rw-r--r--lib/libc/arch/m88k/gen/fpsetsticky.c25
-rw-r--r--lib/libc/arch/m88k/gen/frexp.c79
-rw-r--r--lib/libc/arch/m88k/gen/infinity.c10
-rw-r--r--lib/libc/arch/m88k/gen/isinf.c65
-rw-r--r--lib/libc/arch/m88k/gen/isnan.c55
-rw-r--r--lib/libc/arch/m88k/gen/ldexp.c148
-rw-r--r--lib/libc/arch/m88k/gen/modf.c309
-rw-r--r--lib/libc/arch/m88k/gen/setjmp.S61
-rw-r--r--lib/libc/arch/m88k/gen/sigsetjmp.S64
18 files changed, 1017 insertions, 0 deletions
diff --git a/lib/libc/arch/m88k/gen/Makefile.inc b/lib/libc/arch/m88k/gen/Makefile.inc
new file mode 100644
index 00000000000..3c4ea22c543
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/Makefile.inc
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile.inc,v 1.3 1995/04/10 21:09:06 jtc Exp $
+
+#SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c isnan.c ldexp.c modf.S
+#SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+# fpsetround.c fpsetsticky.c
+#SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S setjmp.S sigsetjmp.S
+
+SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c ldexp.c
+SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+ fpsetround.c fpsetsticky.c
+SRCS+= setjmp.S sigsetjmp.S
+SRCS+= modf.c
diff --git a/lib/libc/arch/m88k/gen/_setjmp.S b/lib/libc/arch/m88k/gen/_setjmp.S
new file mode 100644
index 00000000000..d7228f04ede
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/_setjmp.S
@@ -0,0 +1,50 @@
+#include "SYS.h"
+
+ENTRY(_setjmp)
+ st r1, r2,0
+ st r14,r2,8
+ st r15,r2,12
+ st r16,r2,16
+ st r17,r2,20
+ st r18,r2,24
+ st r19,r2,28
+ st r20,r2,32
+ st r21,r2,36
+ st r22,r2,40
+ st r23,r2,44
+ st r24,r2,48
+ st r25,r2,52
+ st r26,r2,56
+ st r27,r2,60
+ st r28,r2,64
+ st r29,r2,68
+ st r30,r2,72
+ st r31,r2,76
+ jmp.n r1
+ or r2,r0,0
+
+ENTRY(_longjmp)
+ ld r14,r2,8
+ ld r15,r2,12
+ ld r16,r2,16
+ ld r17,r2,20
+ ld r18,r2,24
+ ld r19,r2,28
+ ld r20,r2,32
+ ld r21,r2,36
+ ld r22,r2,40
+ ld r23,r2,44
+ ld r24,r2,48
+ ld r25,r2,52
+ ld r26,r2,56
+ ld r27,r2,60
+ ld r28,r2,64
+ ld r29,r2,68
+ ld r30,r2,72
+ ld r31,r2,76
+ ld r1,r2,0
+ bcnd.n ne0,r3,dsrlbl
+ or r2,r3,0
+ or r2,r0,1
+ dsrlbl:
+ jmp r1
diff --git a/lib/libc/arch/m88k/gen/fabs.S b/lib/libc/arch/m88k/gen/fabs.S
new file mode 100644
index 00000000000..810ccf30ef3
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fabs.S
@@ -0,0 +1,14 @@
+#include <machine/asm.h>
+/*
+ * Will work only if the argument passed is in IEEE format!
+ */
+
+ENTRY(fabs)
+ subu r31,r31,40
+ st.d r2,r31,32
+ ld.bu r4,r31,32
+ mask r4,r4,0x7f /* set sign bit to 0 */
+ st.b r4,r31,32
+ ld.d r2,r31,32
+ jmp.n r1
+ addu r31,r31,40
diff --git a/lib/libc/arch/m88k/gen/flt_rounds.c b/lib/libc/arch/m88k/gen/flt_rounds.c
new file mode 100644
index 00000000000..c3f6e4f2c58
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/flt_rounds.c
@@ -0,0 +1,27 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <sys/types.h>
+#include <machine/float.h>
+
+/*
+ * Ported to 88k (Nivas Madhur)
+ */
+
+static const int map[] = {
+ 0, /* round to nearest */
+ 1, /* round to zero */
+ 2, /* round to negative infinity */
+ 3 /* round to positive infinity */
+};
+
+int
+__flt_rounds()
+{
+ int x;
+
+ __asm__("fldcr %0,fcr63" : "=r" (x));
+ return map[(x >> 14) & 0x03];
+}
diff --git a/lib/libc/arch/m88k/gen/fpgetmask.c b/lib/libc/arch/m88k/gen/fpgetmask.c
new file mode 100644
index 00000000000..832fe0de567
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fpgetmask.c
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ * Ported to 88k by Nivas Madhur.
+ */
+
+#include <ieeefp.h>
+
+fp_except
+fpgetmask()
+{
+ int x;
+
+ __asm__ volatile ("fldcr %0,fcr63" : "=r" (x));
+ return (x & 0x1f);
+}
diff --git a/lib/libc/arch/m88k/gen/fpgetround.c b/lib/libc/arch/m88k/gen/fpgetround.c
new file mode 100644
index 00000000000..4edac881ff9
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fpgetround.c
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ * Ported to 88k by Nivas Madhur.
+ */
+
+#include <ieeefp.h>
+
+fp_rnd
+fpgetround()
+{
+ int x;
+
+ __asm__ volatile ("fldcr %0, fcr63" : "=r" (x));
+ return (x >> 14) & 0x03;
+}
diff --git a/lib/libc/arch/m88k/gen/fpgetsticky.c b/lib/libc/arch/m88k/gen/fpgetsticky.c
new file mode 100644
index 00000000000..6d5bdc7bbde
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fpgetsticky.c
@@ -0,0 +1,16 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ * Ported to 88k by Nivas Madhur
+ */
+
+#include <ieeefp.h>
+
+fp_except
+fpgetsticky()
+{
+ int x;
+
+ __asm__ volatile("fldcr %0,fcr62" : "=r" (x));
+ return x & 0x1f;
+}
diff --git a/lib/libc/arch/m88k/gen/fpsetmask.c b/lib/libc/arch/m88k/gen/fpsetmask.c
new file mode 100644
index 00000000000..42d88a7f641
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fpsetmask.c
@@ -0,0 +1,25 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ * Porting to m88k by Nivas Madhur.
+ */
+
+#include <ieeefp.h>
+
+fp_except
+fpsetmask(mask)
+ fp_except mask;
+{
+ fp_except old;
+ fp_except new;
+
+ __asm__ volatile("fldcr %0,fcr63" : "=r" (old));
+
+ new = old;
+ new &= ~0x1f; /* clear bottom 5 bits and */
+ new |= (mask & 0x1f); /* set them to mask */
+
+ __asm__ volatile("fstcr %0,fcr63" : : "r" (new));
+
+ return (old & 0x1f);
+}
diff --git a/lib/libc/arch/m88k/gen/fpsetround.c b/lib/libc/arch/m88k/gen/fpsetround.c
new file mode 100644
index 00000000000..417eefefa87
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fpsetround.c
@@ -0,0 +1,25 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ * Ported to 88k by Nivas Madhur
+ */
+
+#include <ieeefp.h>
+
+fp_rnd
+fpsetround(rnd_dir)
+ fp_rnd rnd_dir;
+{
+ fp_rnd old;
+ fp_rnd new;
+
+ __asm__ volatile("fldcr %0,fcr63" : "=r" (old));
+
+ new = old;
+ new &= ~(0x03 << 14); /* clear old value */
+ new |= ((rnd_dir & 0x03) << 14);/* and set new one */
+
+ __asm__ volatile("fstcr %0,fcr63" : : "r" (new));
+
+ return (old >> 14) & 0x03;
+}
diff --git a/lib/libc/arch/m88k/gen/fpsetsticky.c b/lib/libc/arch/m88k/gen/fpsetsticky.c
new file mode 100644
index 00000000000..2c3f4c8c6d8
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/fpsetsticky.c
@@ -0,0 +1,25 @@
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ * Ported to m88k by Nivas Madhur.
+ */
+
+#include <ieeefp.h>
+
+fp_except
+fpsetsticky(sticky)
+ fp_except sticky;
+{
+ fp_except old;
+ fp_except new;
+
+ __asm__ volatile("fldcr %0,fcr62" : "=r" (old));
+
+ new = old;
+ new &= ~(0x1f);
+ new |= (sticky & 0x1f);
+
+ __asm__ volatile("fstcr %0,fcr62" : : "r" (new));
+
+ return (old & 0x1f);
+}
diff --git a/lib/libc/arch/m88k/gen/frexp.c b/lib/libc/arch/m88k/gen/frexp.c
new file mode 100644
index 00000000000..68a208d01d8
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/frexp.c
@@ -0,0 +1,79 @@
+/*
+ * 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: frexp.c,v 1.1 91/07/07 04:45:01 torek Exp
+ * $Id: frexp.c,v 1.1 1998/12/15 07:10:30 smurph Exp $
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)frexp.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+
+/*
+ * Split the given value into a fraction in the range [0.5, 1.0) and
+ * an exponent, such that frac * (2^exp) == value. If value is 0,
+ * return 0.
+ */
+double
+frexp(value, eptr)
+ double value;
+ int *eptr;
+{
+ union {
+ double v;
+ struct ieee_double s;
+ } u;
+
+ if (value) {
+ /*
+ * Fractions in [0.5..1.0) have an exponent of 2^-1.
+ * Leave Inf and NaN alone, however.
+ * WHAT ABOUT DENORMS?
+ */
+ u.v = value;
+ if (u.s.dbl_exp != DBL_EXP_INFNAN) {
+ *eptr = u.s.dbl_exp - (DBL_EXP_BIAS - 1);
+ u.s.dbl_exp = DBL_EXP_BIAS - 1;
+ }
+ return (u.v);
+ } else {
+ *eptr = 0;
+ return ((double)0);
+ }
+}
diff --git a/lib/libc/arch/m88k/gen/infinity.c b/lib/libc/arch/m88k/gen/infinity.c
new file mode 100644
index 00000000000..5d63ff87b44
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/infinity.c
@@ -0,0 +1,10 @@
+#ifndef lint
+static char rcsid[] = "$Id: infinity.c,v 1.1 1998/12/15 07:10:30 smurph Exp $";
+#endif /* not lint */
+
+/* infinity.c */
+
+#include <math.h>
+
+/* bytes for +Infinity on 88100 */
+char __infinity[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
diff --git a/lib/libc/arch/m88k/gen/isinf.c b/lib/libc/arch/m88k/gen/isinf.c
new file mode 100644
index 00000000000..7d4be7e6bc3
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/isinf.c
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 1991 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[] = "from: @(#)isinf.c 5.1 (Berkeley) 3/18/91";*/
+static char rcsid[] = "$Id: isinf.c,v 1.1 1998/12/15 07:10:30 smurph Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+
+isnan(d)
+ double d;
+{
+ register struct IEEEdp {
+ u_int sign : 1;
+ u_int exp : 11;
+ u_int manh : 20;
+ u_int manl : 32;
+ } *p = (struct IEEEdp *)&d;
+
+ return(p->exp == 2047 && (p->manh || p->manl));
+}
+
+isinf(d)
+ double d;
+{
+ register struct IEEEdp {
+ u_int sign : 1;
+ u_int exp : 11;
+ u_int manh : 20;
+ u_int manl : 32;
+ } *p = (struct IEEEdp *)&d;
+
+ return(p->exp == 2047 && !p->manh && !p->manl);
+}
diff --git a/lib/libc/arch/m88k/gen/isnan.c b/lib/libc/arch/m88k/gen/isnan.c
new file mode 100644
index 00000000000..2ad50f1bddd
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/isnan.c
@@ -0,0 +1,55 @@
+/*
+ * 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: isnan.c,v 1.1 91/07/08 19:03:34 torek Exp
+ * $Id: isnan.c,v 1.1 1998/12/15 07:10:31 smurph Exp $
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)isnan.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+
+isnan(d)
+ double d;
+{
+ register struct ieee_double *p = (struct ieee_double *)&d;
+
+ return (p->dbl_exp == DBL_EXP_INFNAN &&
+ (p->dbl_frach != 0 || p->dbl_fracl != 0));
+}
diff --git a/lib/libc/arch/m88k/gen/ldexp.c b/lib/libc/arch/m88k/gen/ldexp.c
new file mode 100644
index 00000000000..0da4f5f365c
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/ldexp.c
@@ -0,0 +1,148 @@
+/*
+ * 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: ldexp.c,v 1.1 91/07/07 04:28:19 torek Exp
+ * $Id: ldexp.c,v 1.1 1998/12/15 07:10:31 smurph Exp $
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char sccsid[] = "@(#)ldexp.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <errno.h>
+
+/*
+ * double ldexp(double val, int exp)
+ * returns: val * (2**exp)
+ */
+double
+ldexp(val, exp)
+ double val;
+ int exp;
+{
+ register int oldexp, newexp, mulexp;
+ union doub {
+ double v;
+ struct ieee_double s;
+ } u, mul;
+
+ /*
+ * If input is zero, or no change, just return input.
+ * Likewise, if input is Inf or NaN, just return it.
+ */
+ u.v = val;
+ oldexp = u.s.dbl_exp;
+ if (val == 0 || exp == 0 || oldexp == DBL_EXP_INFNAN)
+ return (val);
+
+ /*
+ * Compute new exponent and check for over/under flow.
+ * Underflow, unfortunately, could mean switching to denormal.
+ * If result out of range, set ERANGE and return 0 if too small
+ * or Inf if too big, with the same sign as the input value.
+ */
+ newexp = oldexp + exp;
+ if (newexp >= DBL_EXP_INFNAN) {
+ /* u.s.dbl_sign = val < 0; -- already set */
+ u.s.dbl_exp = DBL_EXP_INFNAN;
+ u.s.dbl_frach = u.s.dbl_fracl = 0;
+ errno = ERANGE;
+ return (u.v); /* Inf */
+ }
+ if (newexp <= 0) {
+ /*
+ * The output number is either a denormal or underflows
+ * (see comments in machine/ieee.h).
+ */
+ if (newexp <= -DBL_FRACBITS) {
+ /* u.s.dbl_sign = val < 0; -- already set */
+ u.s.dbl_exp = 0;
+ u.s.dbl_frach = u.s.dbl_fracl = 0;
+ errno = ERANGE;
+ return (u.v); /* zero */
+ }
+ /*
+ * We are going to produce a denorm. Our `exp' argument
+ * might be as small as -2097, and we cannot compute
+ * 2^-2097, so we may have to do this as many as three
+ * steps (not just two, as for positive `exp's below).
+ */
+ mul.v = 0;
+ while (exp <= -DBL_EXP_BIAS) {
+ mul.s.dbl_exp = 1;
+ val *= mul.v;
+ exp += DBL_EXP_BIAS - 1;
+ }
+ mul.s.dbl_exp = exp + DBL_EXP_BIAS;
+ val *= mul.v;
+ return (val);
+ }
+
+ /*
+ * Newexp is positive.
+ *
+ * If oldexp is zero, we are starting with a denorm, and simply
+ * adjusting the exponent will produce bogus answers. We need
+ * to fix that first.
+ */
+ if (oldexp == 0) {
+ /*
+ * Multiply by 2^mulexp to make the number normalizable.
+ * We cannot multiply by more than 2^1023, but `exp'
+ * argument might be as large as 2046. A single
+ * adjustment, however, will normalize the number even
+ * for huge `exp's, and then we can use exponent
+ * arithmetic just as for normal `double's.
+ */
+ mulexp = exp <= DBL_EXP_BIAS ? exp : DBL_EXP_BIAS;
+ mul.v = 0;
+ mul.s.dbl_exp = mulexp + DBL_EXP_BIAS;
+ val *= mul.v;
+ if (mulexp == exp)
+ return (val);
+ u.v = val;
+ newexp -= mulexp;
+ }
+
+ /*
+ * Both oldexp and newexp are positive; just replace the
+ * old exponent with the new one.
+ */
+ u.s.dbl_exp = newexp;
+ return (u.v);
+}
diff --git a/lib/libc/arch/m88k/gen/modf.c b/lib/libc/arch/m88k/gen/modf.c
new file mode 100644
index 00000000000..aa3853bad7e
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/modf.c
@@ -0,0 +1,309 @@
+/* @(#)s_modf.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#if defined(LIBM_SCCS) && !defined(lint)
+static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $";
+#endif
+
+/*
+ * modf(double x, double *iptr)
+ * return fraction part of x, and return x's integral part in *iptr.
+ * Method:
+ * Bit twiddling.
+ *
+ * Exception:
+ * No exception.
+ */
+
+#include "math.h"
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * from: @(#)fdlibm.h 5.1 93/09/24
+ * $Id: modf.c,v 1.1 1998/12/15 07:10:31 smurph Exp $
+ */
+
+#ifndef _MATH_PRIVATE_H_
+#define _MATH_PRIVATE_H_
+
+#include <sys/types.h>
+#include <machine/endian.h>
+
+/* The original fdlibm code used statements like:
+ n0 = ((*(int*)&one)>>29)^1; * index of high word *
+ ix0 = *(n0+(int*)&x); * high word of x *
+ ix1 = *((1-n0)+(int*)&x); * low word of x *
+ to dig two 32 bit words out of the 64 bit IEEE floating point
+ value. That is non-ANSI, and, moreover, the gcc instruction
+ scheduler gets it wrong. We instead use the following macros.
+ Unlike the original code, we determine the endianness at compile
+ time, not at run time; I don't see much benefit to selecting
+ endianness at run time. */
+
+/* A union which permits us to convert between a double and two 32 bit
+ ints. */
+
+/*
+ * The arm32 port is little endian except for the FP word order which is
+ * big endian.
+ */
+
+#if (BYTE_ORDER == BIG_ENDIAN) || defined(arm32)
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t msw;
+ u_int32_t lsw;
+ } parts;
+} ieee_double_shape_type;
+
+#endif
+
+#if (BYTE_ORDER == LITTLE_ENDIAN) && !defined(arm32)
+
+typedef union
+{
+ double value;
+ struct
+ {
+ u_int32_t lsw;
+ u_int32_t msw;
+ } parts;
+} ieee_double_shape_type;
+
+#endif
+
+/* Get two 32 bit ints from a double. */
+
+#define EXTRACT_WORDS(ix0,ix1,d) \
+do { \
+ ieee_double_shape_type ew_u; \
+ ew_u.value = (d); \
+ (ix0) = ew_u.parts.msw; \
+ (ix1) = ew_u.parts.lsw; \
+} while (0)
+
+/* Get the more significant 32 bit int from a double. */
+
+#define GET_HIGH_WORD(i,d) \
+do { \
+ ieee_double_shape_type gh_u; \
+ gh_u.value = (d); \
+ (i) = gh_u.parts.msw; \
+} while (0)
+
+/* Get the less significant 32 bit int from a double. */
+
+#define GET_LOW_WORD(i,d) \
+do { \
+ ieee_double_shape_type gl_u; \
+ gl_u.value = (d); \
+ (i) = gl_u.parts.lsw; \
+} while (0)
+
+/* Set a double from two 32 bit ints. */
+
+#define INSERT_WORDS(d,ix0,ix1) \
+do { \
+ ieee_double_shape_type iw_u; \
+ iw_u.parts.msw = (ix0); \
+ iw_u.parts.lsw = (ix1); \
+ (d) = iw_u.value; \
+} while (0)
+
+/* Set the more significant 32 bits of a double from an int. */
+
+#define SET_HIGH_WORD(d,v) \
+do { \
+ ieee_double_shape_type sh_u; \
+ sh_u.value = (d); \
+ sh_u.parts.msw = (v); \
+ (d) = sh_u.value; \
+} while (0)
+
+/* Set the less significant 32 bits of a double from an int. */
+
+#define SET_LOW_WORD(d,v) \
+do { \
+ ieee_double_shape_type sl_u; \
+ sl_u.value = (d); \
+ sl_u.parts.lsw = (v); \
+ (d) = sl_u.value; \
+} while (0)
+
+/* A union which permits us to convert between a float and a 32 bit
+ int. */
+
+typedef union
+{
+ float value;
+ u_int32_t word;
+} ieee_float_shape_type;
+
+/* Get a 32 bit int from a float. */
+
+#define GET_FLOAT_WORD(i,d) \
+do { \
+ ieee_float_shape_type gf_u; \
+ gf_u.value = (d); \
+ (i) = gf_u.word; \
+} while (0)
+
+/* Set a float from a 32 bit int. */
+
+#define SET_FLOAT_WORD(d,i) \
+do { \
+ ieee_float_shape_type sf_u; \
+ sf_u.word = (i); \
+ (d) = sf_u.value; \
+} while (0)
+
+/* ieee style elementary functions */
+extern double __ieee754_sqrt __P((double));
+extern double __ieee754_acos __P((double));
+extern double __ieee754_acosh __P((double));
+extern double __ieee754_log __P((double));
+extern double __ieee754_atanh __P((double));
+extern double __ieee754_asin __P((double));
+extern double __ieee754_atan2 __P((double,double));
+extern double __ieee754_exp __P((double));
+extern double __ieee754_cosh __P((double));
+extern double __ieee754_fmod __P((double,double));
+extern double __ieee754_pow __P((double,double));
+extern double __ieee754_lgamma_r __P((double,int *));
+extern double __ieee754_gamma_r __P((double,int *));
+extern double __ieee754_lgamma __P((double));
+extern double __ieee754_gamma __P((double));
+extern double __ieee754_log10 __P((double));
+extern double __ieee754_sinh __P((double));
+extern double __ieee754_hypot __P((double,double));
+extern double __ieee754_j0 __P((double));
+extern double __ieee754_j1 __P((double));
+extern double __ieee754_y0 __P((double));
+extern double __ieee754_y1 __P((double));
+extern double __ieee754_jn __P((int,double));
+extern double __ieee754_yn __P((int,double));
+extern double __ieee754_remainder __P((double,double));
+extern int __ieee754_rem_pio2 __P((double,double*));
+extern double __ieee754_scalb __P((double,double));
+
+/* fdlibm kernel function */
+extern double __kernel_standard __P((double,double,int));
+extern double __kernel_sin __P((double,double,int));
+extern double __kernel_cos __P((double,double));
+extern double __kernel_tan __P((double,double,int));
+extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));
+
+
+/* ieee style elementary float functions */
+extern float __ieee754_sqrtf __P((float));
+extern float __ieee754_acosf __P((float));
+extern float __ieee754_acoshf __P((float));
+extern float __ieee754_logf __P((float));
+extern float __ieee754_atanhf __P((float));
+extern float __ieee754_asinf __P((float));
+extern float __ieee754_atan2f __P((float,float));
+extern float __ieee754_expf __P((float));
+extern float __ieee754_coshf __P((float));
+extern float __ieee754_fmodf __P((float,float));
+extern float __ieee754_powf __P((float,float));
+extern float __ieee754_lgammaf_r __P((float,int *));
+extern float __ieee754_gammaf_r __P((float,int *));
+extern float __ieee754_lgammaf __P((float));
+extern float __ieee754_gammaf __P((float));
+extern float __ieee754_log10f __P((float));
+extern float __ieee754_sinhf __P((float));
+extern float __ieee754_hypotf __P((float,float));
+extern float __ieee754_j0f __P((float));
+extern float __ieee754_j1f __P((float));
+extern float __ieee754_y0f __P((float));
+extern float __ieee754_y1f __P((float));
+extern float __ieee754_jnf __P((int,float));
+extern float __ieee754_ynf __P((int,float));
+extern float __ieee754_remainderf __P((float,float));
+extern int __ieee754_rem_pio2f __P((float,float*));
+extern float __ieee754_scalbf __P((float,float));
+
+/* float versions of fdlibm kernel functions */
+extern float __kernel_sinf __P((float,float,int));
+extern float __kernel_cosf __P((float,float));
+extern float __kernel_tanf __P((float,float,int));
+extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int*));
+
+#endif /* _MATH_PRIVATE_H_ */
+#ifdef __STDC__
+static const double one = 1.0;
+#else
+static double one = 1.0;
+#endif
+
+#ifdef __STDC__
+ double modf(double x, double *iptr)
+#else
+ double modf(x, iptr)
+ double x,*iptr;
+#endif
+{
+ int32_t i0,i1,j0;
+ u_int32_t i;
+ EXTRACT_WORDS(i0,i1,x);
+ j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */
+ if(j0<20) { /* integer part in high x */
+ if(j0<0) { /* |x|<1 */
+ INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */
+ return x;
+ } else {
+ i = (0x000fffff)>>j0;
+ if(((i0&i)|i1)==0) { /* x is integral */
+ u_int32_t high;
+ *iptr = x;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else {
+ INSERT_WORDS(*iptr,i0&(~i),0);
+ return x - *iptr;
+ }
+ }
+ } else if (j0>51) { /* no fraction part */
+ u_int32_t high;
+ *iptr = x*one;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else { /* fraction part in low x */
+ i = ((u_int32_t)(0xffffffff))>>(j0-20);
+ if((i1&i)==0) { /* x is integral */
+ u_int32_t high;
+ *iptr = x;
+ GET_HIGH_WORD(high,x);
+ INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
+ return x;
+ } else {
+ INSERT_WORDS(*iptr,i0,i1&(~i));
+ return x - *iptr;
+ }
+ }
+}
diff --git a/lib/libc/arch/m88k/gen/setjmp.S b/lib/libc/arch/m88k/gen/setjmp.S
new file mode 100644
index 00000000000..9fc8988311d
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/setjmp.S
@@ -0,0 +1,61 @@
+#include "SYS.h"
+
+ENTRY(setjmp)
+ st r1, r2,0
+ st r14,r2,8
+ st r15,r2,12
+ st r16,r2,16
+ st r17,r2,20
+ st r18,r2,24
+ st r19,r2,28
+ st r20,r2,32
+ st r21,r2,36
+ st r22,r2,40
+ st r23,r2,44
+ st r24,r2,48
+ st r25,r2,52
+ st r26,r2,56
+ st r27,r2,60
+ st r28,r2,64
+ st r29,r2,68
+ st r30,r2,72
+ st r31,r2,76
+ or r15,r1,0 /* can use r15 */
+ or r14,r2,0 /* can use r14 as it is already saved */
+ bsr.n _sigblock
+ or r2,r0,0
+ st r2,r14,4
+ jmp.n r15
+ or r2,r0,0
+
+ENTRY(longjmp)
+ subu r31,r31,32 /* get some temporary stack */
+
+ ld r14,r2,8
+ ld r15,r2,12
+ ld r16,r2,16
+ ld r17,r2,20
+ ld r18,r2,24
+ ld r19,r2,28
+ ld r20,r2,32
+ ld r21,r2,36
+ ld r22,r2,40
+ ld r23,r2,44
+ ld r24,r2,48
+ ld r25,r2,52
+ ld r26,r2,56
+ ld r27,r2,60
+ ld r28,r2,64
+ ld r29,r2,68
+
+ st r2,r31,24 /* save r2 on stack */
+ st r3,r31,28 /* save r3 on stack */
+ bsr.n _sigsetmask
+ ld r2,r2,4
+ ld r2,r31,24 /* restore r2 from stack */
+ ld r3,r31,28 /* restore r3 from stack */
+ ld r30,r2,72 /* restore r30 */
+ ld r31,r2,76 /* restore r31 */
+ ld r1,r2,0 /* restore r1 */
+ jmp.n r1 /* and jump to it */
+ or r2,r0,r3 /* but first return r3 value */
diff --git a/lib/libc/arch/m88k/gen/sigsetjmp.S b/lib/libc/arch/m88k/gen/sigsetjmp.S
new file mode 100644
index 00000000000..44637c0c25a
--- /dev/null
+++ b/lib/libc/arch/m88k/gen/sigsetjmp.S
@@ -0,0 +1,64 @@
+#include "SYS.h"
+
+/*
+ * Need to write sigsetjmp version. But for now,
+ * I am copying setjmp XXX nivas
+ */
+ENTRY(sigsetjmp)
+ st r1, r2,0
+ st r14,r2,8
+ st r15,r2,12
+ st r16,r2,16
+ st r17,r2,20
+ st r18,r2,24
+ st r19,r2,28
+ st r20,r2,32
+ st r21,r2,36
+ st r22,r2,40
+ st r23,r2,44
+ st r24,r2,48
+ st r25,r2,52
+ st r26,r2,56
+ st r27,r2,60
+ st r28,r2,64
+ st r29,r2,68
+ st r30,r2,72
+ st r31,r2,76
+ or r15,r1,0 /* can use r15 */
+ or r14,r2,0 /* can use r14 as it is already saved */
+ bsr.n _sigblock
+ or r2,r0,0
+ st r2,r14,4
+ jmp.n r15
+ or r2,r0,0
+
+ENTRY(siglongjmp)
+ subu r31,r31,32 /* get some temporary stack */
+ ld r14,r2,8
+ ld r15,r2,12
+ ld r16,r2,16
+ ld r17,r2,20
+ ld r18,r2,24
+ ld r19,r2,28
+ ld r20,r2,32
+ ld r21,r2,36
+ ld r22,r2,40
+ ld r23,r2,44
+ ld r24,r2,48
+ ld r25,r2,52
+ ld r26,r2,56
+ ld r27,r2,60
+ ld r28,r2,64
+ ld r29,r2,68
+
+ st r2,r31,24 /* save r2 on stack */
+ st r3,r31,28 /* save r3 on stack */
+ bsr.n _sigsetmask
+ ld r2,r2,4
+ ld r2,r31,24 /* restore r2 from stack */
+ ld r3,r31,28 /* restore r3 from stack */
+ ld r30,r2,72 /* restore r30 */
+ ld r31,r2,76 /* restore r31 */
+ ld r1,r2,0 /* restore r1 */
+ jmp.n r1 /* and jump to it */
+ or r2,r0,r3 /* but first return r3 value */