summaryrefslogtreecommitdiffstats
path: root/lib/libc/alpha/gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/alpha/gen')
-rw-r--r--lib/libc/alpha/gen/Makefile.inc47
-rw-r--r--lib/libc/alpha/gen/_ctx_start.S49
-rw-r--r--lib/libc/alpha/gen/_setjmp.S128
-rw-r--r--lib/libc/alpha/gen/divrem.m4198
-rw-r--r--lib/libc/alpha/gen/fabs.S36
-rw-r--r--lib/libc/alpha/gen/flt_rounds.c59
-rw-r--r--lib/libc/alpha/gen/fpgetmask.c52
-rw-r--r--lib/libc/alpha/gen/fpgetround.c51
-rw-r--r--lib/libc/alpha/gen/fpgetsticky.c51
-rw-r--r--lib/libc/alpha/gen/fpsetmask.c54
-rw-r--r--lib/libc/alpha/gen/fpsetround.c58
-rw-r--r--lib/libc/alpha/gen/fpsetsticky.c58
-rw-r--r--lib/libc/alpha/gen/frexp.c56
-rw-r--r--lib/libc/alpha/gen/getcontext.S377
-rw-r--r--lib/libc/alpha/gen/infinity.c36
-rw-r--r--lib/libc/alpha/gen/isinf.c55
-rw-r--r--lib/libc/alpha/gen/ldexp.c137
-rw-r--r--lib/libc/alpha/gen/makecontext.c171
-rw-r--r--lib/libc/alpha/gen/modf.c107
-rw-r--r--lib/libc/alpha/gen/rfork_thread.S65
-rw-r--r--lib/libc/alpha/gen/setjmp.S129
-rw-r--r--lib/libc/alpha/gen/sigsetjmp.S65
22 files changed, 2039 insertions, 0 deletions
diff --git a/lib/libc/alpha/gen/Makefile.inc b/lib/libc/alpha/gen/Makefile.inc
new file mode 100644
index 0000000..32c80d8
--- /dev/null
+++ b/lib/libc/alpha/gen/Makefile.inc
@@ -0,0 +1,47 @@
+# $FreeBSD$
+
+SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.c setjmp.S
+SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+ fpsetround.c fpsetsticky.c
+
+SRCS+= sigsetjmp.S
+SRCS+= __divqu.S __divq.S __divlu.S __divl.S
+SRCS+= __remqu.S __remq.S __remlu.S __reml.S
+SRCS+= rfork_thread.S
+SRCS+= _ctx_start.S getcontext.S makecontext.c swapcontext.c
+
+CLEANFILES+= __divqu.S __divq.S __divlu.S __divl.S
+CLEANFILES+= __remqu.S __remq.S __remlu.S __reml.S
+
+
+__divqu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__divqu -DOP=div -DS=false -DWORDSIZE=64 \
+ ${.ALLSRC} > ${.TARGET}
+
+__divq.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__divq -DOP=div -DS=true -DWORDSIZE=64 \
+ ${.ALLSRC} > ${.TARGET}
+
+__divlu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__divlu -DOP=div -DS=false -DWORDSIZE=32 \
+ ${.ALLSRC} > ${.TARGET}
+
+__divl.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__divl -DOP=div -DS=true -DWORDSIZE=32 \
+ ${.ALLSRC} > ${.TARGET}
+
+__remqu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__remqu -DOP=rem -DS=false -DWORDSIZE=64 \
+ ${.ALLSRC} > ${.TARGET}
+
+__remq.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__remq -DOP=rem -DS=true -DWORDSIZE=64 \
+ ${.ALLSRC} > ${.TARGET}
+
+__remlu.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__remlu -DOP=rem -DS=false -DWORDSIZE=32 \
+ ${.ALLSRC} > ${.TARGET}
+
+__reml.S: ${.CURDIR}/../libc/alpha/gen/divrem.m4
+ m4 -DNAME=__reml -DOP=rem -DS=true -DWORDSIZE=32 \
+ ${.ALLSRC} > ${.TARGET}
diff --git a/lib/libc/alpha/gen/_ctx_start.S b/lib/libc/alpha/gen/_ctx_start.S
new file mode 100644
index 0000000..f17d1d5
--- /dev/null
+++ b/lib/libc/alpha/gen/_ctx_start.S
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>
+ * 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. Neither the name of the author 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+
+/*
+ * A0-A5 are the first 6 arguments to the start routine with the
+ * remaining arguments (if any) placed on the stack. S0 is the
+ * address of the user-supplied start routine, and S1 is the pointer
+ * to the ucontext.
+ */
+ .set noreorder
+LEAF(_ctx_start,0)
+ mov s0, t12
+ jsr ra, (s0) /* call start routine; args already set */
+ LDGP(ra)
+ mov s1, a0 /* load A0 (arg 1) with pointer to ucontext */
+ CALL(_ctx_done) /* call context completion routine */
+ CALL(abort) /* should never return from above call */
+ RET
+END(_ctx_start)
diff --git a/lib/libc/alpha/gen/_setjmp.S b/lib/libc/alpha/gen/_setjmp.S
new file mode 100644
index 0000000..22cba2a
--- /dev/null
+++ b/lib/libc/alpha/gen/_setjmp.S
@@ -0,0 +1,128 @@
+/* $NetBSD: _setjmp.S,v 1.2 1996/10/17 03:08:03 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+/*
+ * 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.
+ */
+
+ .set noreorder
+
+LEAF(_setjmp, 1)
+ LDGP(pv)
+ stq ra, (2 * 8)(a0) /* sc_pc = return address */
+ stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */
+ stq s1, ((10 + 4) * 8)(a0)
+ stq s2, ((11 + 4) * 8)(a0)
+ stq s3, ((12 + 4) * 8)(a0)
+ stq s4, ((13 + 4) * 8)(a0)
+ stq s5, ((14 + 4) * 8)(a0)
+ stq s6, ((15 + 4) * 8)(a0)
+ stq ra, ((26 + 4) * 8)(a0)
+ stq t12,((27 + 4) * 8)(a0)
+ stq sp, ((30 + 4) * 8)(a0)
+ ldiq t0, 0xacedbadd /* sigcontext magic number */
+ stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */
+ /* Too bad we can't check if we actually used FP */
+ ldiq t0, 1
+ stq t0, (36 * 8)(a0) /* say we've used FP. */
+ stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */
+ stt fs1, ((3 + 37) * 8)(a0)
+ stt fs2, ((4 + 37) * 8)(a0)
+ stt fs3, ((5 + 37) * 8)(a0)
+ stt fs4, ((6 + 37) * 8)(a0)
+ stt fs5, ((7 + 37) * 8)(a0)
+ stt fs6, ((8 + 37) * 8)(a0)
+ stt fs7, ((9 + 37) * 8)(a0)
+ mf_fpcr ft0 /* get FP control reg */
+ stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */
+ stq zero, (70 * 8)(a0) /* FP software control XXX */
+ stq zero, (71 * 8)(a0) /* sc_reserved[0] */
+ stq zero, (72 * 8)(a0) /* sc_reserved[1] */
+ stq zero, (73 * 8)(a0) /* sc_xxx[0] */
+ stq zero, (74 * 8)(a0) /* sc_xxx[1] */
+ stq zero, (75 * 8)(a0) /* sc_xxx[2] */
+ stq zero, (76 * 8)(a0) /* sc_xxx[3] */
+ stq zero, (77 * 8)(a0) /* sc_xxx[4] */
+ stq zero, (78 * 8)(a0) /* sc_xxx[5] */
+ stq zero, (79 * 8)(a0) /* sc_xxx[6] */
+ stq zero, (80 * 8)(a0) /* sc_xxx[7] */
+
+ mov zero, v0 /* return zero */
+ RET
+END(_setjmp)
+
+XLEAF(_longjmp, 2)
+LEAF(___longjmp, 2)
+ LDGP(pv)
+ ldq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */
+ ldiq t1, 0xacedbadd
+ cmpeq t0, t1, t0
+ beq t0, botch /* If the magic was bad, punt */
+
+ ldq ra, (2 * 8)(a0) /* sc_pc = return address */
+ ldq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */
+ ldq s1, ((10 + 4) * 8)(a0)
+ ldq s2, ((11 + 4) * 8)(a0)
+ ldq s3, ((12 + 4) * 8)(a0)
+ ldq s4, ((13 + 4) * 8)(a0)
+ ldq s5, ((14 + 4) * 8)(a0)
+ ldq s6, ((15 + 4) * 8)(a0)
+ /* ldq ra, ((26 + 4) * 8)(a0) set above */
+ ldq t12,((27 + 4) * 8)(a0)
+ ldq sp, ((30 + 4) * 8)(a0)
+ ldt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */
+ ldt fs1, ((3 + 37) * 8)(a0)
+ ldt fs2, ((4 + 37) * 8)(a0)
+ ldt fs3, ((5 + 37) * 8)(a0)
+ ldt fs4, ((6 + 37) * 8)(a0)
+ ldt fs5, ((7 + 37) * 8)(a0)
+ ldt fs6, ((8 + 37) * 8)(a0)
+ ldt fs7, ((9 + 37) * 8)(a0)
+ ldt ft0, (69 * 8)(a0) /* get sc_fpcr */
+ mt_fpcr ft0 /* and restore it. */
+
+ mov a1, v0 /* return second arg */
+ RET
+
+botch:
+ CALL(longjmperror)
+ CALL(abort)
+ RET /* "can't" get here... */
+END(___longjmp)
diff --git a/lib/libc/alpha/gen/divrem.m4 b/lib/libc/alpha/gen/divrem.m4
new file mode 100644
index 0000000..10406a6
--- /dev/null
+++ b/lib/libc/alpha/gen/divrem.m4
@@ -0,0 +1,198 @@
+/* $NetBSD: divrem.m4,v 1.7 1996/10/17 03:08:04 cgd Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+/*
+ * Division and remainder.
+ *
+ * The use of m4 is modeled after the sparc code, but the algorithm is
+ * simple binary long division.
+ *
+ * Note that the loops could probably benefit from unrolling.
+ */
+
+/*
+ * M4 Parameters
+ * NAME name of function to generate
+ * OP OP=div: t10 / t11 -> t12; OP=rem: t10 % t11 -> t12
+ * S S=true: signed; S=false: unsigned
+ * WORDSIZE total number of bits
+ */
+
+define(A, `t10')
+define(B, `t11')
+define(RESULT, `t12')
+
+define(BIT, `t0')
+define(I, `t1')
+define(CC, `t2')
+define(T_0, `t3')
+ifelse(S, `true', `define(NEG, `t4')')
+
+#include <machine/asm.h>
+
+NESTED(NAME, 0, 0, t9, 0, 0) /* Get the right ra */
+ lda sp, -64(sp)
+ stq BIT, 0(sp)
+ stq I, 8(sp)
+ stq CC, 16(sp)
+ stq T_0, 24(sp)
+ifelse(S, `true',
+` stq NEG, 32(sp)')
+ stq A, 40(sp)
+ stq B, 48(sp)
+ mov zero, RESULT /* Initialize result to zero */
+
+ifelse(S, `true',
+`
+ /* Compute sign of result. If either is negative, this is easy. */
+ or A, B, NEG /* not the sign, but... */
+ srl NEG, WORDSIZE - 1, NEG /* rather, or of high bits */
+ blbc NEG, Ldoit /* neither negative? do it! */
+
+ifelse(OP, `div',
+` xor A, B, NEG /* THIS is the sign! */
+', ` mov A, NEG /* sign follows A. */
+')
+ srl NEG, WORDSIZE - 1, NEG /* make negation the low bit. */
+
+ srl A, WORDSIZE - 1, I /* is A negative? */
+ blbc I, LnegB /* no. */
+ /* A is negative; flip it. */
+ifelse(WORDSIZE, `32', `
+ /* top 32 bits may be random junk */
+ zap A, 0xf0, A
+')
+ subq zero, A, A
+ srl B, WORDSIZE - 1, I /* is B negative? */
+ blbc I, Ldoit /* no. */
+LnegB:
+ /* B is definitely negative, no matter how we got here. */
+ifelse(WORDSIZE, `32', `
+ /* top 32 bits may be random junk */
+ zap B, 0xf0, B
+')
+ subq zero, B, B
+Ldoit:
+')
+ifelse(WORDSIZE, `32', `
+ /*
+ * Clear the top 32 bits of each operand, as they may
+ * sign extension (if negated above), or random junk.
+ */
+ zap A, 0xf0, A
+ zap B, 0xf0, B
+')
+
+ /* kill the special cases. */
+ beq B, Ldotrap /* division by zero! */
+
+ cmpult A, B, CC /* A < B? */
+ /* RESULT is already zero, from above. A is untouched. */
+ bne CC, Lret_result
+
+ cmpeq A, B, CC /* A == B? */
+ cmovne CC, 1, RESULT
+ cmovne CC, zero, A
+ bne CC, Lret_result
+
+ /*
+ * Find out how many bits of zeros are at the beginning of the divisor.
+ */
+LBbits:
+ ldiq T_0, 1 /* I = 0; BIT = 1<<WORDSIZE-1 */
+ mov zero, I
+ sll T_0, WORDSIZE-1, BIT
+LBloop:
+ and B, BIT, CC /* if bit in B is set, done. */
+ bne CC, LAbits
+ addq I, 1, I /* increment I, shift bit */
+ srl BIT, 1, BIT
+ cmplt I, WORDSIZE-1, CC /* if I leaves one bit, done. */
+ bne CC, LBloop
+
+LAbits:
+ beq I, Ldodiv /* If I = 0, divide now. */
+ ldiq T_0, 1 /* BIT = 1<<WORDSIZE-1 */
+ sll T_0, WORDSIZE-1, BIT
+
+LAloop:
+ and A, BIT, CC /* if bit in A is set, done. */
+ bne CC, Ldodiv
+ subq I, 1, I /* decrement I, shift bit */
+ srl BIT, 1, BIT
+ bne I, LAloop /* If I != 0, loop again */
+
+Ldodiv:
+ sll B, I, B /* B <<= i */
+ ldiq T_0, 1
+ sll T_0, I, BIT
+
+Ldivloop:
+ cmpult A, B, CC
+ or RESULT, BIT, T_0
+ cmoveq CC, T_0, RESULT
+ subq A, B, T_0
+ cmoveq CC, T_0, A
+ srl BIT, 1, BIT
+ srl B, 1, B
+ beq A, Lret_result
+ bne BIT, Ldivloop
+
+Lret_result:
+ifelse(OP, `div',
+`', ` mov A, RESULT
+')
+ifelse(S, `true',
+`
+ /* Check to see if we should negate it. */
+ subqv zero, RESULT, T_0
+ cmovlbs NEG, T_0, RESULT
+')
+
+ ldq BIT, 0(sp)
+ ldq I, 8(sp)
+ ldq CC, 16(sp)
+ ldq T_0, 24(sp)
+ifelse(S, `true',
+` ldq NEG, 32(sp)')
+ ldq A, 40(sp)
+ ldq B, 48(sp)
+ lda sp, 64(sp)
+ ret zero, (t9), 1
+
+Ldotrap:
+ ldiq a0, -2 /* This is the signal to SIGFPE! */
+ call_pal PAL_gentrap
+ifelse(OP, `div',
+`', ` mov zero, A /* so that zero will be returned */
+')
+ br zero, Lret_result
+
+END(NAME)
diff --git a/lib/libc/alpha/gen/fabs.S b/lib/libc/alpha/gen/fabs.S
new file mode 100644
index 0000000..4305cce
--- /dev/null
+++ b/lib/libc/alpha/gen/fabs.S
@@ -0,0 +1,36 @@
+/* $NetBSD: fabs.S,v 1.2 1996/10/17 03:08:05 cgd Exp $ */
+/* $FreeBSD$ */
+
+/*
+ * 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.
+ */
+
+#include <machine/asm.h>
+
+LEAF(fabs, 1)
+ cpys fzero, fa0, fv0
+ RET
+END(fabs)
diff --git a/lib/libc/alpha/gen/flt_rounds.c b/lib/libc/alpha/gen/flt_rounds.c
new file mode 100644
index 0000000..a5181e3
--- /dev/null
+++ b/lib/libc/alpha/gen/flt_rounds.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: flt_rounds.c,v 1.2 1997/07/18 00:30:30 thorpej Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/float.h>
+
+static const int map[] = {
+ 0, /* round to zero */
+ 3, /* round to negative infinity */
+ 1, /* round to nearest */
+ 2 /* round to positive infinity */
+};
+
+int
+__flt_rounds()
+{
+ double fpcrval;
+ u_int64_t old;
+
+ __asm__("trapb");
+ __asm__("mf_fpcr %0" : "=f" (fpcrval));
+ __asm__("trapb");
+ old = *(u_int64_t *)&fpcrval;
+
+ return map[(old >> 58) & 0x3];
+}
diff --git a/lib/libc/alpha/gen/fpgetmask.c b/lib/libc/alpha/gen/fpgetmask.c
new file mode 100644
index 0000000..5fbb13f
--- /dev/null
+++ b/lib/libc/alpha/gen/fpgetmask.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: fpgetmask.c,v 1.1 1995/04/29 05:10:55 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <ieeefp.h>
+#include <machine/sysarch.h>
+
+struct params {
+ u_int64_t mask;
+};
+
+fp_except_t
+fpgetmask()
+{
+ struct params p;
+
+ sysarch(ALPHA_GET_FPMASK, (char *) &p);
+ return((fp_except_t) p.mask);
+}
diff --git a/lib/libc/alpha/gen/fpgetround.c b/lib/libc/alpha/gen/fpgetround.c
new file mode 100644
index 0000000..70de648
--- /dev/null
+++ b/lib/libc/alpha/gen/fpgetround.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: fpgetround.c,v 1.1 1995/04/29 05:09:55 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <ieeefp.h>
+#include <machine/fpu.h>
+
+fp_rnd_t
+fpgetround()
+{
+ double fpcrval;
+ u_int64_t old;
+
+ GET_FPCR(fpcrval);
+ old = *(u_int64_t *)&fpcrval;
+
+ return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
+}
diff --git a/lib/libc/alpha/gen/fpgetsticky.c b/lib/libc/alpha/gen/fpgetsticky.c
new file mode 100644
index 0000000..2cca07d
--- /dev/null
+++ b/lib/libc/alpha/gen/fpgetsticky.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: fpgetsticky.c,v 1.1 1995/04/29 05:10:59 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <ieeefp.h>
+#include <machine/fpu.h>
+
+fp_except_t
+fpgetsticky()
+{
+ double fpcrval;
+ u_int64_t old;
+
+ GET_FPCR(fpcrval);
+ old = *(u_int64_t *)&fpcrval;
+ return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
+ >> IEEE_STATUS_TO_EXCSUM_SHIFT);
+}
diff --git a/lib/libc/alpha/gen/fpsetmask.c b/lib/libc/alpha/gen/fpsetmask.c
new file mode 100644
index 0000000..28675b5
--- /dev/null
+++ b/lib/libc/alpha/gen/fpsetmask.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: fpsetmask.c,v 1.1 1995/04/29 05:11:01 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <ieeefp.h>
+#include <machine/sysarch.h>
+
+struct params {
+ u_int64_t mask;
+};
+
+fp_except_t
+fpsetmask(mask)
+ fp_except_t mask;
+{
+ struct params p;
+
+ p.mask = (u_int64_t) mask;
+ sysarch(ALPHA_SET_FPMASK, (char *) &p);
+ return ((fp_except_t) p.mask);
+}
diff --git a/lib/libc/alpha/gen/fpsetround.c b/lib/libc/alpha/gen/fpsetround.c
new file mode 100644
index 0000000..627aca96
--- /dev/null
+++ b/lib/libc/alpha/gen/fpsetround.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: fpsetround.c,v 1.1 1995/04/29 05:09:57 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <ieeefp.h>
+#include <machine/fpu.h>
+
+fp_rnd_t
+fpsetround(rnd_dir)
+ fp_rnd_t rnd_dir;
+{
+ double fpcrval;
+ u_int64_t old, new;
+
+ GET_FPCR(fpcrval);
+ old = *(u_int64_t *)&fpcrval;
+
+ new = old & (~FPCR_DYN_MASK);
+ new |= ((long) rnd_dir << FPCR_DYN_SHIFT) & FPCR_DYN_MASK;
+
+ *(u_int64_t *)&fpcrval = new;
+ SET_FPCR(fpcrval);
+
+ return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
+}
diff --git a/lib/libc/alpha/gen/fpsetsticky.c b/lib/libc/alpha/gen/fpsetsticky.c
new file mode 100644
index 0000000..02af77a
--- /dev/null
+++ b/lib/libc/alpha/gen/fpsetsticky.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1995 Christopher G. Demetriou
+ * 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 Christopher G. Demetriou
+ * for the NetBSD Project.
+ * 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.
+ *
+ * $NetBSD: fpsetsticky.c,v 1.1 1995/04/29 05:11:04 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <ieeefp.h>
+#include <machine/fpu.h>
+
+fp_except_t
+fpsetsticky(sticky)
+ fp_except_t sticky;
+{
+ double fpcrval;
+ u_int64_t old,new ;
+
+ GET_FPCR(fpcrval);
+ old = *(u_int64_t *)&fpcrval;
+ new = old & ~ (IEEE_STATUS_MASK << IEEE_STATUS_TO_FPCR_SHIFT);
+ new |= ((sticky << IEEE_STATUS_TO_EXCSUM_SHIFT) & IEEE_STATUS_MASK)
+ << IEEE_STATUS_TO_FPCR_SHIFT;
+ *(u_int64_t *)&fpcrval = new;
+ SET_FPCR(fpcrval);
+
+ return (((old >> IEEE_STATUS_TO_FPCR_SHIFT) & IEEE_STATUS_MASK)
+ >> IEEE_STATUS_TO_EXCSUM_SHIFT);
+}
diff --git a/lib/libc/alpha/gen/frexp.c b/lib/libc/alpha/gen/frexp.c
new file mode 100644
index 0000000..386c36b
--- /dev/null
+++ b/lib/libc/alpha/gen/frexp.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: frexp.c,v 1.1 1995/02/10 17:50:22 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <math.h>
+
+double
+frexp(value, eptr)
+ double value;
+ int *eptr;
+{
+ union doub {
+ double v;
+ struct ieee_double s;
+ } u;
+
+ if (value) {
+ u.v = value;
+ *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/alpha/gen/getcontext.S b/lib/libc/alpha/gen/getcontext.S
new file mode 100644
index 0000000..92a15fd
--- /dev/null
+++ b/lib/libc/alpha/gen/getcontext.S
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 2001 Daniel Eischen <deischen@freebsd.org>
+ * 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. Neither the name of the author 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ * Copyright (c) 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.
+ *
+ */
+
+/*
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+/* #include <machine/frame.h> */
+#define FRAME_V0 0
+#define FRAME_T0 1
+#define FRAME_T1 2
+#define FRAME_T2 3
+#define FRAME_T3 4
+#define FRAME_T4 5
+#define FRAME_T5 6
+#define FRAME_T6 7
+#define FRAME_T7 8
+#define FRAME_S0 9
+#define FRAME_S1 10
+#define FRAME_S2 11
+#define FRAME_S3 12
+#define FRAME_S4 13
+#define FRAME_S5 14
+#define FRAME_S6 15
+#define FRAME_A3 16
+#define FRAME_A4 17
+#define FRAME_A5 18
+#define FRAME_RA 23
+#define FRAME_T12 24
+#define FRAME_AT 25
+#define FRAME_SP 26
+#define FRAME_TRAPARG_A0 28
+#define FRAME_TRAPARG_A1 29
+#define FRAME_TRAPARG_A2 30
+#define FRAME_PC (FRAME_TRAPARG_A2 + 1 + 1)
+
+/* #include <machine/reg.h> */
+#define R_V0 0
+#define R_T0 1
+#define R_T1 2
+#define R_T2 3
+#define R_T3 4
+#define R_T4 5
+#define R_T5 6
+#define R_T6 7
+#define R_T7 8
+#define R_S0 9
+#define R_S1 10
+#define R_S2 11
+#define R_S3 12
+#define R_S4 13
+#define R_S5 14
+#define R_S6 15
+#define R_A0 16
+#define R_A1 17
+#define R_A2 18
+#define R_A3 19
+#define R_A4 20
+#define R_A5 21
+#define R_T8 22
+#define R_T9 23
+#define R_T10 24
+#define R_T11 25
+#define R_RA 26
+#define R_T12 27
+#define R_SP 30
+#define R_ZERO 31
+
+/*
+ * XXX - The rev id's are defined in <machine/ucontext.h>
+ */
+#define UC_FMT_OFFSET 73*8 + 4*4 /* offset to format from ucontext */
+#define REV0_SIGFRAME 0x0001 /* rev R0 sigcontext format */
+#define REV0_TRAPFRAME 0x0002 /* rev R0 trapframe format */
+
+/*
+ * int setcontext(const ucontext_t *);
+ *
+ * The format of the context is verified at the beginning.
+ * Returns -1 if invalid format or sigprocmask fails.
+ */
+ .set noreorder
+XLEAF(setcontext, 1)
+LEAF(__setcontext, 1)
+ LDGP(pv)
+ bne a0, Lsc1 /* argument null? */
+Lscbad: ldiq v0, -1 /* return -1 */
+ br Lscend
+Lsc1: ldl t1, UC_FMT_OFFSET(a0) /* is mcontext valid format? */
+ ldil t0, REV0_TRAPFRAME
+ cmpeq t0, t1, t0 /* is it trapframe format? */
+ bne t0, Lsc_sm /* if so, get signal mask */
+ ldil t0, REV0_SIGFRAME
+ cmpeq t0, t1, t0 /* is it sigcontext format? */
+ beq t0, Lscbad
+ /* supposedly sigcontext format, check magic number */
+ ldiq t0, 0xACEDBADE /* check magic number */
+ ldq t1, ((R_ZERO + 3) * 8)(a0) /* magic in mc_regs[R_ZERO] */
+ cmpeq t0, t1, t0
+ beq t0, Lscbad
+ /*
+ * set current signal mask
+ */
+Lsc_sm: lda sp, -16(sp) /* save some space on stack */
+ stq ra, 0(sp) /* save ra */
+ stq a0, 8(sp) /* save ptr to ucontext */
+ mov a0, a1 /* set: &ucp->uc_sigmask */
+ mov zero, a2 /* oset: NULL */
+ ldiq a0, 3 /* how: SIG_SETMASK */
+ CALL(_sigprocmask) /* set new signal mask */
+ ldq a0, 8(sp) /* restore ptr to ucontext */
+ ldq ra, 0(sp) /* restore ra */
+ lda sp, 16(sp) /* restore stack */
+ bne v0, Lscbad /* check for error */
+ /* restore floating point regs first */
+ ldq t0, ((71 + 3) * 8)(a0) /* if FP regs not saved, */
+ beq t0, Lsc2 /* skip setting FP regs */
+ ldt $f0, ((37 + 3) * 8)(a0) /* restore FP regs using */
+ ldt $f1, ((38 + 3) * 8)(a0) /* hw name */
+ ldt $f2, ((39 + 3) * 8)(a0)
+ ldt $f3, ((40 + 3) * 8)(a0)
+ ldt $f4, ((41 + 3) * 8)(a0)
+ ldt $f5, ((42 + 3) * 8)(a0)
+ ldt $f6, ((43 + 3) * 8)(a0)
+ ldt $f7, ((44 + 3) * 8)(a0)
+ ldt $f8, ((45 + 3) * 8)(a0)
+ ldt $f9, ((46 + 3) * 8)(a0)
+ ldt $f10, ((47 + 3) * 8)(a0)
+ ldt $f11, ((48 + 3) * 8)(a0)
+ ldt $f12, ((49 + 3) * 8)(a0)
+ ldt $f13, ((50 + 3) * 8)(a0)
+ ldt $f14, ((51 + 3) * 8)(a0)
+ ldt $f15, ((52 + 3) * 8)(a0)
+ ldt $f16, ((53 + 3) * 8)(a0)
+ ldt $f17, ((54 + 3) * 8)(a0)
+ ldt $f18, ((55 + 3) * 8)(a0)
+ ldt $f19, ((56 + 3) * 8)(a0)
+ ldt $f20, ((57 + 3) * 8)(a0)
+ ldt $f21, ((58 + 3) * 8)(a0)
+ ldt $f22, ((59 + 3) * 8)(a0)
+ ldt $f23, ((60 + 3) * 8)(a0)
+ ldt $f24, ((61 + 3) * 8)(a0)
+ ldt $f25, ((62 + 3) * 8)(a0)
+ ldt $f26, ((63 + 3) * 8)(a0)
+ ldt $f27, ((64 + 3) * 8)(a0)
+ .set noat
+ ldt $f28, ((65 + 3) * 8)(a0)
+ .set at
+ ldt $f29, ((66 + 3) * 8)(a0)
+ ldt $f30, ((67 + 3) * 8)(a0)
+ /* $f31 is hardwired zero */
+ ldt ft0, ((69 + 3) * 8)(a0) /* restore FP control reg */
+ mt_fpcr ft0
+Lsc2: ldil t0, REV0_SIGFRAME /* check the context format */
+ ldl t1, UC_FMT_OFFSET(a0) /* again. */
+ cmpeq t0, t1, t0 /* is it sigcontext format? */
+ bne t0, Lsc_sc
+ /* trapframe format */
+ ldq v0, ((FRAME_V0 + 3) * 8)(a0) /* set v0 */
+ ldq t0, ((FRAME_T0 + 3) * 8)(a0) /* set t0-t7 */
+ ldq t1, ((FRAME_T1 + 3) * 8)(a0)
+ ldq t2, ((FRAME_T2 + 3) * 8)(a0)
+ ldq t3, ((FRAME_T3 + 3) * 8)(a0)
+ ldq t4, ((FRAME_T4 + 3) * 8)(a0)
+ ldq t5, ((FRAME_T5 + 3) * 8)(a0)
+ ldq t6, ((FRAME_T6 + 3) * 8)(a0)
+ ldq t7, ((FRAME_T7 + 3) * 8)(a0)
+ ldq s0, ((FRAME_S0 + 3) * 8)(a0) /* set s0-s6 */
+ ldq s1, ((FRAME_S1 + 3) * 8)(a0)
+ ldq s2, ((FRAME_S2 + 3) * 8)(a0)
+ ldq s3, ((FRAME_S3 + 3) * 8)(a0)
+ ldq s4, ((FRAME_S4 + 3) * 8)(a0)
+ ldq s5, ((FRAME_S5 + 3) * 8)(a0)
+ ldq s6, ((FRAME_S6 + 3) * 8)(a0)
+ ldq a1, ((FRAME_TRAPARG_A1 + 3) * 8)(a0) /* set a1-a5 */
+ ldq a2, ((FRAME_TRAPARG_A2 + 3) * 8)(a0)
+ ldq a3, ((FRAME_A3 + 3) * 8)(a0)
+ ldq a4, ((FRAME_A4 + 3) * 8)(a0)
+ ldq a5, ((FRAME_A5 + 3) * 8)(a0)
+ ldq ra, ((FRAME_RA + 3) * 8)(a0)
+ ldq sp, ((FRAME_SP + 3) * 8)(a0)
+ .set noat
+ ldq at_reg, ((FRAME_PC + 3) * 8)(a0) /* PC at time of trap? */
+ .set at
+ ldq a0, ((FRAME_TRAPARG_A0 + 3) * 8)(a0) /* restore a0 last */
+ br Lscend /* return to PC or RA? */
+Lsc_sc: /* sigcontext format */
+ ldq v0, ((R_V0 + 3) * 8)(a0) /* set v0 */
+ ldq t0, ((R_T0 + 3) * 8)(a0) /* set t0-t7 */
+ ldq t1, ((R_T1 + 3) * 8)(a0)
+ ldq t2, ((R_T2 + 3) * 8)(a0)
+ ldq t3, ((R_T3 + 3) * 8)(a0)
+ ldq t4, ((R_T4 + 3) * 8)(a0)
+ ldq t5, ((R_T5 + 3) * 8)(a0)
+ ldq t6, ((R_T6 + 3) * 8)(a0)
+ ldq t7, ((R_T7 + 3) * 8)(a0)
+ ldq s0, ((R_S0 + 3) * 8)(a0) /* set s0-s6 */
+ ldq s1, ((R_S1 + 3) * 8)(a0)
+ ldq s2, ((R_S2 + 3) * 8)(a0)
+ ldq s3, ((R_S3 + 3) * 8)(a0)
+ ldq s4, ((R_S4 + 3) * 8)(a0)
+ ldq s5, ((R_S5 + 3) * 8)(a0)
+ ldq s6, ((R_S6 + 3) * 8)(a0)
+ ldq a1, ((R_A1 + 3) * 8)(a0) /* set a1-a5 */
+ ldq a2, ((R_A2 + 3) * 8)(a0)
+ ldq a3, ((R_A3 + 3) * 8)(a0)
+ ldq a4, ((R_A4 + 3) * 8)(a0)
+ ldq a5, ((R_A5 + 3) * 8)(a0)
+ ldq ra, ((R_RA + 3) * 8)(a0)
+ ldq sp, ((R_SP + 3) * 8)(a0)
+ ldq a0, ((R_A0 + 3) * 8)(a0) /* restore a0 last */
+Lscend: RET
+END(__setcontext)
+
+
+/*
+ * int getcontext(ucontext_t *ucp);
+ *
+ * Always save in trapframe format. Floating point registers are
+ * saved but may be optimized away later (see comments below).
+ */
+XLEAF(getcontext, 1)
+LEAF(__getcontext, 1)
+ LDGP(pv)
+ bne a0, Lgc1 /* argument null? */
+ ldiq v0, -1 /* return -1 */
+ br Lgcend
+Lgc1: ldiq v0, 0 /* {gs}etcontext returns 0, */
+ stq v0, ((FRAME_V0 + 3) * 8)(a0) /* so save 0 in v0 */
+ stq t0, ((FRAME_T0 + 3) * 8)(a0) /* save t0-t7 */
+ stq t1, ((FRAME_T1 + 3) * 8)(a0)
+ stq t2, ((FRAME_T2 + 3) * 8)(a0)
+ stq t3, ((FRAME_T3 + 3) * 8)(a0)
+ stq t4, ((FRAME_T4 + 3) * 8)(a0)
+ stq t5, ((FRAME_T5 + 3) * 8)(a0)
+ stq t6, ((FRAME_T6 + 3) * 8)(a0)
+ stq t7, ((FRAME_T7 + 3) * 8)(a0)
+ stq s0, ((FRAME_S0 + 3) * 8)(a0) /* save s0-s6 */
+ stq s1, ((FRAME_S1 + 3) * 8)(a0)
+ stq s2, ((FRAME_S2 + 3) * 8)(a0)
+ stq s3, ((FRAME_S3 + 3) * 8)(a0)
+ stq s4, ((FRAME_S4 + 3) * 8)(a0)
+ stq s5, ((FRAME_S5 + 3) * 8)(a0)
+ stq s6, ((FRAME_S6 + 3) * 8)(a0)
+ stq a0, ((FRAME_TRAPARG_A0 + 3) * 8)(a0) /* save a0-a5 */
+ stq a1, ((FRAME_TRAPARG_A1 + 3) * 8)(a0)
+ stq a2, ((FRAME_TRAPARG_A2 + 3) * 8)(a0)
+ stq a3, ((FRAME_A3 + 3) * 8)(a0)
+ stq a4, ((FRAME_A4 + 3) * 8)(a0)
+ stq a5, ((FRAME_A5 + 3) * 8)(a0)
+ stq ra, ((FRAME_RA + 3) * 8)(a0)
+ stq sp, ((FRAME_SP + 3) * 8)(a0)
+ ldiq t0, REV0_TRAPFRAME /* store trapframe format in */
+ stq t0, UC_FMT_OFFSET(a0) /* ucp->uc-rev */
+ /*
+ * get current signal mask
+ *
+ * XXX - Since a1 is destroyed, does it need to be saved and restored?
+ */
+ mov a0, s0 /* save ptr to ucontext */
+ mov a0, a2 /* oset: &ucp->uc_sigmask */
+ mov zero, a1 /* set: NULL */
+ ldiq a0, 3 /* how: SIG_SETMASK */
+ CALL(_sigprocmask) /* see what's blocked */
+ mov s0, a0 /* restore ptr to ucontext */
+ ldq ra, ((FRAME_RA + 3) * 8)(a0) /* restore ra */
+ ldq s0, ((FRAME_S0 + 3) * 8)(a0) /* restore s0 */
+ beq v0, Lgc2 /* check for error */
+ ldiq v0, -1 /* return -1 */
+ br Lgcend
+Lgc2:
+ /*
+ * XXX - Do we really need to save floating point registers?
+ *
+ * This is an explicit call to get the current context, so
+ * shouldn't the caller be done with the floating point registers?
+ * Contexts formed by involuntary switches, such as signal delivery,
+ * should have floating point registers saved by the kernel.
+ */
+#if 1
+ stq zero, ((71 + 3) * 8)(a0) /* FP regs are not saved */
+#else
+ ldiq t0, 1 /* say we've used FP, */
+ stq t0, ((71 + 3) * 8)(a0) /* mc_ownedfp = 1 */
+ stt $f0, ((37 + 3) * 8)(a0) /* save first register, using */
+ stt $f1, ((38 + 3) * 8)(a0) /* hw name etc. */
+ stt $f2, ((39 + 3) * 8)(a0)
+ stt $f3, ((40 + 3) * 8)(a0)
+ stt $f4, ((41 + 3) * 8)(a0)
+ stt $f5, ((42 + 3) * 8)(a0)
+ stt $f6, ((43 + 3) * 8)(a0)
+ stt $f7, ((44 + 3) * 8)(a0)
+ stt $f8, ((45 + 3) * 8)(a0)
+ stt $f9, ((46 + 3) * 8)(a0)
+ stt $f10, ((47 + 3) * 8)(a0)
+ stt $f11, ((48 + 3) * 8)(a0)
+ stt $f12, ((49 + 3) * 8)(a0)
+ stt $f13, ((50 + 3) * 8)(a0)
+ stt $f14, ((51 + 3) * 8)(a0)
+ stt $f15, ((52 + 3) * 8)(a0)
+ stt $f16, ((53 + 3) * 8)(a0)
+ stt $f17, ((54 + 3) * 8)(a0)
+ stt $f18, ((55 + 3) * 8)(a0)
+ stt $f19, ((56 + 3) * 8)(a0)
+ stt $f20, ((57 + 3) * 8)(a0)
+ stt $f21, ((58 + 3) * 8)(a0)
+ stt $f22, ((59 + 3) * 8)(a0)
+ stt $f23, ((60 + 3) * 8)(a0)
+ stt $f24, ((61 + 3) * 8)(a0)
+ stt $f25, ((62 + 3) * 8)(a0)
+ stt $f26, ((63 + 3) * 8)(a0)
+ stt $f27, ((64 + 3) * 8)(a0)
+ .set noat
+ stt $f28, ((65 + 3) * 8)(a0)
+ .set at
+ stt $f29, ((66 + 3) * 8)(a0)
+ stt $f30, ((67 + 3) * 8)(a0)
+ /* $f31 is hardwired zero */
+#endif
+ mf_fpcr ft0 /* get FP control reg */
+ stt ft0, ((69 + 3) * 8)(a0) /* and store it in mc_fpcr */
+ stq zero, ((70 + 3) * 8)(a0) /* FP software control XXX */
+ mov zero, v0 /* return zero */
+Lgcend: RET
+END(__getcontext)
diff --git a/lib/libc/alpha/gen/infinity.c b/lib/libc/alpha/gen/infinity.c
new file mode 100644
index 0000000..7cb5b80
--- /dev/null
+++ b/lib/libc/alpha/gen/infinity.c
@@ -0,0 +1,36 @@
+/*
+ * 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: infinity.c,v 1.1 1995/02/10 17:50:23 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <math.h>
+
+/* bytes for +Infinity on an Alpha (IEEE double format) */
+char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
diff --git a/lib/libc/alpha/gen/isinf.c b/lib/libc/alpha/gen/isinf.c
new file mode 100644
index 0000000..663154c
--- /dev/null
+++ b/lib/libc/alpha/gen/isinf.c
@@ -0,0 +1,55 @@
+/*
+ * 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 $
+ */
+
+#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/alpha/gen/ldexp.c b/lib/libc/alpha/gen/ldexp.c
new file mode 100644
index 0000000..78decbb
--- /dev/null
+++ b/lib/libc/alpha/gen/ldexp.c
@@ -0,0 +1,137 @@
+/*
+ * 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: ldexp.c,v 1.1 1995/02/10 17:50:24 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <errno.h>
+#include <math.h>
+
+/*
+ * double ldexp(double val, int exp)
+ * returns: val * (2**exp)
+ */
+double
+ldexp(val, exp)
+ double val;
+ int exp;
+{
+ 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/alpha/gen/makecontext.c b/lib/libc/alpha/gen/makecontext.c
new file mode 100644
index 0000000..fa9856d
--- /dev/null
+++ b/lib/libc/alpha/gen/makecontext.c
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2001 Daniel M. Eischen <deischen@freebsd.org>
+ * 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. Neither the name of the author 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 AUTHOR 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 AUTHOR 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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/signal.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <ucontext.h>
+#include <unistd.h>
+
+
+/* Prototypes */
+extern void _ctx_start(int argc, ...);
+
+
+__weak_reference(__makecontext, makecontext);
+
+void
+_ctx_done (ucontext_t *ucp)
+{
+ if (ucp->uc_link == NULL)
+ exit(0);
+ else {
+ /*
+ * Since this context has finished, don't allow it
+ * to be restarted without being reinitialized (via
+ * setcontext or swapcontext).
+ */
+ ucp->uc_mcontext.mc_format = 0;
+
+ /* Set context to next one in link */
+ /* XXX - what to do for error, abort? */
+ setcontext((const ucontext_t *)ucp->uc_link);
+ abort(); /* should never get here */
+ }
+}
+
+void
+__makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
+{
+ va_list ap;
+ char *stack_top;
+ intptr_t *argp;
+ int i;
+
+ if (ucp == NULL)
+ return;
+ else if ((ucp->uc_stack.ss_sp == NULL) ||
+ (ucp->uc_stack.ss_size < MINSIGSTKSZ)) {
+ /*
+ * This should really return -1 with errno set to ENOMEM
+ * or something, but the spec says that makecontext is
+ * a void function. At least make sure that the context
+ * isn't valid so it can't be used without an error.
+ */
+ ucp->uc_mcontext.mc_format = 0;
+ }
+ /* XXX - Do we want to sanity check argc? */
+ else if ((argc < 0) || (argc > NCARGS)) {
+ ucp->uc_mcontext.mc_format = 0;
+ }
+ /*
+ * Make sure the context is valid. For now, we only allow
+ * trapframe format contexts to be used for makecontext.
+ */
+ else if (ucp->uc_mcontext.mc_format == __UC_REV0_SIGFRAME) {
+ /*
+ * Alpha passes the first 6 parameters in registers and
+ * remaining parameters on the stack. Set up the context
+ * accordingly, with the user start routine in register
+ * S0, and the context start wrapper (_ctx_start) in the
+ * program counter and return address. The context must
+ * be in trapframe format.
+ *
+ * Note: The context start wrapper needs to retrieve the
+ * ucontext pointer. Place this in register S1
+ * which must be saved by the callee.
+ */
+ stack_top = (char *)(ucp->uc_stack.ss_sp +
+ ucp->uc_stack.ss_size - sizeof(double));
+ stack_top = (char *)ALIGN(stack_top);
+
+ /*
+ * Adjust top of stack to allow for any additional integer
+ * arguments beyond 6.
+ */
+ if (argc > 6)
+ stack_top = stack_top - (sizeof(intptr_t) * (argc - 6));
+
+ argp = (intptr_t *)stack_top;
+
+ va_start(ap, argc);
+ for (i = 0; i < argc; i++) {
+ switch (i) {
+ case 0: ucp->uc_mcontext.mc_regs[FRAME_TRAPARG_A0] =
+ (unsigned long)va_arg(ap, intptr_t);
+ break;
+
+ case 1: ucp->uc_mcontext.mc_regs[FRAME_TRAPARG_A1] =
+ (unsigned long)va_arg(ap, intptr_t);
+ break;
+
+ case 2: ucp->uc_mcontext.mc_regs[FRAME_TRAPARG_A2] =
+ (unsigned long)va_arg(ap, intptr_t);
+ break;
+
+ case 3: ucp->uc_mcontext.mc_regs[FRAME_A3] =
+ (unsigned long)va_arg(ap, intptr_t);
+ break;
+
+ case 4: ucp->uc_mcontext.mc_regs[FRAME_A4] =
+ (unsigned long)va_arg(ap, intptr_t);
+ break;
+
+ case 5: ucp->uc_mcontext.mc_regs[FRAME_A5] =
+ (unsigned long)va_arg(ap, intptr_t);
+ break;
+
+ default:
+ *argp = va_arg(ap, intptr_t);
+ argp++;
+ break;
+ }
+ }
+ va_end(ap);
+
+ /*
+ * The start routine and ucontext are placed in registers
+ * S0 and S1 respectively.
+ */
+ ucp->uc_mcontext.mc_regs[FRAME_S0] = (unsigned long)start;
+ ucp->uc_mcontext.mc_regs[FRAME_S1] = (unsigned long)ucp;
+
+ /*
+ * Set the machine context to point to the top of the stack,
+ * and the program counter and return address to the context
+ * start wrapper.
+ */
+ ucp->uc_mcontext.mc_regs[FRAME_SP] = (unsigned long)stack_top;
+ ucp->uc_mcontext.mc_regs[FRAME_PC] = (unsigned long)_ctx_start;
+ ucp->uc_mcontext.mc_regs[FRAME_RA] = (unsigned long)_ctx_start;
+ ucp->uc_mcontext.mc_regs[FRAME_T12] = (unsigned long)_ctx_start;
+ }
+}
diff --git a/lib/libc/alpha/gen/modf.c b/lib/libc/alpha/gen/modf.c
new file mode 100644
index 0000000..37786dc
--- /dev/null
+++ b/lib/libc/alpha/gen/modf.c
@@ -0,0 +1,107 @@
+/*
+ * 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: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <machine/ieee.h>
+#include <errno.h>
+#include <math.h>
+
+/*
+ * double modf(double val, double *iptr)
+ * returns: f and i such that |f| < 1.0, (f + i) = val, and
+ * sign(f) == sign(i) == sign(val).
+ *
+ * Beware signedness when doing subtraction, and also operand size!
+ */
+double
+modf(val, iptr)
+ double val, *iptr;
+{
+ union doub {
+ double v;
+ struct ieee_double s;
+ } u, v;
+ u_int64_t frac;
+
+ /*
+ * If input is Inf or NaN, return it and leave i alone.
+ */
+ u.v = val;
+ if (u.s.dbl_exp == DBL_EXP_INFNAN)
+ return (u.v);
+
+ /*
+ * If input can't have a fractional part, return
+ * (appropriately signed) zero, and make i be the input.
+ */
+ if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
+ *iptr = u.v;
+ v.v = 0.0;
+ v.s.dbl_sign = u.s.dbl_sign;
+ return (v.v);
+ }
+
+ /*
+ * If |input| < 1.0, return it, and set i to the appropriately
+ * signed zero.
+ */
+ if (u.s.dbl_exp < DBL_EXP_BIAS) {
+ v.v = 0.0;
+ v.s.dbl_sign = u.s.dbl_sign;
+ *iptr = v.v;
+ return (u.v);
+ }
+
+ /*
+ * There can be a fractional part of the input.
+ * If you look at the math involved for a few seconds, it's
+ * plain to see that the integral part is the input, with the
+ * low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
+ * the the fractional part is the part with the rest of the
+ * bits zeroed. Just zeroing the high bits to get the
+ * fractional part would yield a fraction in need of
+ * normalization. Therefore, we take the easy way out, and
+ * just use subtraction to get the fractional part.
+ */
+ v.v = u.v;
+ /* Zero the low bits of the fraction, the sleazy way. */
+ frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
+ frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
+ frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
+ v.s.dbl_fracl = frac & 0xffffffff;
+ v.s.dbl_frach = frac >> 32;
+ *iptr = v.v;
+
+ u.v -= v.v;
+ u.s.dbl_sign = v.s.dbl_sign;
+ return (u.v);
+}
diff --git a/lib/libc/alpha/gen/rfork_thread.S b/lib/libc/alpha/gen/rfork_thread.S
new file mode 100644
index 0000000..ff0ed2c
--- /dev/null
+++ b/lib/libc/alpha/gen/rfork_thread.S
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include "SYS.h"
+#include <sys/syscall.h>
+/* #include <machine/pal.h> */
+
+/*
+ * This is pretty evil and based mostly on examples from other syscall
+ * stubs and code that gcc generated. Correctness is uncertain, but it
+ * seems to work quite happily.
+ */
+LEAF(rfork_thread, 1)
+ br gp,L1 /* XXX profiling */
+L1:
+ LDGP(pv)
+ lda sp,-16(sp)
+ stq ra,0(sp)
+ mov a3,a5
+ CALLSYS_ERROR(rfork)
+ beq v0,$child
+ addl v0,zero,v0
+ ldq ra,0(sp)
+ lda sp,16(sp)
+ RET
+$child:
+ mov a1,sp
+ lda sp,-16(sp)
+ stq zero,0(sp)
+ mov a5,a0
+ mov a2,t12
+ jsr ra,(t12),0
+ ldgp gp,0(ra)
+ mov v0,a0
+#ifdef SYS_exit
+ CALLSYS_NOERROR(exit)
+#else
+ CALLSYS_NOERROR(sys_exit)
+#endif
+END(rfork_thread)
diff --git a/lib/libc/alpha/gen/setjmp.S b/lib/libc/alpha/gen/setjmp.S
new file mode 100644
index 0000000..20e1135
--- /dev/null
+++ b/lib/libc/alpha/gen/setjmp.S
@@ -0,0 +1,129 @@
+/* $NetBSD: setjmp.S,v 1.3 1997/12/05 02:06:27 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $FreeBSD$
+ */
+
+#include "SYS.h"
+
+/*
+ * 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 the previous signal state.
+ */
+
+ .set noreorder
+
+LEAF(setjmp, 1)
+ LDGP(pv)
+ stq ra, (2 * 8)(a0) /* sc_pc = return address */
+ stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */
+ stq s1, ((10 + 4) * 8)(a0)
+ stq s2, ((11 + 4) * 8)(a0)
+ stq s3, ((12 + 4) * 8)(a0)
+ stq s4, ((13 + 4) * 8)(a0)
+ stq s5, ((14 + 4) * 8)(a0)
+ stq s6, ((15 + 4) * 8)(a0)
+ stq ra, ((26 + 4) * 8)(a0)
+ stq t12,((27 + 4) * 8)(a0)
+ stq sp, ((30 + 4) * 8)(a0)
+
+ /*
+ * get signal information
+ */
+ mov a0, s0 /* squirrel away ptr to sc */
+
+ /* see what's blocked */
+ lda a2, (71 * 8)(a0) /* oset: sc_reserved */
+ mov zero, a1 /* set: NULL */
+ addq a1, 1, a0 /* how: SIG_BLOCK */
+ CALL(_sigprocmask) /* see what's blocked */
+
+ lda sp, -24(sp) /* sizeof struct sigaltstack */
+ mov zero, a0
+ mov sp, a1
+ CALL(_sigaltstack)
+ ldl t0, 16(sp) /* offset of ss_flags */
+ lda sp, 24(sp) /* sizeof struct sigaltstack */
+ ldq ra, ((26 + 4) * 8)(s0) /* restore return address */
+ blt v0, botch /* check for error */
+ and t0, 0x1, t0 /* get SA_ONSTACK flag */
+ stq t0, (0 * 8)(s0) /* and save it in sc_onstack */
+ /*
+ * Restore old s0 and a0, and continue saving registers
+ */
+ mov s0, a0
+ ldq s0, (( 9 + 4) * 8)(a0)
+
+ ldiq t0, 0xacedbade /* sigcontext magic number */
+ stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */
+ /* Too bad we can't check if we actually used FP */
+ ldiq t0, 1
+ stq t0, (36 * 8)(a0) /* say we've used FP. */
+ stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */
+ stt fs1, ((3 + 37) * 8)(a0)
+ stt fs2, ((4 + 37) * 8)(a0)
+ stt fs3, ((5 + 37) * 8)(a0)
+ stt fs4, ((6 + 37) * 8)(a0)
+ stt fs5, ((7 + 37) * 8)(a0)
+ stt fs6, ((8 + 37) * 8)(a0)
+ stt fs7, ((9 + 37) * 8)(a0)
+ mf_fpcr ft0 /* get FP control reg */
+ stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */
+ stq zero, (70 * 8)(a0) /* FP software control XXX */
+ stq zero, (71 * 8)(a0) /* sc_reserved[0] */
+ stq zero, (72 * 8)(a0) /* sc_reserved[1] */
+ stq zero, (73 * 8)(a0) /* sc_xxx[0] */
+ stq zero, (74 * 8)(a0) /* sc_xxx[1] */
+ stq zero, (75 * 8)(a0) /* sc_xxx[2] */
+ stq zero, (76 * 8)(a0) /* sc_xxx[3] */
+ stq zero, (77 * 8)(a0) /* sc_xxx[4] */
+ stq zero, (78 * 8)(a0) /* sc_xxx[5] */
+ stq zero, (79 * 8)(a0) /* sc_xxx[6] */
+ stq zero, (80 * 8)(a0) /* sc_xxx[7] */
+
+ mov zero, v0 /* return zero */
+ RET
+END(setjmp)
+
+XLEAF(longjmp, 2)
+LEAF(__longjmp, 2)
+ LDGP(pv)
+ stq a1, (( 0 + 4) * 8)(a0) /* save return value */
+ CALL(_sigreturn) /* use sigreturn to return */
+
+botch:
+ CALL(longjmperror)
+ CALL(abort)
+ RET /* "can't" get here... */
+END(__longjmp)
diff --git a/lib/libc/alpha/gen/sigsetjmp.S b/lib/libc/alpha/gen/sigsetjmp.S
new file mode 100644
index 0000000..ddc0636
--- /dev/null
+++ b/lib/libc/alpha/gen/sigsetjmp.S
@@ -0,0 +1,65 @@
+/* $NetBSD: sigsetjmp.S,v 1.2 1996/10/17 03:08:07 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asm.h>
+
+/*
+ * C library -- sigsetjmp, siglongjmp
+ *
+ * siglongjmp(a,v)
+ * will generate a "return(v)" from
+ * the last call to
+ * sigsetjmp(a, mask)
+ * by restoring registers from the stack.
+ * If `mask' is non-zero, the previous signal
+ * state will be restored.
+ */
+
+ .set noreorder
+
+LEAF(sigsetjmp, 2)
+ LDGP(pv)
+ stq a1, (81 * 8)(a0) /* save the mask */
+ bne a1, Lsavesig /* if !zero, save signals */
+ jmp zero, _setjmp /* else don't. */
+Lsavesig:
+ jmp zero, setjmp
+END(sigsetjmp)
+
+XLEAF(siglongjmp, 2)
+LEAF(__siglongjmp, 2)
+ LDGP(pv)
+ ldq t0, (81 * 8)(a0) /* get the mask */
+ bne t0, Lrestoresig /* if !zero, restore signals */
+ jmp zero, ___longjmp
+Lrestoresig:
+ jmp zero, __longjmp
+END(__siglongjmp)
OpenPOWER on IntegriCloud