summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPer Fogelstrom <pefo@cvs.openbsd.org>2004-08-11 17:31:01 +0000
committerPer Fogelstrom <pefo@cvs.openbsd.org>2004-08-11 17:31:01 +0000
commit157c05af49992f375d3ca44737e259c872051014 (patch)
treef8cc5522886b78edb8ebabfa9652193df94e667c /lib
parent67b613d9239ed22a3fe39669391322df18da32c9 (diff)
Move mips to mips64
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/arch/mips64/Makefile.inc4
-rw-r--r--lib/libc/arch/mips64/SYS.h84
-rw-r--r--lib/libc/arch/mips64/gen/Makefile.inc7
-rw-r--r--lib/libc/arch/mips64/gen/_setjmp.S158
-rw-r--r--lib/libc/arch/mips64/gen/fabs.S50
-rw-r--r--lib/libc/arch/mips64/gen/flt_rounds.c28
-rw-r--r--lib/libc/arch/mips64/gen/fpgetmask.c19
-rw-r--r--lib/libc/arch/mips64/gen/fpgetround.c19
-rw-r--r--lib/libc/arch/mips64/gen/fpgetsticky.c19
-rw-r--r--lib/libc/arch/mips64/gen/fpsetmask.c28
-rw-r--r--lib/libc/arch/mips64/gen/fpsetround.c28
-rw-r--r--lib/libc/arch/mips64/gen/fpsetsticky.c28
-rw-r--r--lib/libc/arch/mips64/gen/frexp.c74
-rw-r--r--lib/libc/arch/mips64/gen/infinity.c15
-rw-r--r--lib/libc/arch/mips64/gen/isinf.S91
-rw-r--r--lib/libc/arch/mips64/gen/ldexp.S213
-rw-r--r--lib/libc/arch/mips64/gen/modf.S75
-rw-r--r--lib/libc/arch/mips64/gen/setjmp.S138
-rw-r--r--lib/libc/arch/mips64/gen/sigsetjmp.S65
-rw-r--r--lib/libc/arch/mips64/net/Makefile.inc4
-rw-r--r--lib/libc/arch/mips64/net/htonl.S65
-rw-r--r--lib/libc/arch/mips64/net/htons.S61
-rw-r--r--lib/libc/arch/mips64/string/Makefile.inc7
-rw-r--r--lib/libc/arch/mips64/string/bcmp.S116
-rw-r--r--lib/libc/arch/mips64/string/bcopy.S123
-rw-r--r--lib/libc/arch/mips64/string/bzero.S70
-rw-r--r--lib/libc/arch/mips64/string/ffs.S53
-rw-r--r--lib/libc/arch/mips64/string/index.S52
-rw-r--r--lib/libc/arch/mips64/string/rindex.S51
-rw-r--r--lib/libc/arch/mips64/string/strcmp.S62
-rw-r--r--lib/libc/arch/mips64/string/strlen.S49
-rw-r--r--lib/libc/arch/mips64/sys/Ovfork.S59
-rw-r--r--lib/libc/arch/mips64/sys/brk.S77
-rw-r--r--lib/libc/arch/mips64/sys/cerror.S47
-rw-r--r--lib/libc/arch/mips64/sys/exect.S49
-rw-r--r--lib/libc/arch/mips64/sys/fork.S52
-rw-r--r--lib/libc/arch/mips64/sys/rfork.S52
-rw-r--r--lib/libc/arch/mips64/sys/sbrk.S60
-rw-r--r--lib/libc/arch/mips64/sys/setlogin.S51
-rw-r--r--lib/libc/arch/mips64/sys/sigpending.S51
-rw-r--r--lib/libc/arch/mips64/sys/sigprocmask.S59
-rw-r--r--lib/libc/arch/mips64/sys/sigreturn.S44
-rw-r--r--lib/libc/arch/mips64/sys/sigsuspend.S51
-rw-r--r--lib/libc/arch/mips64/sys/syscall.S43
44 files changed, 2551 insertions, 0 deletions
diff --git a/lib/libc/arch/mips64/Makefile.inc b/lib/libc/arch/mips64/Makefile.inc
new file mode 100644
index 00000000000..7e333674e53
--- /dev/null
+++ b/lib/libc/arch/mips64/Makefile.inc
@@ -0,0 +1,4 @@
+# $OpenBSD: Makefile.inc,v 1.1 2004/08/11 17:30:59 pefo Exp $
+
+KMINCLUDES=
+KMSRCS=
diff --git a/lib/libc/arch/mips64/SYS.h b/lib/libc/arch/mips64/SYS.h
new file mode 100644
index 00000000000..284e9fb4152
--- /dev/null
+++ b/lib/libc/arch/mips64/SYS.h
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $OpenBSD: SYS.h,v 1.1 2004/08/11 17:30:59 pefo Exp $
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+
+#ifdef __STDC__
+# define __ENTRY(p,x) ENTRY(p ## x)
+
+# define __DO_SYSCALL(x) \
+ li v0,SYS_ ## x; \
+ syscall
+
+# define __LEAF2(p,x) LEAF(p ## x) \
+ .weak x; x = p ## x;
+# define __END2(p,x) END(p ## x)
+# define __CLABEL2(p,x) _C_LABEL(p ## x)
+#else
+# define __ENTRY(p,x) ENTRY(p/**/x)
+
+# define __DO_SYSCALL(x) \
+ li v0,SYS_/**/x; \
+ syscall
+
+# define __LEAF2(p,x) LEAF(p/**/x) \
+ .weak x; x = p/**/x;
+# define __END2(p,x) END(p/**/x)
+# define __CLABEL2(p,x) _C_LABEL(p/**/x)
+#endif
+
+#define __PSEUDO_NOERROR(p,x,y) \
+ __LEAF2(p,x); \
+ __DO_SYSCALL(y); \
+ j ra; \
+ __END2(p,x)
+
+#define __PSEUDO(p,x,y) \
+ __LEAF2(p,x); \
+ __DO_SYSCALL(y); \
+ bne a3,zero,err; \
+ j ra; \
+ err: la t9,_C_LABEL(cerror); \
+ jr t9; \
+ __END2(p,x)
+
+
+#define RSYSCALL(x) __PSEUDO(_thread_sys_,x,x)
+#define PSEUDO(x,y) __PSEUDO(_thread_sys_,x,y)
+#define PSEUDO_NOERROR(x,y) __PSEUDO_NOERROR(_thread_sys_,x,y)
+
+#define SYSLEAF(x) __LEAF2(_thread_sys_,x)
+#define SYSEND(x) __END2(_thread_sys_,x)
+
diff --git a/lib/libc/arch/mips64/gen/Makefile.inc b/lib/libc/arch/mips64/gen/Makefile.inc
new file mode 100644
index 00000000000..b9d62dd689b
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/Makefile.inc
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile.inc,v 1.1 2004/08/11 17:30:59 pefo Exp $
+
+SRCS+= _setjmp.S fabs.S frexp.c infinity.c isinf.S ldexp.S modf.S
+SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+ fpsetround.c fpsetsticky.c
+SRCS+= setjmp.S sigsetjmp.S
+SRCS+= alloca.c
diff --git a/lib/libc/arch/mips64/gen/_setjmp.S b/lib/libc/arch/mips64/gen/_setjmp.S
new file mode 100644
index 00000000000..60a6977df9e
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/_setjmp.S
@@ -0,0 +1,158 @@
+/* $OpenBSD: _setjmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $ */
+
+/*
+ * Copyright (c) 2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Opsycon AB 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 ``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.
+ *
+ */
+
+#include <machine/asm.h>
+#include <machine/regnum.h>
+#include <machine/signal.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: _setjmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * _setjmp, _longjmp (not restoring signal state)
+ *
+ * XXX FPSET should probably be taken from SR setting. hmmm...
+ *
+ */
+LEAF(_setjmp)
+ .set noreorder
+#if defined(__mips64)
+ dli v0, 0xACEDBADE # sigcontext magic number
+#else
+ li v0, 0xACEDBADE # sigcontext magic number
+#endif
+ REG_S v0, SC_REGS+ZERO*REGSZ(a0)
+ REG_S s0, SC_REGS+S0*REGSZ(a0)
+ REG_S s1, SC_REGS+S1*REGSZ(a0)
+ REG_S s2, SC_REGS+S2*REGSZ(a0)
+ REG_S s3, SC_REGS+S3*REGSZ(a0)
+ REG_S s4, SC_REGS+S4*REGSZ(a0)
+ REG_S s5, SC_REGS+S5*REGSZ(a0)
+ REG_S s6, SC_REGS+S6*REGSZ(a0)
+ REG_S s7, SC_REGS+S7*REGSZ(a0)
+ REG_S s8, SC_REGS+S8*REGSZ(a0)
+ REG_S gp, SC_REGS+GP*REGSZ(a0)
+ REG_S sp, SC_REGS+SP*REGSZ(a0)
+ REG_S ra, SC_PC(a0)
+ cfc1 v0, $31
+#if _MIPS_FPSET == 32
+ sdc1 $f20, SC_FPREGS+((F20-F0)*REGSZ)(a0)
+ sdc1 $f21, SC_FPREGS+((F21-F0)*REGSZ)(a0)
+ sdc1 $f22, SC_FPREGS+((F22-F0)*REGSZ)(a0)
+ sdc1 $f23, SC_FPREGS+((F23-F0)*REGSZ)(a0)
+ sdc1 $f24, SC_FPREGS+((F24-F0)*REGSZ)(a0)
+ sdc1 $f25, SC_FPREGS+((F25-F0)*REGSZ)(a0)
+ sdc1 $f26, SC_FPREGS+((F26-F0)*REGSZ)(a0)
+ sdc1 $f27, SC_FPREGS+((F27-F0)*REGSZ)(a0)
+ sdc1 $f28, SC_FPREGS+((F28-F0)*REGSZ)(a0)
+ sdc1 $f29, SC_FPREGS+((F29-F0)*REGSZ)(a0)
+ sdc1 $f30, SC_FPREGS+((F30-F0)*REGSZ)(a0)
+ sdc1 $f31, SC_FPREGS+((F31-F0)*REGSZ)(a0)
+#else
+ swc1 $f20, SC_FPREGS+((F20-F0)*REGSZ)(a0)
+ swc1 $f21, SC_FPREGS+((F21-F0)*REGSZ)(a0)
+ swc1 $f22, SC_FPREGS+((F22-F0)*REGSZ)(a0)
+ swc1 $f23, SC_FPREGS+((F23-F0)*REGSZ)(a0)
+ swc1 $f24, SC_FPREGS+((F24-F0)*REGSZ)(a0)
+ swc1 $f25, SC_FPREGS+((F25-F0)*REGSZ)(a0)
+ swc1 $f26, SC_FPREGS+((F26-F0)*REGSZ)(a0)
+ swc1 $f27, SC_FPREGS+((F27-F0)*REGSZ)(a0)
+ swc1 $f28, SC_FPREGS+((F28-F0)*REGSZ)(a0)
+ swc1 $f29, SC_FPREGS+((F29-F0)*REGSZ)(a0)
+ swc1 $f30, SC_FPREGS+((F30-F0)*REGSZ)(a0)
+ swc1 $f31, SC_FPREGS+((F31-F0)*REGSZ)(a0)
+#endif
+ REG_S v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
+ j ra
+ move v0, zero
+END(_setjmp)
+
+LEAF(_longjmp)
+#ifdef ABICALLS
+ subu sp, sp, 32
+ .cprestore 16
+#endif
+ .set noreorder
+ REG_L v0, SC_REGS+ZERO*REGSZ(a0)
+ bne v0, 0xACEDBADE, botch # jump if error
+ REG_L ra, SC_PC(a0)
+ REG_L v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
+ REG_L s0, SC_REGS+S0*REGSZ(a0)
+ REG_L s1, SC_REGS+S1*REGSZ(a0)
+ REG_L s2, SC_REGS+S2*REGSZ(a0)
+ REG_L s3, SC_REGS+S3*REGSZ(a0)
+ REG_L s4, SC_REGS+S4*REGSZ(a0)
+ REG_L s5, SC_REGS+S5*REGSZ(a0)
+ REG_L s6, SC_REGS+S6*REGSZ(a0)
+ REG_L s7, SC_REGS+S7*REGSZ(a0)
+ REG_L s8, SC_REGS+S8*REGSZ(a0)
+ REG_L gp, SC_REGS+GP*REGSZ(a0)
+ REG_L sp, SC_REGS+SP*REGSZ(a0)
+ ctc1 v0, $31
+#if _MIPS_FPSET == 32
+ ldc1 $f20, SC_FPREGS+((F20-F0)*REGSZ)(a0)
+ ldc1 $f21, SC_FPREGS+((F21-F0)*REGSZ)(a0)
+ ldc1 $f22, SC_FPREGS+((F22-F0)*REGSZ)(a0)
+ ldc1 $f23, SC_FPREGS+((F23-F0)*REGSZ)(a0)
+ ldc1 $f24, SC_FPREGS+((F24-F0)*REGSZ)(a0)
+ ldc1 $f25, SC_FPREGS+((F25-F0)*REGSZ)(a0)
+ ldc1 $f26, SC_FPREGS+((F26-F0)*REGSZ)(a0)
+ ldc1 $f27, SC_FPREGS+((F27-F0)*REGSZ)(a0)
+ ldc1 $f28, SC_FPREGS+((F28-F0)*REGSZ)(a0)
+ ldc1 $f29, SC_FPREGS+((F29-F0)*REGSZ)(a0)
+ ldc1 $f30, SC_FPREGS+((F30-F0)*REGSZ)(a0)
+ ldc1 $f31, SC_FPREGS+((F31-F0)*REGSZ)(a0)
+#else
+ lwc1 $f20, SC_FPREGS+((F20-F0)*REGSZ)(a0)
+ lwc1 $f21, SC_FPREGS+((F21-F0)*REGSZ)(a0)
+ lwc1 $f22, SC_FPREGS+((F22-F0)*REGSZ)(a0)
+ lwc1 $f23, SC_FPREGS+((F23-F0)*REGSZ)(a0)
+ lwc1 $f24, SC_FPREGS+((F24-F0)*REGSZ)(a0)
+ lwc1 $f25, SC_FPREGS+((F25-F0)*REGSZ)(a0)
+ lwc1 $f26, SC_FPREGS+((F26-F0)*REGSZ)(a0)
+ lwc1 $f27, SC_FPREGS+((F27-F0)*REGSZ)(a0)
+ lwc1 $f28, SC_FPREGS+((F28-F0)*REGSZ)(a0)
+ lwc1 $f29, SC_FPREGS+((F29-F0)*REGSZ)(a0)
+ lwc1 $f30, SC_FPREGS+((F30-F0)*REGSZ)(a0)
+ lwc1 $f31, SC_FPREGS+((F31-F0)*REGSZ)(a0)
+#endif
+ j ra
+ move v0, a1
+
+botch:
+ jal longjmperror
+ nop
+ jal abort
+ nop
+END(_longjmp)
+
diff --git a/lib/libc/arch/mips64/gen/fabs.S b/lib/libc/arch/mips64/gen/fabs.S
new file mode 100644
index 00000000000..31b440ec329
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fabs.S
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: fabs.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * fabs(x)
+ * double x;
+ *
+ * Return absolute value of x.
+ */
+LEAF(fabs)
+ .set noreorder
+ j ra
+ abs.d $f0, $f12 # compute absolute value of x
+END(fabs)
diff --git a/lib/libc/arch/mips64/gen/flt_rounds.c b/lib/libc/arch/mips64/gen/flt_rounds.c
new file mode 100644
index 00000000000..2bb2f99b8e2
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/flt_rounds.c
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#include <sys/types.h>
+#include <machine/float.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: flt_rounds.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+static const int map[] = {
+ 1, /* round to nearest */
+ 0, /* round to zero */
+ 2, /* round to positive infinity */
+ 3 /* round to negative infinity */
+};
+
+int
+__flt_rounds()
+{
+ int x;
+
+ __asm__("cfc1 %0,$31" : "=r" (x));
+ __asm__("nop");
+ return map[x & 0x03];
+}
diff --git a/lib/libc/arch/mips64/gen/fpgetmask.c b/lib/libc/arch/mips64/gen/fpgetmask.c
new file mode 100644
index 00000000000..a7414d81793
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fpgetmask.c
@@ -0,0 +1,19 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: fpgetmask.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ieeefp.h>
+
+fp_except
+fpgetmask()
+{
+ int x;
+
+ __asm__("cfc1 %0,$31" : "=r" (x));
+ return (x >> 7) & 0x1f;
+}
diff --git a/lib/libc/arch/mips64/gen/fpgetround.c b/lib/libc/arch/mips64/gen/fpgetround.c
new file mode 100644
index 00000000000..8dd14bb25f6
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fpgetround.c
@@ -0,0 +1,19 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: fpgetround.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ieeefp.h>
+
+fp_rnd
+fpgetround()
+{
+ int x;
+
+ __asm__("cfc1 %0,$31" : "=r" (x));
+ return x & 0x03;
+}
diff --git a/lib/libc/arch/mips64/gen/fpgetsticky.c b/lib/libc/arch/mips64/gen/fpgetsticky.c
new file mode 100644
index 00000000000..c1e60434220
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fpgetsticky.c
@@ -0,0 +1,19 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: fpgetsticky.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ieeefp.h>
+
+fp_except
+fpgetsticky()
+{
+ int x;
+
+ __asm__("cfc1 %0,$31" : "=r" (x));
+ return (x >> 2) & 0x1f;
+}
diff --git a/lib/libc/arch/mips64/gen/fpsetmask.c b/lib/libc/arch/mips64/gen/fpsetmask.c
new file mode 100644
index 00000000000..26337c805c4
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fpsetmask.c
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: fpsetmask.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ieeefp.h>
+
+fp_except
+fpsetmask(mask)
+ fp_except mask;
+{
+ fp_except old;
+ fp_except new;
+
+ __asm__("cfc1 %0,$31" : "=r" (old));
+
+ new = old;
+ new &= ~(0x1f << 7);
+ new |= ((mask & 0x1f) << 7);
+
+ __asm__("ctc1 %0,$31" : : "r" (new));
+
+ return (old >> 7) & 0x1f;
+}
diff --git a/lib/libc/arch/mips64/gen/fpsetround.c b/lib/libc/arch/mips64/gen/fpsetround.c
new file mode 100644
index 00000000000..d72f4e435ad
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fpsetround.c
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: fpsetround.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ieeefp.h>
+
+fp_rnd
+fpsetround(rnd_dir)
+ fp_rnd rnd_dir;
+{
+ fp_rnd old;
+ fp_rnd new;
+
+ __asm__("cfc1 %0,$31" : "=r" (old));
+
+ new = old;
+ new &= ~0x03;
+ new |= (rnd_dir & 0x03);
+
+ __asm__("ctc1 %0,$31" : : "r" (new));
+
+ return old & 0x03;
+}
diff --git a/lib/libc/arch/mips64/gen/fpsetsticky.c b/lib/libc/arch/mips64/gen/fpsetsticky.c
new file mode 100644
index 00000000000..dcfc751a990
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/fpsetsticky.c
@@ -0,0 +1,28 @@
+/*
+ * Written by J.T. Conklin, Apr 11, 1995
+ * Public domain.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: fpsetsticky.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <ieeefp.h>
+
+fp_except
+fpsetsticky(sticky)
+ fp_except sticky;
+{
+ fp_except old;
+ fp_except new;
+
+ __asm__("cfc1 %0,$31" : "=r" (old));
+
+ new = old;
+ new &= ~(0x1f << 2);
+ new |= ((sticky & 0x1f) << 2);
+
+ __asm__("ctc1 %0,$31" : : "r" (new));
+
+ return (old >> 2) & 0x1f;
+}
diff --git a/lib/libc/arch/mips64/gen/frexp.c b/lib/libc/arch/mips64/gen/frexp.c
new file mode 100644
index 00000000000..5c285637d12
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/frexp.c
@@ -0,0 +1,74 @@
+/* $OpenBSD: frexp.c,v 1.1 2004/08/11 17:30:59 pefo Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: frexp.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#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/mips64/gen/infinity.c b/lib/libc/arch/mips64/gen/infinity.c
new file mode 100644
index 00000000000..30249b65aed
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/infinity.c
@@ -0,0 +1,15 @@
+/* infinity.c */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: infinity.c,v 1.1 2004/08/11 17:30:59 pefo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <math.h>
+#include <sys/types.h>
+
+/* bytes for +Infinity on a MIPS */
+#if BYTE_ORDER == BIG_ENDIAN
+char __infinity[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 };
+#else
+char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
+#endif
diff --git a/lib/libc/arch/mips64/gen/isinf.S b/lib/libc/arch/mips64/gen/isinf.S
new file mode 100644
index 00000000000..439de1efcfc
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/isinf.S
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: isinf.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+#define DEXP_INF 0x7ff
+
+/*
+ * isnan(x)
+ * double x;
+ *
+ * Return true if x is a NAN.
+ */
+LEAF(isnan)
+ .set noreorder
+ mfc1 v1, $f13 # get MSW of x
+ mfc1 t3, $f12 # get LSW of x
+ sll t1, v1, 1 # get x exponent
+ srl t1, t1, 32 - 11
+ bne t1, DEXP_INF, 2f # is it a finite number?
+ sll t2, v1, 32 - 20 # get x fraction
+ bne t3, zero, 1f # is it a NAN?
+ nop
+ beq t2, zero, 2f # its infinity
+ nop
+1:
+ j ra
+ li v0, 1 # x is a NAN
+2:
+ j ra
+ move v0, zero # x is NOT a NAN
+END(isnan)
+
+/*
+ * isinf(x)
+ * double x;
+ *
+ * Return true if x is infinity.
+ */
+LEAF(isinf)
+ .set noreorder
+ mfc1 v1, $f13 # get MSW of x
+ mfc1 t3, $f12 # get LSW of x
+ sll t1, v1, 1 # get x exponent
+ srl t1, t1, 32 - 11
+ bne t1, DEXP_INF, 1f # is it a finite number?
+ sll t2, v1, 32 - 20 # get x fraction
+ bne t3, zero, 1f # is it a NAN?
+ nop
+ bne t2, zero, 1f # is it a NAN?
+ nop
+ j ra
+ li v0, 1 # x is infinity
+1:
+ j ra
+ move v0, zero # x is NOT infinity
+END(isinf)
diff --git a/lib/libc/arch/mips64/gen/ldexp.S b/lib/libc/arch/mips64/gen/ldexp.S
new file mode 100644
index 00000000000..cbee28cb0a8
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/ldexp.S
@@ -0,0 +1,213 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: ldexp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+#define DEXP_INF 0x7ff
+#define DEXP_BIAS 1023
+#define DEXP_MIN -1022
+#define DEXP_MAX 1023
+#define DFRAC_BITS 52
+#define DIMPL_ONE 0x00100000
+#define DLEAD_ZEROS 31 - 20
+#define STICKYBIT 1
+#define GUARDBIT 0x80000000
+#define DSIGNAL_NAN 0x00040000
+#define DQUIET_NAN0 0x0007ffff
+#define DQUIET_NAN1 0xffffffff
+
+/*
+ * double ldexp(x, N)
+ * double x; int N;
+ *
+ * Return x * (2**N), for integer values N.
+ */
+LEAF(ldexp)
+ .set reorder
+ mfc1 v1, $f13 # get MSW of x
+ mfc1 t3, $f12 # get LSW of x
+ sll t1, v1, 1 # get x exponent
+ srl t1, t1, 32 - 11
+ beq t1, DEXP_INF, 9f # is it a NAN or infinity?
+ beq t1, zero, 1f # zero or denormalized number?
+ addu t1, t1, a2 # scale exponent
+ sll v0, a2, 20 # position N for addition
+ bge t1, DEXP_INF, 8f # overflow?
+ addu v0, v0, v1 # multiply by (2**N)
+ ble t1, zero, 4f # underflow?
+ mtc1 v0, $f1 # save MSW of result
+ mtc1 t3, $f0 # save LSW of result
+ j ra
+1:
+ sll t2, v1, 32 - 20 # get x fraction
+ srl t2, t2, 32 - 20
+ srl t0, v1, 31 # get x sign
+ bne t2, zero, 1f
+ beq t3, zero, 9f # result is zero
+1:
+/*
+ * Find out how many leading zero bits are in t2,t3 and put in t9.
+ */
+ move v0, t2
+ move t9, zero
+ bne t2, zero, 1f
+ move v0, t3
+ addu t9, 32
+1:
+ srl t4, v0, 16
+ bne t4, zero, 1f
+ addu t9, 16
+ sll v0, 16
+1:
+ srl t4, v0, 24
+ bne t4, zero, 1f
+ addu t9, 8
+ sll v0, 8
+1:
+ srl t4, v0, 28
+ bne t4, zero, 1f
+ addu t9, 4
+ sll v0, 4
+1:
+ srl t4, v0, 30
+ bne t4, zero, 1f
+ addu t9, 2
+ sll v0, 2
+1:
+ srl t4, v0, 31
+ bne t4, zero, 1f
+ addu t9, 1
+/*
+ * Now shift t2,t3 the correct number of bits.
+ */
+1:
+ subu t9, t9, DLEAD_ZEROS # dont count normal leading zeros
+ li t1, DEXP_MIN + DEXP_BIAS
+ subu t1, t1, t9 # adjust exponent
+ addu t1, t1, a2 # scale exponent
+ li v0, 32
+ blt t9, v0, 1f
+ subu t9, t9, v0 # shift fraction left >= 32 bits
+ sll t2, t3, t9
+ move t3, zero
+ b 2f
+1:
+ subu v0, v0, t9 # shift fraction left < 32 bits
+ sll t2, t2, t9
+ srl t4, t3, v0
+ or t2, t2, t4
+ sll t3, t3, t9
+2:
+ bge t1, DEXP_INF, 8f # overflow?
+ ble t1, zero, 4f # underflow?
+ sll t2, t2, 32 - 20 # clear implied one bit
+ srl t2, t2, 32 - 20
+3:
+ sll t1, t1, 31 - 11 # reposition exponent
+ sll t0, t0, 31 # reposition sign
+ or t0, t0, t1 # put result back together
+ or t0, t0, t2
+ mtc1 t0, $f1 # save MSW of result
+ mtc1 t3, $f0 # save LSW of result
+ j ra
+4:
+ li v0, 0x80000000
+ ble t1, -52, 7f # is result too small for denorm?
+ sll t2, v1, 31 - 20 # clear exponent, extract fraction
+ or t2, t2, v0 # set implied one bit
+ blt t1, -30, 2f # will all bits in t3 be shifted out?
+ srl t2, t2, 31 - 20 # shift fraction back to normal position
+ subu t1, t1, 1
+ sll t4, t2, t1 # shift right t2,t3 based on exponent
+ srl t8, t3, t1 # save bits shifted out
+ negu t1
+ srl t3, t3, t1
+ or t3, t3, t4
+ srl t2, t2, t1
+ bge t8, zero, 1f # does result need to be rounded?
+ addu t3, t3, 1 # round result
+ sltu t4, t3, 1
+ sll t8, t8, 1
+ addu t2, t2, t4
+ bne t8, zero, 1f # round result to nearest
+ and t3, t3, ~1
+1:
+ mtc1 t3, $f0 # save denormalized result (LSW)
+ mtc1 t2, $f1 # save denormalized result (MSW)
+ bge v1, zero, 1f # should result be negative?
+ neg.d $f0, $f0 # negate result
+1:
+ j ra
+2:
+ mtc1 zero, $f1 # exponent and upper fraction
+ addu t1, t1, 20 # compute amount to shift right by
+ sll t8, t2, t1 # save bits shifted out
+ negu t1
+ srl t3, t2, t1
+ bge t8, zero, 1f # does result need to be rounded?
+ addu t3, t3, 1 # round result
+ sltu t4, t3, 1
+ sll t8, t8, 1
+ mtc1 t4, $f1 # exponent and upper fraction
+ bne t8, zero, 1f # round result to nearest
+ and t3, t3, ~1
+1:
+ mtc1 t3, $f0
+ bge v1, zero, 1f # is result negative?
+ neg.d $f0, $f0 # negate result
+1:
+ j ra
+7:
+ mtc1 zero, $f0 # result is zero
+ mtc1 zero, $f1
+ beq t0, zero, 1f # is result positive?
+ neg.d $f0, $f0 # negate result
+1:
+ j ra
+8:
+ li t1, 0x7ff00000 # result is infinity (MSW)
+ mtc1 t1, $f1
+ mtc1 zero, $f0 # result is infinity (LSW)
+ bge v1, zero, 1f # should result be negative infinity?
+ neg.d $f0, $f0 # result is negative infinity
+1:
+ add.d $f0, $f0 # cause overflow faults if enabled
+ j ra
+9:
+ mov.d $f0, $f12 # yes, result is just x
+ j ra
+END(ldexp)
diff --git a/lib/libc/arch/mips64/gen/modf.S b/lib/libc/arch/mips64/gen/modf.S
new file mode 100644
index 00000000000..677cdaf2967
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/modf.S
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 1991, 1993, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: modf.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * double modf(val, iptr)
+ * double val, *iptr;
+ * returns: xxx and n (in *iptr) where val == n.xxx
+ */
+LEAF(modf)
+ .set reorder
+ cfc1 t0, $31 # get the control register
+ li.d $f2, 4503599627370496e0 # f2 <- 2^52
+
+ or t1, t0, 0x3 # set rounding mode to round to zero
+ xor t1, t1, 0x2 # (i.e., 01)
+ ctc1 t1, $31
+
+ mov.d $f0, $f12 # f0 <- f12
+ abs.d $f4, $f12 # f4 <- |f12|
+ c.olt.d $f4, $f2 # f4 ? < f2
+ bc1f 1f # leave f0 alone if Nan, infinity
+ # or >=2^52
+ c.eq.d $f12,$f4 # was f12 positive ?
+ add.d $f4,$f2,$f4 # round off to integer
+ bc1f 2f # No -> will have to negate result
+ sub.d $f0,$f4,$f2 # Remove fudge factor
+ j 1f # integer fraction got
+2:
+ sub.d $f0,$f2,$f4 # Remove fudge factor and negate
+1:
+ ctc1 t0, $31 # restore old rounding mode
+#ifdef __mips64
+ s.d $f0, 0(a1) # save the integer part
+#else
+ s.d $f0, 0(a2) # save the integer part
+#endif
+ sub.d $f0, $f12, $f0 # subtract val - integer part
+ j ra
+END(modf)
diff --git a/lib/libc/arch/mips64/gen/setjmp.S b/lib/libc/arch/mips64/gen/setjmp.S
new file mode 100644
index 00000000000..ca714f49537
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/setjmp.S
@@ -0,0 +1,138 @@
+/* $OpenBSD: setjmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $ */
+
+/*
+ * Copyright (c) 2001-2002 Opsycon AB (www.opsycon.se / www.opsycon.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Opsycon AB 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 ``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.
+ *
+ */
+
+#include <sys/syscall.h>
+#include <machine/asm.h>
+#include <machine/regnum.h>
+#include <machine/signal.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: setjmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * setjmp, longjmp implementation for libc. this code depends
+ * on the layout of the struct sigcontext in machine/signal.h.
+ *
+ */
+
+#define SETJMP_FRAMESZ (FRAMESZ(CF_SZ) + 4 * REGSZ)
+
+NON_LEAF(setjmp, SETJMP_FRAMESZ, ra)
+ .mask 0x80000000, (CF_RA_OFFS - FRAMESZ(CF_SZ))
+ PTR_SUB sp, sp, SETJMP_FRAMESZ # allocate stack frame
+#ifdef ABICALLS
+ .cprestore 16
+#endif
+ .set reorder
+ REG_S ra, CF_RA_OFFS(sp) # save state
+ REG_S a0, SETJMP_FRAMESZ(sp)
+ move a0, zero # get current signal mask
+ jal sigblock
+ REG_L v1, SETJMP_FRAMESZ(sp) # v1 = jmpbuf
+ REG_S v0, SC_MASK(v1) # save sc_mask = sigblock(0)
+ move a0, zero
+ PTR_ADD a1, sp, FRAMESZ(CF_SZ) # pointer to struct sigaltstack
+ jal _thread_sys_sigaltstack
+ REG_L a0, SETJMP_FRAMESZ(sp) # restore jmpbuf
+ lw v1, FRAMESZ(CF_SZ)+REGSZ+4(sp) # get old ss_onstack
+ and v1, v1, 1 # extract onstack flag
+ REG_S v1, SC_ONSTACK(a0) # save it in sc_onstack
+ REG_L ra, CF_RA_OFFS(sp)
+ PTR_ADD sp, sp, SETJMP_FRAMESZ
+ blt v0, zero, botch # check for sigstack() error
+ REG_S ra, SC_PC(a0) # sc_pc = return address
+#if defined(__mips64)
+ dli v0, 0xACEDBADE # sigcontext magic number
+#else
+ li v0, 0xACEDBADE # sigcontext magic number
+#endif
+ REG_S v0, SC_REGS+ZERO*REGSZ(a0)
+ REG_S s0, SC_REGS+S0*REGSZ(a0)
+ REG_S s1, SC_REGS+S1*REGSZ(a0)
+ REG_S s2, SC_REGS+S2*REGSZ(a0)
+ REG_S s3, SC_REGS+S3*REGSZ(a0)
+ REG_S s4, SC_REGS+S4*REGSZ(a0)
+ REG_S s5, SC_REGS+S5*REGSZ(a0)
+ REG_S s6, SC_REGS+S6*REGSZ(a0)
+ REG_S s7, SC_REGS+S7*REGSZ(a0)
+ REG_S s8, SC_REGS+S8*REGSZ(a0)
+ REG_S gp, SC_REGS+GP*REGSZ(a0)
+ REG_S sp, SC_REGS+SP*REGSZ(a0)
+ li v0, 1 # be nice if we could tell
+ REG_S v0, SC_FPUSED(a0) # sc_fpused = 1
+ cfc1 v0, $31
+#if _MIPS_FPSET == 32
+ sdc1 $f20, SC_FPREGS+((F20-F0)*REGSZ)(a0)
+ sdc1 $f21, SC_FPREGS+((F21-F0)*REGSZ)(a0)
+ sdc1 $f22, SC_FPREGS+((F22-F0)*REGSZ)(a0)
+ sdc1 $f23, SC_FPREGS+((F23-F0)*REGSZ)(a0)
+ sdc1 $f24, SC_FPREGS+((F24-F0)*REGSZ)(a0)
+ sdc1 $f25, SC_FPREGS+((F25-F0)*REGSZ)(a0)
+ sdc1 $f26, SC_FPREGS+((F26-F0)*REGSZ)(a0)
+ sdc1 $f27, SC_FPREGS+((F27-F0)*REGSZ)(a0)
+ sdc1 $f28, SC_FPREGS+((F28-F0)*REGSZ)(a0)
+ sdc1 $f29, SC_FPREGS+((F29-F0)*REGSZ)(a0)
+ sdc1 $f30, SC_FPREGS+((F30-F0)*REGSZ)(a0)
+ sdc1 $f31, SC_FPREGS+((F31-F0)*REGSZ)(a0)
+#else
+ swc1 $f20, SC_FPREGS+((F20-F0)*REGSZ)(a0)
+ swc1 $f21, SC_FPREGS+((F21-F0)*REGSZ)(a0)
+ swc1 $f22, SC_FPREGS+((F22-F0)*REGSZ)(a0)
+ swc1 $f23, SC_FPREGS+((F23-F0)*REGSZ)(a0)
+ swc1 $f24, SC_FPREGS+((F24-F0)*REGSZ)(a0)
+ swc1 $f25, SC_FPREGS+((F25-F0)*REGSZ)(a0)
+ swc1 $f26, SC_FPREGS+((F26-F0)*REGSZ)(a0)
+ swc1 $f27, SC_FPREGS+((F27-F0)*REGSZ)(a0)
+ swc1 $f28, SC_FPREGS+((F28-F0)*REGSZ)(a0)
+ swc1 $f29, SC_FPREGS+((F29-F0)*REGSZ)(a0)
+ swc1 $f30, SC_FPREGS+((F30-F0)*REGSZ)(a0)
+ swc1 $f31, SC_FPREGS+((F31-F0)*REGSZ)(a0)
+#endif
+ REG_S v0, SC_FPREGS+((FSR-F0)*REGSZ)(a0)
+ move v0, zero
+ j ra
+END(setjmp)
+
+LEAF(longjmp)
+#ifdef ABICALLS
+ PTR_SUB sp, sp, CF_ARGSZ * 2
+ .cprestore 16
+#endif
+ .set reorder
+ REG_S a1, SC_REGS+V0*REGSZ(a0)
+ li v0, SYS_sigreturn
+ syscall
+botch:
+ jal longjmperror
+ jal abort
+END(longjmp)
diff --git a/lib/libc/arch/mips64/gen/sigsetjmp.S b/lib/libc/arch/mips64/gen/sigsetjmp.S
new file mode 100644
index 00000000000..414681506d2
--- /dev/null
+++ b/lib/libc/arch/mips64/gen/sigsetjmp.S
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 1991, 1993, 1995,
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Havard Eidnes.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+#include <machine/regnum.h>
+#include <machine/setjmp.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: sigsetjmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * trampolines for sigsetjmp and siglongjmp save and restore mask.
+ *
+ */
+LEAF(sigsetjmp)
+ .set reorder
+ REG_S a1, (_JBLEN*REGSZ)(a0) # save "savemask"
+ bne a1, 0x0, 1f # do saving of signal mask?
+ la t9, _setjmp
+ jr t9
+
+1: la t9, setjmp
+ jr t9
+END(sigsetjmp)
+
+LEAF(siglongjmp)
+ .set reorder
+ REG_L t0, (_JBLEN*REGSZ)(a0) # get "savemask"
+ bne t0, 0x0, 1f # restore signal mask?
+ la t9, _longjmp
+ jr t9
+1: la t9, longjmp
+ jr t9
+END(siglongjmp)
diff --git a/lib/libc/arch/mips64/net/Makefile.inc b/lib/libc/arch/mips64/net/Makefile.inc
new file mode 100644
index 00000000000..21b5694f652
--- /dev/null
+++ b/lib/libc/arch/mips64/net/Makefile.inc
@@ -0,0 +1,4 @@
+# $OpenBSD: Makefile.inc,v 1.1 2004/08/11 17:30:59 pefo Exp $
+
+SRCS+= htonl.S htons.S
+LSRCS+= htonl.c htons.c
diff --git a/lib/libc/arch/mips64/net/htonl.S b/lib/libc/arch/mips64/net/htonl.S
new file mode 100644
index 00000000000..4d245078cc3
--- /dev/null
+++ b/lib/libc/arch/mips64/net/htonl.S
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: htonl.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * netorder = htonl(hostorder)
+ * hostorder = ntohl(netorder)
+ */
+ALEAF(ntohl)
+NLEAF(htonl) # a0 = 0x11223344, return 0x44332211
+ .set reorder
+#ifdef __MIPSEL__
+ srl v1, a0, 24 # v1 = 0x00000011
+ sll v0, a0, 24 # v0 = 0x44000000
+ or v0, v0, v1
+ and v1, a0, 0xff00
+ sll v1, v1, 8 # v1 = 0x00330000
+ or v0, v0, v1
+ srl v1, a0, 8
+ and v1, v1, 0xff00 # v1 = 0x00002200
+ or v0, v0, v1
+#else
+#ifdef __MIPSEB__
+ move v0, a0
+#else
+ ERROR
+#endif
+#endif
+ j ra
+END(htonl)
diff --git a/lib/libc/arch/mips64/net/htons.S b/lib/libc/arch/mips64/net/htons.S
new file mode 100644
index 00000000000..ceb537040a0
--- /dev/null
+++ b/lib/libc/arch/mips64/net/htons.S
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: htons.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * netorder = htons(hostorder)
+ * hostorder = ntohs(netorder)
+ */
+ALEAF(ntohs)
+NLEAF(htons)
+ .set reorder
+#ifdef __MIPSEL__
+ srl v0, a0, 8
+ and v0, v0, 0xff
+ sll v1, a0, 8
+ and v1, v1, 0xff00
+ or v0, v0, v1
+#else
+#ifdef __MIPSEB__
+ move v0, a0
+#else
+ ERROR
+#endif
+#endif
+ j ra
+END(htons)
diff --git a/lib/libc/arch/mips64/string/Makefile.inc b/lib/libc/arch/mips64/string/Makefile.inc
new file mode 100644
index 00000000000..1e0e847f1d0
--- /dev/null
+++ b/lib/libc/arch/mips64/string/Makefile.inc
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile.inc,v 1.1 2004/08/11 17:30:59 pefo Exp $
+
+SRCS+= bcmp.S bcopy.S bzero.S ffs.S index.S memchr.c memcmp.c memset.c \
+ rindex.S strcat.c strcmp.S strcpy.c strcspn.c strlcpy.c strlen.S \
+ strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \
+ strspn.c strstr.c swab.c
+LSRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c rindex.c strcmp.c strlen.c
diff --git a/lib/libc/arch/mips64/string/bcmp.S b/lib/libc/arch/mips64/string/bcmp.S
new file mode 100644
index 00000000000..77669da2454
--- /dev/null
+++ b/lib/libc/arch/mips64/string/bcmp.S
@@ -0,0 +1,116 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: bcmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/* bcmp(s1, s2, n) */
+
+LEAF(bcmp)
+ .set noreorder
+ blt a2, 16, small # is it worth any trouble?
+ xor v0, a0, a1 # compare low two bits of addresses
+ and v0, v0, 3
+ subu a3, zero, a1 # compute # bytes to word align address
+ bne v0, zero, unaligned # not possible to align addresses
+ and a3, a3, 3
+
+ beq a3, zero, 1f
+ subu a2, a2, a3 # subtract from remaining count
+ move v0, v1 # init v0,v1 so unmodified bytes match
+ LWHI v0, 0(a0) # read 1, 2, or 3 bytes
+ LWHI v1, 0(a1)
+ addu a1, a1, a3
+ bne v0, v1, nomatch
+ addu a0, a0, a3
+1:
+ and a3, a2, ~3 # compute number of whole words left
+ subu a2, a2, a3 # which has to be >= (16-3) & ~3
+ addu a3, a3, a0 # compute ending address
+2:
+ lw v0, 0(a0) # compare words
+ lw v1, 0(a1)
+ addu a0, a0, 4
+ bne v0, v1, nomatch
+ addu a1, a1, 4
+ bne a0, a3, 2b
+ nop
+ b small # finish remainder
+ nop
+unaligned:
+ beq a3, zero, 2f
+ subu a2, a2, a3 # subtract from remaining count
+ addu a3, a3, a0 # compute ending address
+1:
+ lbu v0, 0(a0) # compare bytes until a1 word aligned
+ lbu v1, 0(a1)
+ addu a0, a0, 1
+ bne v0, v1, nomatch
+ addu a1, a1, 1
+ bne a0, a3, 1b
+ nop
+2:
+ and a3, a2, ~3 # compute number of whole words left
+ subu a2, a2, a3 # which has to be >= (16-3) & ~3
+ addu a3, a3, a0 # compute ending address
+3:
+ LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned
+ LWLO v0, 3(a0)
+ lw v1, 0(a1)
+ addu a0, a0, 4
+ bne v0, v1, nomatch
+ addu a1, a1, 4
+ bne a0, a3, 3b
+ nop
+small:
+ ble a2, zero, match
+ addu a3, a2, a0 # compute ending address
+1:
+ lbu v0, 0(a0)
+ lbu v1, 0(a1)
+ addu a0, a0, 1
+ bne v0, v1, nomatch
+ addu a1, a1, 1
+ bne a0, a3, 1b
+ nop
+match:
+ j ra
+ move v0, zero
+nomatch:
+ j ra
+ li v0, 1
+ .set reorder
+END(bcmp)
diff --git a/lib/libc/arch/mips64/string/bcopy.S b/lib/libc/arch/mips64/string/bcopy.S
new file mode 100644
index 00000000000..8d763e5943a
--- /dev/null
+++ b/lib/libc/arch/mips64/string/bcopy.S
@@ -0,0 +1,123 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: bcopy.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/* bcopy(s1, s2, n) */
+
+
+LEAF(bcopy)
+ .set noreorder
+ addu t0, a0, a2 # t0 = end of s1 region
+ sltu t1, a1, t0
+ sltu t2, a0, a1
+ and t1, t1, t2 # t1 = true if from < to < (from+len)
+ beq t1, zero, forward # non overlapping, do forward copy
+ slt t2, a2, 12 # check for small copy
+
+ ble a2, zero, 2f
+ addu t1, a1, a2 # t1 = end of to region
+1:
+ lb v0, -1(t0) # copy bytes backwards,
+ subu t0, t0, 1 # does not happen often so do slow way
+ subu t1, t1, 1
+ bne t0, a0, 1b
+ sb v0, 0(t1)
+2:
+ j ra
+ nop
+forward:
+ bne t2, zero, smallcpy # do a small bcopy
+ xor v0, a0, a1 # compare low two bits of addresses
+ and v0, v0, 3
+ subu a3, zero, a1 # compute # bytes to word align address
+ beq v0, zero, aligned # addresses can be word aligned
+ and a3, a3, 3
+
+ beq a3, zero, 1f
+ subu a2, a2, a3 # subtract from remaining count
+ LWHI v0, 0(a0) # get next 4 bytes (unaligned)
+ LWLO v0, 3(a0)
+ addu a0, a0, a3
+ SWHI v0, 0(a1) # store 1, 2, or 3 bytes to align a1
+ addu a1, a1, a3
+1:
+ and v0, a2, 3 # compute number of words left
+ subu a3, a2, v0
+ move a2, v0
+ addu a3, a3, a0 # compute ending address
+2:
+ LWHI v0, 0(a0) # copy words a0 unaligned, a1 aligned
+ LWLO v0, 3(a0)
+ addu a0, a0, 4
+ addu a1, a1, 4
+ bne a0, a3, 2b
+ sw v0, -4(a1)
+ b smallcpy
+ nop
+aligned:
+ beq a3, zero, 1f
+ subu a2, a2, a3 # subtract from remaining count
+ LWHI v0, 0(a0) # copy 1, 2, or 3 bytes to align
+ addu a0, a0, a3
+ SWHI v0, 0(a1)
+ addu a1, a1, a3
+1:
+ and v0, a2, 3 # compute number of whole words left
+ subu a3, a2, v0
+ move a2, v0
+ addu a3, a3, a0 # compute ending address
+2:
+ lw v0, 0(a0) # copy words
+ addu a0, a0, 4
+ addu a1, a1, 4
+ bne a0, a3, 2b
+ sw v0, -4(a1)
+smallcpy:
+ ble a2, zero, 2f
+ addu a3, a2, a0 # compute ending address
+1:
+ lbu v0, 0(a0) # copy bytes
+ addu a0, a0, 1
+ addu a1, a1, 1
+ bne a0, a3, 1b
+ sb v0, -1(a1)
+2:
+ j ra
+ nop
+ .set reorder
+END(bcopy)
diff --git a/lib/libc/arch/mips64/string/bzero.S b/lib/libc/arch/mips64/string/bzero.S
new file mode 100644
index 00000000000..ab43507f19c
--- /dev/null
+++ b/lib/libc/arch/mips64/string/bzero.S
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: bzero.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/* bzero(s1, n) */
+
+LEAF(bzero)
+ .set noreorder
+ blt a1, 12, smallclr # small amount to clear?
+ subu a3, zero, a0 # compute # bytes to word align address
+ and a3, a3, 3
+ beq a3, zero, 1f # skip if word aligned
+ subu a1, a1, a3 # subtract from remaining count
+ SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align
+ addu a0, a0, a3
+1:
+ and v0, a1, 3 # compute number of words left
+ subu a3, a1, v0
+ move a1, v0
+ addu a3, a3, a0 # compute ending address
+2:
+ addu a0, a0, 4 # clear words
+ bne a0, a3, 2b # unrolling loop doesn't help
+ sw zero, -4(a0) # since we are limited by memory speed
+smallclr:
+ ble a1, zero, 2f
+ addu a3, a1, a0 # compute ending address
+1:
+ addu a0, a0, 1 # clear bytes
+ bne a0, a3, 1b
+ sb zero, -1(a0)
+2:
+ j ra
+ nop
+END(bzero)
diff --git a/lib/libc/arch/mips64/string/ffs.S b/lib/libc/arch/mips64/string/ffs.S
new file mode 100644
index 00000000000..0c637198b99
--- /dev/null
+++ b/lib/libc/arch/mips64/string/ffs.S
@@ -0,0 +1,53 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: ffs.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/* bit = ffs(value) */
+
+LEAF(ffs)
+ .set reorder
+ move v0, zero
+ beq a0, zero, done
+1:
+ and v1, a0, 1 # bit set?
+ addu v0, v0, 1
+ srl a0, a0, 1
+ beq v1, zero, 1b # no, continue
+done:
+ j ra
+END(ffs)
diff --git a/lib/libc/arch/mips64/string/index.S b/lib/libc/arch/mips64/string/index.S
new file mode 100644
index 00000000000..a90daa35f7c
--- /dev/null
+++ b/lib/libc/arch/mips64/string/index.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: index.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+LEAF(index)
+ .set reorder
+ lbu a2, 0(a0) # get a byte
+ addu a0, a0, 1
+ beq a2, a1, fnd
+ bne a2, zero, _C_LABEL(index)
+notfnd:
+ move v0, zero
+ j ra
+fnd:
+ subu v0, a0, 1
+ j ra
+END(index)
diff --git a/lib/libc/arch/mips64/string/rindex.S b/lib/libc/arch/mips64/string/rindex.S
new file mode 100644
index 00000000000..7eb789a346f
--- /dev/null
+++ b/lib/libc/arch/mips64/string/rindex.S
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: rindex.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+LEAF(rindex)
+ .set reorder
+ move v0, zero # default if not found
+1:
+ lbu a3, 0(a0) # get a byte
+ addu a0, a0, 1
+ bne a3, a1, 2f
+ subu v0, a0, 1 # save address of last match
+2:
+ bne a3, zero, 1b # continue if not end
+ j ra
+END(rindex)
diff --git a/lib/libc/arch/mips64/string/strcmp.S b/lib/libc/arch/mips64/string/strcmp.S
new file mode 100644
index 00000000000..a44d496023b
--- /dev/null
+++ b/lib/libc/arch/mips64/string/strcmp.S
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: strcmp.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+/*
+ * NOTE: this version assumes unsigned chars in order to be "8 bit clean".
+ */
+LEAF(strcmp)
+ .set reorder
+1:
+ lbu t0, 0(a0) # get two bytes and compare them
+ lbu t1, 0(a1)
+ beq t0, zero, LessOrEq # end of first string?
+ bne t0, t1, NotEq
+ lbu t0, 1(a0) # unroll loop
+ lbu t1, 1(a1)
+ add a0, a0, 2
+ beq t0, zero, LessOrEq # end of first string?
+ add a1, a1, 2
+ beq t0, t1, 1b
+NotEq:
+ subu v0, t0, t1
+ j ra
+LessOrEq:
+ subu v0, zero, t1
+ j ra
+END(strcmp)
diff --git a/lib/libc/arch/mips64/string/strlen.S b/lib/libc/arch/mips64/string/strlen.S
new file mode 100644
index 00000000000..4ced4768f80
--- /dev/null
+++ b/lib/libc/arch/mips64/string/strlen.S
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+#if defined(LIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: strlen.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* LIBC_SCCS */
+
+LEAF(strlen)
+ .set reorder
+ addu v1, a0, 1
+1:
+ lb v0, 0(a0) # get byte from string
+ addu a0, a0, 1 # increment pointer
+ bne v0, zero, 1b # continue if not end
+ subu v0, a0, v1 # compute length - 1 for '\0' char
+ j ra
+END(strlen)
diff --git a/lib/libc/arch/mips64/sys/Ovfork.S b/lib/libc/arch/mips64/sys/Ovfork.S
new file mode 100644
index 00000000000..8688afd9794
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/Ovfork.S
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: Ovfork.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+/*
+ * pid = vfork();
+ *
+ * v1 == 0 in parent process, v1 == 1 in child process.
+ * v0 == pid of child in parent, v0 == pid of parent in child.
+ */
+
+SYSLEAF(vfork)
+ .set reorder
+ li v0, SYS_vfork # system call number for vfork
+ syscall
+ beq a3, zero, 1f # jump if no errors
+ la t9, cerror
+ jr t9
+1:
+ beq v1, zero, 2f # parent process ?
+ move v0, zero # return zero in child
+2:
+ j ra
+SYSEND(vfork)
diff --git a/lib/libc/arch/mips64/sys/brk.S b/lib/libc/arch/mips64/sys/brk.S
new file mode 100644
index 00000000000..68ae6837876
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/brk.S
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: brk.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+ .globl minbrk
+ .globl curbrk
+
+ .data
+minbrk: .word _C_LABEL(end)
+ .text
+
+LEAF(brk)
+ .set reorder
+ lw v0, minbrk
+ bltu a0, v0, 1f
+ la t9, _brk
+ jr t9
+1:
+ move a0, v0 # dont allow break < minbrk
+ li v0, SYS_break
+ syscall
+ bne a3, zero, 2f
+ sw a0, curbrk
+ move v0, zero
+ j ra
+2:
+ la t9, _C_LABEL(cerror)
+ jr t9
+END(brk)
+
+LEAF(_brk)
+ .set reorder
+ li v0, SYS_break
+ syscall
+ bne a3, zero, 1f
+ sw a0, curbrk
+ move v0, zero
+ j ra
+1:
+ la t9, _C_LABEL(cerror)
+ jr t9
+END(brk)
diff --git a/lib/libc/arch/mips64/sys/cerror.S b/lib/libc/arch/mips64/sys/cerror.S
new file mode 100644
index 00000000000..394d7e2dada
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/cerror.S
@@ -0,0 +1,47 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: cerror.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+ .globl _C_LABEL(errno)
+LEAF(cerror)
+ .set noreorder
+ sw v0, _C_LABEL(errno)
+ li v0, -1
+ j ra
+ li v1, -1
+END(cerror)
diff --git a/lib/libc/arch/mips64/sys/exect.S b/lib/libc/arch/mips64/sys/exect.S
new file mode 100644
index 00000000000..014b6a98348
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/exect.S
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: exect.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+SYSLEAF(exect)
+ .set reorder
+ li v0, SYS_execve
+ syscall
+ bne a3, zero, 1f
+ j ra
+1:
+ la t9, _C_LABEL(cerror)
+ jr t9
+SYSEND(exect)
diff --git a/lib/libc/arch/mips64/sys/fork.S b/lib/libc/arch/mips64/sys/fork.S
new file mode 100644
index 00000000000..9ade3e1631d
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/fork.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: fork.S,v 1.1 2004/08/11 17:30:59 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+SYSLEAF(fork)
+ .set reorder
+ li v0, SYS_fork # pid = fork()
+ syscall
+ bne a3, zero, 2f
+ beq v1, zero, 1f # v1 == 0 in parent, 1 in child
+ move v0, zero
+1:
+ j ra
+2:
+ la t9, _C_LABEL(cerror)
+ jr t9
+SYSEND(fork)
diff --git a/lib/libc/arch/mips64/sys/rfork.S b/lib/libc/arch/mips64/sys/rfork.S
new file mode 100644
index 00000000000..89aa36b787c
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/rfork.S
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: rfork.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+SYSLEAF(rfork)
+ .set reorder
+ li v0, SYS_rfork # pid = fork()
+ syscall
+ bne a3, zero, 2f
+ beq v1, zero, 1f # v1 == 0 in parent, 1 in child
+ move v0, zero
+1:
+ j ra
+2:
+ la t9, _C_LABEL(cerror)
+ jr t9
+SYSEND(rfork)
diff --git a/lib/libc/arch/mips64/sys/sbrk.S b/lib/libc/arch/mips64/sys/sbrk.S
new file mode 100644
index 00000000000..ed93eea811b
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/sbrk.S
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: sbrk.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+ .globl curbrk
+
+ .data
+curbrk: .word _C_LABEL(end)
+ .text
+
+LEAF(sbrk)
+ .set reorder
+ lw v1, curbrk
+ li v0, SYS_break
+ addu a0, a0, v1 # compute current break
+ syscall
+
+ bne a3, zero, 1f
+ move v0, v1 # return old val of curbrk from above
+ sw a0, curbrk # save current val of curbrk from above
+ j ra
+1:
+ la t9, _C_LABEL(cerror)
+ jr t9
+END(sbrk)
diff --git a/lib/libc/arch/mips64/sys/setlogin.S b/lib/libc/arch/mips64/sys/setlogin.S
new file mode 100644
index 00000000000..74ccd79fe1b
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/setlogin.S
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: setlogin.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+LEAF(setlogin)
+ .set reorder
+ li v0, SYS_setlogin # setlogin(name)
+ syscall
+
+ bne a3, zero, 1f
+ sw zero, _C_LABEL(__logname_valid) # in getlogin()
+ j ra
+1:
+ la t9, _C_LABEL(cerror)
+ jr t9
+END(setlogin)
diff --git a/lib/libc/arch/mips64/sys/sigpending.S b/lib/libc/arch/mips64/sys/sigpending.S
new file mode 100644
index 00000000000..117312df7d5
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/sigpending.S
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: sigpending.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+SYSLEAF(sigpending)
+ .set reorder
+ li v0, SYS_sigpending # setlogin(name)
+ syscall
+ bne a3, zero, 1f
+ sw v0, 0(a0)
+ move v0, zero
+ j ra
+1:
+ la t9, _C_LABEL(cerror)
+ jr t9
+SYSEND(sigpending)
diff --git a/lib/libc/arch/mips64/sys/sigprocmask.S b/lib/libc/arch/mips64/sys/sigprocmask.S
new file mode 100644
index 00000000000..b42bfe33dee
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/sigprocmask.S
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: sigprocmask.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+SYSLEAF(sigprocmask) # sigprocmask(how, new, old) sigset_t *new, *old;
+ .set reorder
+ bne a1, zero, gotptr # if new sigset pointer not null
+ li a0, 1 # how = SIG_BLOCK
+ b doit # mask = zero
+gotptr:
+ lw a1, 0(a1) # indirect to new mask arg
+doit:
+ li v0, SYS_sigprocmask
+ syscall
+ bne a3, zero, err
+ beq a2, zero, out # test if old mask requested
+ sw v0, 0(a2) # store old mask
+out:
+ move v0, zero
+ j ra
+err:
+ la t9, _C_LABEL(cerror)
+ jr t9
+SYSEND(sigprocmask)
diff --git a/lib/libc/arch/mips64/sys/sigreturn.S b/lib/libc/arch/mips64/sys/sigreturn.S
new file mode 100644
index 00000000000..f94c727a4e5
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/sigreturn.S
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: sigreturn.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+/*
+ * We must preserve the state of the registers as the user has set them up.
+ */
+
+RSYSCALL(sigreturn)
diff --git a/lib/libc/arch/mips64/sys/sigsuspend.S b/lib/libc/arch/mips64/sys/sigsuspend.S
new file mode 100644
index 00000000000..2b6ff2f08bf
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/sigsuspend.S
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: sigsuspend.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+SYSLEAF(sigsuspend)
+ .set reorder
+ lw a0, 0(a0) # indirect to mask arg
+ li v0, SYS_sigsuspend
+ syscall
+ bne a3, zero, 1f
+ move v0, zero # should not happen
+ j ra
+1:
+ la t9, _C_LABEL(cerror)
+ jr t9
+SYSEND(sigsuspend)
diff --git a/lib/libc/arch/mips64/sys/syscall.S b/lib/libc/arch/mips64/sys/syscall.S
new file mode 100644
index 00000000000..267dac8753b
--- /dev/null
+++ b/lib/libc/arch/mips64/sys/syscall.S
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "SYS.h"
+
+#if defined(SYSLIBC_SCCS)
+ .text
+ .asciz "$OpenBSD: syscall.S,v 1.1 2004/08/11 17:31:00 pefo Exp $"
+#endif /* SYSLIBC_SCCS */
+
+#define SYS_syscall 0
+
+
+RSYSCALL(syscall)