Add mips support libc from the mips2-jnpr branch of perforce.
This commit is contained in:
parent
cea060d682
commit
87785b8e3a
9
lib/libc/mips/Makefile.inc
Normal file
9
lib/libc/mips/Makefile.inc
Normal file
@ -0,0 +1,9 @@
|
||||
# $NetBSD: Makefile.inc,v 1.7 2005/09/17 11:49:39 tsutsui Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SOFTFLOAT_BITS=32
|
||||
|
||||
CFLAGS+=-DSOFTFLOAT
|
||||
|
||||
MDSRCS+= machdep_ldisd.c
|
||||
SYM_MAPS+= ${.CURDIR}/mips/Symbol.map
|
129
lib/libc/mips/SYS.h
Normal file
129
lib/libc/mips/SYS.h
Normal file
@ -0,0 +1,129 @@
|
||||
/* $NetBSD: SYS.h,v 1.18 2003/10/29 12:28:33 pooka Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 Jonathan Stone
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Jonathan Stone for
|
||||
* the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* 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.
|
||||
*
|
||||
* from: @(#)SYS.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
/*
|
||||
* If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops.
|
||||
*
|
||||
* i) Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after.
|
||||
* ii) Do interprocedure jumps indirectly via t9, with the side-effect of
|
||||
* preserving the callee's entry address in t9.
|
||||
*/
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
# define PIC_PROLOGUE(x,sr) .set noreorder; .cpload sr; .set reorder
|
||||
# define PIC_CALL(l,sr) la sr, _C_LABEL(l); jr sr
|
||||
#else
|
||||
# define PIC_PROLOGUE(x,sr)
|
||||
# define PIC_CALL(l,sr) j _C_LABEL(l)
|
||||
#endif
|
||||
|
||||
# define SYSTRAP(x) li v0, SYS_ ## x; syscall;
|
||||
|
||||
/*
|
||||
* Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id)
|
||||
*/
|
||||
#define RSYSCALL_NOERROR(x) \
|
||||
PSEUDO_NOERROR(x)
|
||||
|
||||
/*
|
||||
* Do a normal syscall.
|
||||
*/
|
||||
#define RSYSCALL(x) \
|
||||
PSEUDO(x)
|
||||
|
||||
/*
|
||||
* Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint
|
||||
* and syscall name are not the same.
|
||||
*/
|
||||
#define PSEUDO_NOERROR(x) \
|
||||
LEAF(__sys_ ## x); \
|
||||
.weak _C_LABEL(x); \
|
||||
_C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \
|
||||
.weak _C_LABEL(__CONCAT(_,x)); \
|
||||
_C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \
|
||||
SYSTRAP(x); \
|
||||
j ra; \
|
||||
END(__sys_ ## x)
|
||||
|
||||
#define PSEUDO(x) \
|
||||
LEAF(__sys_ ## x); \
|
||||
.weak _C_LABEL(x); \
|
||||
_C_LABEL(x) = _C_LABEL(__CONCAT(__sys_,x)); \
|
||||
.weak _C_LABEL(__CONCAT(_,x)); \
|
||||
_C_LABEL(__CONCAT(_,x)) = _C_LABEL(__CONCAT(__sys_,x)); \
|
||||
PIC_PROLOGUE(x,t9); \
|
||||
SYSTRAP(x); \
|
||||
bne a3,zero,err; \
|
||||
j ra; \
|
||||
err: \
|
||||
PIC_CALL(__cerror,t9); \
|
||||
END(__sys_ ## x)
|
68
lib/libc/mips/Symbol.map
Normal file
68
lib/libc/mips/Symbol.map
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* This only needs to contain symbols that are not listed in
|
||||
* symbol maps from other parts of libc (i.e., not found in
|
||||
* stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...).
|
||||
*/
|
||||
FBSD_1.0 {
|
||||
/* PSEUDO syscalls */
|
||||
_exit;
|
||||
|
||||
_setjmp;
|
||||
_longjmp;
|
||||
alloca;
|
||||
fabs;
|
||||
__infinity;
|
||||
__nan;
|
||||
makecontext;
|
||||
modf;
|
||||
setjmp;
|
||||
longjmp;
|
||||
sigsetjmp;
|
||||
siglongjmp;
|
||||
htonl;
|
||||
__htonl;
|
||||
htons;
|
||||
__htons;
|
||||
ntohl;
|
||||
__ntohl;
|
||||
ntohs;
|
||||
__ntohs;
|
||||
vfork;
|
||||
brk;
|
||||
cerror; /* XXX - Should this be .cerror (see sys/cerror.S)? */
|
||||
fork;
|
||||
sbrk;
|
||||
};
|
||||
|
||||
FBSDprivate_1.0 {
|
||||
/* PSEUDO syscalls */
|
||||
__sys_getlogin;
|
||||
_getlogin;
|
||||
__sys_exit;
|
||||
|
||||
_set_tp;
|
||||
___longjmp;
|
||||
__umodsi3;
|
||||
__modsi3;
|
||||
__udivsi3;
|
||||
__divsi3;
|
||||
__makecontext;
|
||||
__longjmp;
|
||||
signalcontext;
|
||||
_signalcontext;
|
||||
__siglongjmp;
|
||||
__sys_vfork;
|
||||
_vfork;
|
||||
_brk;
|
||||
end; /* XXX - Should this be _end (see sys/brk.S)? */
|
||||
curbrk;
|
||||
minbrk;
|
||||
_brk;
|
||||
__sys_fork;
|
||||
_fork;
|
||||
_sbrk;
|
||||
};
|
56
lib/libc/mips/_fpmath.h
Normal file
56
lib/libc/mips/_fpmath.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
union IEEEl2bits {
|
||||
long double e;
|
||||
struct {
|
||||
#ifndef __MIPSEB__
|
||||
unsigned int manl :32;
|
||||
unsigned int manh :20;
|
||||
unsigned int exp :11;
|
||||
unsigned int sign :1;
|
||||
#else
|
||||
unsigned int sign :1;
|
||||
unsigned int exp :11;
|
||||
unsigned int manh :20;
|
||||
unsigned int manl :32;
|
||||
#endif
|
||||
} bits;
|
||||
};
|
||||
|
||||
#define LDBL_NBIT 0
|
||||
#define mask_nbit_l(u) ((void)0)
|
||||
#define LDBL_IMPLICIT_NBIT
|
||||
|
||||
#define LDBL_MANH_SIZE 20
|
||||
#define LDBL_MANL_SIZE 32
|
||||
|
||||
#define LDBL_TO_ARRAY32(u, a) do { \
|
||||
(a)[0] = (uint32_t)(u).bits.manl; \
|
||||
(a)[1] = (uint32_t)(u).bits.manh; \
|
||||
} while(0)
|
29
lib/libc/mips/arith.h
Normal file
29
lib/libc/mips/arith.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* MD header for contrib/gdtoa
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: The definitions in this file must be correct or strtod(3) and
|
||||
* floating point formats in printf(3) will break! The file can be
|
||||
* generated by running contrib/gdtoa/arithchk.c on the target
|
||||
* architecture. See contrib/gdtoa/gdtoaimp.h for details.
|
||||
*/
|
||||
#include <machine/endian.h>
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define IEEE_MC68k
|
||||
#define Arith_Kind_ASL 2
|
||||
#define Double_Align
|
||||
#else
|
||||
/* TODO: Generate these values on a LE machine */
|
||||
/* Current values were stolen from ia64 except the
|
||||
* Xpointer define.
|
||||
*/
|
||||
#define IEEE_8087
|
||||
#define Arith_Kind_ASL 1
|
||||
#define Long int
|
||||
#define Intcast (int)(long)
|
||||
#define Double_Align
|
||||
#endif
|
48
lib/libc/mips/gd_qnan.h
Normal file
48
lib/libc/mips/gd_qnan.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* MD header for contrib/gdtoa
|
||||
*
|
||||
* This file can be generated by compiling and running contrib/gdtoa/qnan.c
|
||||
* on the target architecture after arith.h has been generated.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/* These values were gained on a running
|
||||
* Octeon in Big Endian order. They were gotten
|
||||
* by running ./qnan after arithchk was ran and
|
||||
* got us the proper values for arith.h.
|
||||
*/
|
||||
#define f_QNAN 0x7f900000
|
||||
#define d_QNAN0 0x7ff80000
|
||||
#define d_QNAN1 0x0
|
||||
#define ld_QNAN0 0x7ff80000
|
||||
#define ld_QNAN1 0x0
|
||||
#define ld_QNAN2 0x0
|
||||
#define ld_QNAN3 0x0
|
||||
#define ldus_QNAN0 0x7ff8
|
||||
#define ldus_QNAN1 0x0
|
||||
#define ldus_QNAN2 0x0
|
||||
#define ldus_QNAN3 0x0
|
||||
#define ldus_QNAN4 0x0
|
||||
#else
|
||||
/* FIX FIX, need to run this on a Little Endian
|
||||
* machine and get the proper values, these here
|
||||
* were stolen fromn i386/gd_qnan.h
|
||||
*/
|
||||
#define f_QNAN 0x7fc00000
|
||||
#define d_QNAN0 0x0
|
||||
#define d_QNAN1 0x7ff80000
|
||||
#define ld_QNAN0 0x0
|
||||
#define ld_QNAN1 0xc0000000
|
||||
#define ld_QNAN2 0x7fff
|
||||
#define ld_QNAN3 0x0
|
||||
#define ldus_QNAN0 0x0
|
||||
#define ldus_QNAN1 0x0
|
||||
#define ldus_QNAN2 0x0
|
||||
#define ldus_QNAN3 0xc000
|
||||
#define ldus_QNAN4 0x7fff
|
||||
#endif
|
4
lib/libc/mips/gdtoa/Makefile.inc
Normal file
4
lib/libc/mips/gdtoa/Makefile.inc
Normal file
@ -0,0 +1,4 @@
|
||||
# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= strtof.c
|
10
lib/libc/mips/gdtoa/arith.h
Normal file
10
lib/libc/mips/gdtoa/arith.h
Normal file
@ -0,0 +1,10 @@
|
||||
/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#include <machine/endian.h>
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
#define IEEE_BIG_ENDIAN
|
||||
#else
|
||||
#define IEEE_LITTLE_ENDIAN
|
||||
#endif
|
9
lib/libc/mips/gen/Makefile.inc
Normal file
9
lib/libc/mips/gen/Makefile.inc
Normal file
@ -0,0 +1,9 @@
|
||||
# $NetBSD: Makefile.inc,v 1.27 2005/10/07 17:16:40 tsutsui Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= infinity.c fabs.c ldexp.c modf.c
|
||||
|
||||
# SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
|
||||
# fpsetround.c fpsetsticky.c
|
||||
|
||||
SRCS+= _set_tp.c _setjmp.S makecontext.c setjmp.S signalcontext.c sigsetjmp.S
|
35
lib/libc/mips/gen/_set_tp.c
Normal file
35
lib/libc/mips/gen/_set_tp.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 Doug Rabson
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void
|
||||
_set_tp(void *tp)
|
||||
{
|
||||
}
|
117
lib/libc/mips/gen/_setjmp.S
Normal file
117
lib/libc/mips/gen/_setjmp.S
Normal file
@ -0,0 +1,117 @@
|
||||
/* $NetBSD: _setjmp.S,v 1.20 2005/10/07 17:16:40 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include <machine/regnum.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)_setjmp.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: _setjmp.S,v 1.20 2005/10/07 17:16:40 tsutsui Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/*
|
||||
* C library -- _setjmp, _longjmp
|
||||
*
|
||||
* _longjmp(a,v)
|
||||
* will generate a "return(v)" from
|
||||
* the last call to
|
||||
* _setjmp(a)
|
||||
* by restoring registers from the stack,
|
||||
* The previous signal state is NOT restored.
|
||||
*/
|
||||
|
||||
|
||||
LEAF(_setjmp)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
subu sp, sp, CALLFRAME_SIZ # allocate stack frame
|
||||
.cprestore 16
|
||||
#endif
|
||||
li v0, _JB_MAGIC__SETJMP
|
||||
sw v0, (_JB_MAGIC * SZREG)(a0)
|
||||
sw ra, (_JB_REG_RA * SZREG)(a0)
|
||||
sw s0, (_JB_REG_S0 * SZREG)(a0)
|
||||
sw s1, (_JB_REG_S1 * SZREG)(a0)
|
||||
sw s2, (_JB_REG_S2 * SZREG)(a0)
|
||||
sw s3, (_JB_REG_S3 * SZREG)(a0)
|
||||
sw s4, (_JB_REG_S4 * SZREG)(a0)
|
||||
sw s5, (_JB_REG_S5 * SZREG)(a0)
|
||||
sw s6, (_JB_REG_S6 * SZREG)(a0)
|
||||
sw s7, (_JB_REG_S7 * SZREG)(a0)
|
||||
sw s8, (_JB_REG_S8 * SZREG)(a0)
|
||||
#ifdef __ABICALLS__
|
||||
addu sp, sp, CALLFRAME_SIZ # un-allocate the stack frame
|
||||
#endif
|
||||
sw sp, (_JB_REG_SP * SZREG)(a0)
|
||||
j ra
|
||||
move v0, zero
|
||||
END(_setjmp)
|
||||
|
||||
LEAF(_longjmp)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
subu sp, sp, CALLFRAME_SIZ # allocate stack frame
|
||||
.cprestore 16
|
||||
#endif
|
||||
lw v0, (_JB_MAGIC * SZREG)(a0)
|
||||
lw ra, (_JB_REG_RA * SZREG)(a0)
|
||||
li t0, _JB_MAGIC__SETJMP
|
||||
bne v0, t0, botch # jump if error
|
||||
lw s0, (_JB_REG_S0 * SZREG)(a0)
|
||||
lw s1, (_JB_REG_S1 * SZREG)(a0)
|
||||
lw s2, (_JB_REG_S2 * SZREG)(a0)
|
||||
lw s3, (_JB_REG_S3 * SZREG)(a0)
|
||||
lw s4, (_JB_REG_S4 * SZREG)(a0)
|
||||
lw s5, (_JB_REG_S5 * SZREG)(a0)
|
||||
lw s6, (_JB_REG_S6 * SZREG)(a0)
|
||||
lw s7, (_JB_REG_S7 * SZREG)(a0)
|
||||
lw sp, (_JB_REG_SP * SZREG)(a0)
|
||||
lw s8, (_JB_REG_S8 * SZREG)(a0)
|
||||
|
||||
j ra
|
||||
move v0, a1
|
||||
|
||||
botch:
|
||||
jal _C_LABEL(longjmperror)
|
||||
nop
|
||||
jal _C_LABEL(abort)
|
||||
nop
|
||||
END(_longjmp)
|
58
lib/libc/mips/gen/fabs.S
Normal file
58
lib/libc/mips/gen/fabs.S
Normal file
@ -0,0 +1,58 @@
|
||||
/* $NetBSD: fabs.S,v 1.7 2003/08/07 16:42:15 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)fabs.s 8.1 (Berkeley) 2/16/94")
|
||||
ASMSTR("$NetBSD: fabs.S,v 1.7 2003/08/07 16:42:15 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
.set noreorder
|
||||
|
||||
/*
|
||||
* fabs(x)
|
||||
* double x;
|
||||
*
|
||||
* Return absolute value of x.
|
||||
*/
|
||||
LEAF(fabs)
|
||||
j ra
|
||||
abs.d $f0, $f12 # compute absolute value of x
|
||||
END(fabs)
|
46
lib/libc/mips/gen/fabs.c
Normal file
46
lib/libc/mips/gen/fabs.c
Normal file
@ -0,0 +1,46 @@
|
||||
/* $NetBSD: fabs.c,v 1.2 2002/05/26 11:48:01 wiz Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Mark Brinicombe
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Mark Brinicombe
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* fabs(x) returns the absolute value of x.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
double
|
||||
fabs(double x)
|
||||
{
|
||||
if (x < 0)
|
||||
x = -x;
|
||||
return(x);
|
||||
}
|
30
lib/libc/mips/gen/flt_rounds.c
Normal file
30
lib/libc/mips/gen/flt_rounds.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* $NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/float.h>
|
||||
|
||||
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));
|
||||
return map[x & 0x03];
|
||||
}
|
29
lib/libc/mips/gen/fpgetmask.c
Normal file
29
lib/libc/mips/gen/fpgetmask.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* $NetBSD: fpgetmask.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: fpgetmask.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fpgetmask,_fpgetmask)
|
||||
#endif
|
||||
|
||||
fp_except_t
|
||||
fpgetmask()
|
||||
{
|
||||
int x;
|
||||
|
||||
__asm("cfc1 %0,$31" : "=r" (x));
|
||||
return (x >> 7) & 0x1f;
|
||||
}
|
29
lib/libc/mips/gen/fpgetround.c
Normal file
29
lib/libc/mips/gen/fpgetround.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* $NetBSD: fpgetround.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: fpgetround.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fpgetround,_fpgetround)
|
||||
#endif
|
||||
|
||||
fp_rnd_t
|
||||
fpgetround()
|
||||
{
|
||||
int x;
|
||||
|
||||
__asm("cfc1 %0,$31" : "=r" (x));
|
||||
return x & 0x03;
|
||||
}
|
29
lib/libc/mips/gen/fpgetsticky.c
Normal file
29
lib/libc/mips/gen/fpgetsticky.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* $NetBSD: fpgetsticky.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: fpgetsticky.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fpgetsticky,_fpgetsticky)
|
||||
#endif
|
||||
|
||||
fp_except_t
|
||||
fpgetsticky()
|
||||
{
|
||||
int x;
|
||||
|
||||
__asm("cfc1 %0,$31" : "=r" (x));
|
||||
return (x >> 2) & 0x1f;
|
||||
}
|
38
lib/libc/mips/gen/fpsetmask.c
Normal file
38
lib/libc/mips/gen/fpsetmask.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* $NetBSD: fpsetmask.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: fpsetmask.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fpsetmask,_fpsetmask)
|
||||
#endif
|
||||
|
||||
fp_except_t
|
||||
fpsetmask(mask)
|
||||
fp_except_t mask;
|
||||
{
|
||||
fp_except_t old;
|
||||
fp_except_t 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;
|
||||
}
|
37
lib/libc/mips/gen/fpsetround.c
Normal file
37
lib/libc/mips/gen/fpsetround.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* $NetBSD: fpsetround.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: fpsetround.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fpsetround,_fpsetround)
|
||||
#endif
|
||||
|
||||
fp_rnd_t
|
||||
fpsetround(fp_rnd_t rnd_dir)
|
||||
{
|
||||
fp_rnd_t old;
|
||||
fp_rnd_t new;
|
||||
|
||||
__asm("cfc1 %0,$31" : "=r" (old));
|
||||
|
||||
new = old;
|
||||
new &= ~0x03;
|
||||
new |= (rnd_dir & 0x03);
|
||||
|
||||
__asm("ctc1 %0,$31" : : "r" (new));
|
||||
|
||||
return old & 0x03;
|
||||
}
|
38
lib/libc/mips/gen/fpsetsticky.c
Normal file
38
lib/libc/mips/gen/fpsetsticky.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* $NetBSD: fpsetsticky.c,v 1.5 2005/12/24 23:10:08 perry Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin, Apr 11, 1995
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: fpsetsticky.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <ieeefp.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(fpsetsticky,_fpsetsticky)
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
26
lib/libc/mips/gen/infinity.c
Normal file
26
lib/libc/mips/gen/infinity.c
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* infinity.c
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* bytes for +Infinity on a 387 */
|
||||
const union __infinity_un __infinity = {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
{ 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
|
||||
#else
|
||||
{ 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
|
||||
#endif
|
||||
};
|
||||
|
||||
/* bytes for NaN */
|
||||
const union __nan_un __nan = {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
{0x7f, 0xa0, 0, 0}
|
||||
#else
|
||||
{ 0, 0, 0xa0, 0x7f }
|
||||
#endif
|
||||
};
|
219
lib/libc/mips/gen/ldexp.S
Normal file
219
lib/libc/mips/gen/ldexp.S
Normal file
@ -0,0 +1,219 @@
|
||||
/* $NetBSD: ldexp.S,v 1.8 2003/08/07 16:42:15 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)ldexp.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: ldexp.S,v 1.8 2003/08/07 16:42:15 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
#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)
|
||||
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 ta0, v0, 16
|
||||
bne ta0, zero, 1f
|
||||
addu t9, 16
|
||||
sll v0, 16
|
||||
1:
|
||||
srl ta0, v0, 24
|
||||
bne ta0, zero, 1f
|
||||
addu t9, 8
|
||||
sll v0, 8
|
||||
1:
|
||||
srl ta0, v0, 28
|
||||
bne ta0, zero, 1f
|
||||
addu t9, 4
|
||||
sll v0, 4
|
||||
1:
|
||||
srl ta0, v0, 30
|
||||
bne ta0, zero, 1f
|
||||
addu t9, 2
|
||||
sll v0, 2
|
||||
1:
|
||||
srl ta0, v0, 31
|
||||
bne ta0, 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 ta0, t3, v0
|
||||
or t2, t2, ta0
|
||||
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 ta0, 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, ta0
|
||||
srl t2, t2, t1
|
||||
bge t8, zero, 1f # does result need to be rounded?
|
||||
addu t3, t3, 1 # round result
|
||||
sltu ta0, t3, 1
|
||||
sll t8, t8, 1
|
||||
addu t2, t2, ta0
|
||||
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 ta0, t3, 1
|
||||
sll t8, t8, 1
|
||||
mtc1 ta0, $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)
|
110
lib/libc/mips/gen/longjmp.c
Normal file
110
lib/libc/mips/gen/longjmp.c
Normal file
@ -0,0 +1,110 @@
|
||||
/* $NetBSD: longjmp.c,v 1.1 2005/09/17 11:49:39 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christian Limpach and Matt Thomas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
#include <ucontext.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <machine/regnum.h>
|
||||
|
||||
void
|
||||
__longjmp14(jmp_buf env, int val)
|
||||
{
|
||||
struct sigcontext *sc = (void *)env;
|
||||
ucontext_t uc;
|
||||
|
||||
/* Ensure non-zero SP and sigcontext magic number is present */
|
||||
if (sc->sc_regs[_R_SP] == 0 || sc->sc_regs[_R_ZERO] != 0xACEDBADE)
|
||||
goto err;
|
||||
|
||||
/* Ensure non-zero return value */
|
||||
if (val == 0)
|
||||
val = 1;
|
||||
|
||||
/*
|
||||
* Set _UC_{SET,CLR}STACK according to SS_ONSTACK.
|
||||
*
|
||||
* Restore the signal mask with sigprocmask() instead of _UC_SIGMASK,
|
||||
* since libpthread may want to interpose on signal handling.
|
||||
*/
|
||||
uc.uc_flags = _UC_CPU | (sc->sc_onstack ? _UC_SETSTACK : _UC_CLRSTACK);
|
||||
|
||||
sigprocmask(SIG_SETMASK, &sc->sc_mask, NULL);
|
||||
|
||||
/* Clear uc_link */
|
||||
uc.uc_link = 0;
|
||||
|
||||
/* Save return value in context */
|
||||
uc.uc_mcontext.__gregs[_R_V0] = val;
|
||||
|
||||
/* Copy saved registers */
|
||||
uc.uc_mcontext.__gregs[_REG_S0] = sc->sc_regs[_R_S0];
|
||||
uc.uc_mcontext.__gregs[_REG_S1] = sc->sc_regs[_R_S1];
|
||||
uc.uc_mcontext.__gregs[_REG_S2] = sc->sc_regs[_R_S2];
|
||||
uc.uc_mcontext.__gregs[_REG_S3] = sc->sc_regs[_R_S3];
|
||||
uc.uc_mcontext.__gregs[_REG_S4] = sc->sc_regs[_R_S4];
|
||||
uc.uc_mcontext.__gregs[_REG_S5] = sc->sc_regs[_R_S5];
|
||||
uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[_R_S6];
|
||||
uc.uc_mcontext.__gregs[_REG_S7] = sc->sc_regs[_R_S7];
|
||||
uc.uc_mcontext.__gregs[_REG_S8] = sc->sc_regs[_R_S8];
|
||||
uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_regs[_R_SP];
|
||||
uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[_R_RA];
|
||||
uc.uc_mcontext.__gregs[_REG_EPC] = sc->sc_pc;
|
||||
|
||||
/* Copy FP state */
|
||||
if (sc->sc_fpused) {
|
||||
/* FP saved regs are $f20 .. $f31 */
|
||||
memcpy(&uc.uc_mcontext.__fpregs.__fp_r.__fp_regs[20],
|
||||
&sc->sc_fpregs[20], 32 - 20);
|
||||
uc.uc_mcontext.__fpregs.__fp_csr =
|
||||
sc->sc_fpregs[_R_FSR - _FPBASE];
|
||||
/* XXX sc_fp_control */
|
||||
uc.uc_flags |= _UC_FPU;
|
||||
}
|
||||
|
||||
setcontext(&uc);
|
||||
err:
|
||||
longjmperror();
|
||||
abort();
|
||||
/* NOTREACHED */
|
||||
}
|
86
lib/libc/mips/gen/makecontext.c
Normal file
86
lib/libc/mips/gen/makecontext.c
Normal file
@ -0,0 +1,86 @@
|
||||
/* $NetBSD: makecontext.c,v 1.3 2003/01/19 08:53:36 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus Klein.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: makecontext.c,v 1.3 2003/01/19 08:53:36 matt Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ucontext.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void
|
||||
makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
|
||||
{
|
||||
/* XXXMIPS: Implement me */
|
||||
#if 0
|
||||
__greg_t *gr = ucp->uc_mcontext.__gregs;
|
||||
uintptr_t *sp;
|
||||
int i;
|
||||
va_list ap;
|
||||
|
||||
void __resumecontext(void);
|
||||
|
||||
/* LINTED uintptr_t is safe */
|
||||
sp = (uintptr_t *)
|
||||
((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
|
||||
/* LINTED uintptr_t is safe */
|
||||
sp -= (argc >= 4 ? argc : 4); /* Make room for >=4 arguments. */
|
||||
sp = (uintptr_t *)
|
||||
((uintptr_t)sp & ~0x7); /* Align on double-word boundary. */
|
||||
|
||||
gr[_REG_SP] = (__greg_t)sp;
|
||||
gr[_REG_RA] = (__greg_t)__resumecontext;
|
||||
gr[_REG_T9] = (__greg_t)func; /* required for .abicalls */
|
||||
gr[_REG_EPC] = (__greg_t)func;
|
||||
|
||||
/* Construct argument list. */
|
||||
va_start(ap, argc);
|
||||
/* Up to the first four arguments are passed in $a0-3. */
|
||||
for (i = 0; i < argc && i < 4; i++)
|
||||
/* LINTED uintptr_t is safe */
|
||||
gr[_REG_A0 + i] = va_arg(ap, uintptr_t);
|
||||
/* Pass remaining arguments on the stack above the $a0-3 gap. */
|
||||
for (sp += 4; i < argc; i++)
|
||||
/* LINTED uintptr_t is safe */
|
||||
*sp++ = va_arg(ap, uintptr_t);
|
||||
va_end(ap);
|
||||
#endif
|
||||
}
|
82
lib/libc/mips/gen/modf.S
Normal file
82
lib/libc/mips/gen/modf.S
Normal file
@ -0,0 +1,82 @@
|
||||
/* $NetBSD: modf.S,v 1.10 2003/08/07 16:42:15 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)modf.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: modf.S,v 1.10 2003/08/07 16:42:15 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/*
|
||||
* double modf(val, iptr)
|
||||
* double val, *iptr;
|
||||
* returns: xxx and n (in *iptr) where val == n.xxx
|
||||
*/
|
||||
LEAF(modf)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
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
|
||||
s.d $f0, 0(a2) # save the integer part
|
||||
sub.d $f0, $f12, $f0 # subtract val - integer part
|
||||
j ra
|
||||
END(modf)
|
107
lib/libc/mips/gen/modf.c
Normal file
107
lib/libc/mips/gen/modf.c
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and
|
||||
* its documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
||||
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <machine/ieee.h>
|
||||
|
||||
/*
|
||||
* double modf(double val, double *iptr)
|
||||
* returns: f and i such that |f| < 1.0, (f + i) = val, and
|
||||
* sign(f) == sign(i) == sign(val).
|
||||
*
|
||||
* Beware signedness when doing subtraction, and also operand size!
|
||||
*/
|
||||
double
|
||||
modf(val, iptr)
|
||||
double val, *iptr;
|
||||
{
|
||||
union doub {
|
||||
double v;
|
||||
struct ieee_double s;
|
||||
} u, v;
|
||||
u_int64_t frac;
|
||||
|
||||
/*
|
||||
* If input is Inf or NaN, return it and leave i alone.
|
||||
*/
|
||||
u.v = val;
|
||||
if (u.s.dbl_exp == DBL_EXP_INFNAN)
|
||||
return (u.v);
|
||||
|
||||
/*
|
||||
* If input can't have a fractional part, return
|
||||
* (appropriately signed) zero, and make i be the input.
|
||||
*/
|
||||
if ((int)u.s.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) {
|
||||
*iptr = u.v;
|
||||
v.v = 0.0;
|
||||
v.s.dbl_sign = u.s.dbl_sign;
|
||||
return (v.v);
|
||||
}
|
||||
|
||||
/*
|
||||
* If |input| < 1.0, return it, and set i to the appropriately
|
||||
* signed zero.
|
||||
*/
|
||||
if (u.s.dbl_exp < DBL_EXP_BIAS) {
|
||||
v.v = 0.0;
|
||||
v.s.dbl_sign = u.s.dbl_sign;
|
||||
*iptr = v.v;
|
||||
return (u.v);
|
||||
}
|
||||
|
||||
/*
|
||||
* There can be a fractional part of the input.
|
||||
* If you look at the math involved for a few seconds, it's
|
||||
* plain to see that the integral part is the input, with the
|
||||
* low (DBL_FRACBITS - (exponent - DBL_EXP_BIAS)) bits zeroed,
|
||||
* the the fractional part is the part with the rest of the
|
||||
* bits zeroed. Just zeroing the high bits to get the
|
||||
* fractional part would yield a fraction in need of
|
||||
* normalization. Therefore, we take the easy way out, and
|
||||
* just use subtraction to get the fractional part.
|
||||
*/
|
||||
v.v = u.v;
|
||||
/* Zero the low bits of the fraction, the sleazy way. */
|
||||
frac = ((u_int64_t)v.s.dbl_frach << 32) + v.s.dbl_fracl;
|
||||
frac >>= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
|
||||
frac <<= DBL_FRACBITS - (u.s.dbl_exp - DBL_EXP_BIAS);
|
||||
v.s.dbl_fracl = frac & 0xffffffff;
|
||||
v.s.dbl_frach = frac >> 32;
|
||||
*iptr = v.v;
|
||||
|
||||
u.v -= v.v;
|
||||
u.s.dbl_sign = v.s.dbl_sign;
|
||||
return (u.v);
|
||||
}
|
160
lib/libc/mips/gen/setjmp.S
Normal file
160
lib/libc/mips/gen/setjmp.S
Normal file
@ -0,0 +1,160 @@
|
||||
/* $NetBSD: setjmp.S,v 1.17 2005/09/17 11:49:39 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include <machine/regnum.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: setjmp.S,v 1.17 2005/09/17 11:49:39 tsutsui Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/*
|
||||
* C library -- setjmp, longjmp
|
||||
*
|
||||
* longjmp(a,v)
|
||||
* will generate a "return(v)" from
|
||||
* the last call to
|
||||
* setjmp(a)
|
||||
* by restoring registers from the stack,
|
||||
* and a struct sigcontext, see <signal.h>
|
||||
*/
|
||||
|
||||
#define SETJMP_FRAME_SIZE (CALLFRAME_SIZ + (SZREG * 2))
|
||||
|
||||
|
||||
NESTED(setjmp, SETJMP_FRAME_SIZE, ra)
|
||||
.mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
|
||||
.set noreorder
|
||||
#ifdef __ABICALLS__
|
||||
.cpload t9
|
||||
#endif
|
||||
subu sp, sp, SETJMP_FRAME_SIZE # allocate stack frame
|
||||
#ifdef __ABICALLS__
|
||||
.cprestore 16
|
||||
#endif
|
||||
sw ra, CALLFRAME_RA(sp) # save RA
|
||||
sw a0, CALLFRAME_SIZ(sp) # store env
|
||||
|
||||
/* Get the signal mask. */
|
||||
addu a2, a0, _JB_SIGMASK * SZREG # &oenv
|
||||
li a0, 1 # SIG_SETBLOCK
|
||||
move a1, zero # &env == 0
|
||||
la t9, _C_LABEL(sigprocmask) # get current signal mask
|
||||
jal t9
|
||||
nop
|
||||
|
||||
lw a0, CALLFRAME_SIZ(sp) # restore env pointer
|
||||
lw ra, CALLFRAME_RA(sp) # restore RA
|
||||
addu sp, sp, SETJMP_FRAME_SIZE # pop stack frame
|
||||
|
||||
li v0, _JB_MAGIC_SETJMP
|
||||
sw v0, (_JB_MAGIC * SZREG)(a0)
|
||||
sw ra, (_JB_REG_RA * SZREG)(a0)
|
||||
sw s0, (_JB_REG_S0 * SZREG)(a0)
|
||||
sw s1, (_JB_REG_S1 * SZREG)(a0)
|
||||
sw s2, (_JB_REG_S2 * SZREG)(a0)
|
||||
sw s3, (_JB_REG_S3 * SZREG)(a0)
|
||||
sw s4, (_JB_REG_S4 * SZREG)(a0)
|
||||
sw s5, (_JB_REG_S5 * SZREG)(a0)
|
||||
sw s6, (_JB_REG_S6 * SZREG)(a0)
|
||||
sw s7, (_JB_REG_S7 * SZREG)(a0)
|
||||
sw sp, (_JB_REG_SP * SZREG)(a0)
|
||||
sw s8, (_JB_REG_S8 * SZREG)(a0)
|
||||
|
||||
move v0, zero
|
||||
j ra
|
||||
END(setjmp)
|
||||
|
||||
#define LONGJMP_FRAME_SIZE (CALLFRAME_SIZ + (SZREG * 2))
|
||||
|
||||
NESTED(longjmp, LONGJMP_FRAME_SIZE, ra)
|
||||
.mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
|
||||
.set noreorder
|
||||
#ifdef __ABICALLS__
|
||||
.cpload t9
|
||||
#endif
|
||||
subu sp, sp, LONGJMP_FRAME_SIZE # allocate stack frame
|
||||
#ifdef __ABICALLS__
|
||||
.cprestore 16
|
||||
#endif
|
||||
sw ra, CALLFRAME_RA(sp) # save RA
|
||||
lw v0, (_JB_MAGIC * SZREG)(a0)
|
||||
li t0, _JB_MAGIC_SETJMP
|
||||
bne v0, t0, botch # jump if error
|
||||
nop
|
||||
|
||||
sw a0, CALLFRAME_SIZ(sp) # save env
|
||||
sw a1, (CALLFRAME_SIZ + SZREG)(sp) # save return value
|
||||
|
||||
# set sigmask
|
||||
addu a1, a0, _JB_SIGMASK * SZREG # &set
|
||||
move a2, zero # &oset == NULL
|
||||
li a0, 3 # SIG_SETMASK
|
||||
la t9,_C_LABEL(sigprocmask) # set current signal mask
|
||||
jal t9
|
||||
nop
|
||||
|
||||
lw a0, CALLFRAME_SIZ(sp) # restore env
|
||||
lw a1, (CALLFRAME_SIZ + SZREG)(sp) # restore return value
|
||||
|
||||
lw ra, (_JB_REG_RA * SZREG)(a0)
|
||||
lw s0, (_JB_REG_S0 * SZREG)(a0)
|
||||
lw s1, (_JB_REG_S1 * SZREG)(a0)
|
||||
lw s2, (_JB_REG_S2 * SZREG)(a0)
|
||||
lw s3, (_JB_REG_S3 * SZREG)(a0)
|
||||
lw s4, (_JB_REG_S4 * SZREG)(a0)
|
||||
lw s5, (_JB_REG_S5 * SZREG)(a0)
|
||||
lw s6, (_JB_REG_S6 * SZREG)(a0)
|
||||
lw s7, (_JB_REG_S7 * SZREG)(a0)
|
||||
lw sp, (_JB_REG_SP * SZREG)(a0)
|
||||
lw s8, (_JB_REG_S8 * SZREG)(a0)
|
||||
move v0, a1
|
||||
j ra
|
||||
nop
|
||||
|
||||
botch:
|
||||
la t9, _C_LABEL(longjmperror)
|
||||
jal t9
|
||||
nop
|
||||
|
||||
la t9, _C_LABEL(abort)
|
||||
jal t9
|
||||
nop
|
||||
END(longjmp)
|
53
lib/libc/mips/gen/signalcontext.c
Normal file
53
lib/libc/mips/gen/signalcontext.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 Olivier Houchard
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/sigframe.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
#include <signal.h>
|
||||
|
||||
__weak_reference(__signalcontext, signalcontext);
|
||||
|
||||
extern void _ctx_start(void);
|
||||
|
||||
int
|
||||
__signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
|
||||
{
|
||||
/* XXXMIPS: Implement me */
|
||||
return (0);
|
||||
}
|
86
lib/libc/mips/gen/sigsetjmp.S
Normal file
86
lib/libc/mips/gen/sigsetjmp.S
Normal file
@ -0,0 +1,86 @@
|
||||
/* $NetBSD: sigsetjmp.S,v 1.8 2005/09/17 11:49:39 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include <machine/regnum.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: sigsetjmp.S,v 1.8 2005/09/17 11:49:39 tsutsui Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/*
|
||||
* C library -- sigsetjmp, siglongjmp
|
||||
*
|
||||
* siglongjmp(a,v)
|
||||
* will generate a "return(v)" from
|
||||
* the last call to
|
||||
* sigsetjmp(a, savemask)
|
||||
* by restoring registers from the stack,
|
||||
* and dependent on savemask restores the
|
||||
* signal mask.
|
||||
*/
|
||||
|
||||
LEAF(sigsetjmp)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
bne a1, 0x0, 1f # do saving of signal mask?
|
||||
la t9, _setjmp
|
||||
jr t9
|
||||
|
||||
1: la t9, setjmp
|
||||
jr t9
|
||||
END(sigsetjmp)
|
||||
|
||||
LEAF(siglongjmp)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
lw t0, (_JB_MAGIC * SZREG)(a0)
|
||||
li t1, _JB_MAGIC__SETJMP
|
||||
bne t0, t1, 1f # setjmp or _setjmp magic?
|
||||
la t9, _longjmp
|
||||
jr t9
|
||||
1: la t9, longjmp
|
||||
jr t9
|
||||
END(siglongjmp)
|
4
lib/libc/mips/net/Makefile.inc
Normal file
4
lib/libc/mips/net/Makefile.inc
Normal file
@ -0,0 +1,4 @@
|
||||
# $NetBSD: Makefile.inc,v 1.3 2003/08/01 17:03:51 lukem Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= htonl.S ntohl.S htons.S ntohs.S
|
58
lib/libc/mips/net/htonl.S
Normal file
58
lib/libc/mips/net/htonl.S
Normal file
@ -0,0 +1,58 @@
|
||||
/* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Neil A. Carson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
LEAF(htonl) # a0 = 0x11223344, return 0x44332211
|
||||
#ifdef __MIPSEB__
|
||||
move v0, a0
|
||||
#else
|
||||
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
|
||||
#endif
|
||||
j ra
|
||||
END(htonl)
|
54
lib/libc/mips/net/htons.S
Normal file
54
lib/libc/mips/net/htons.S
Normal file
@ -0,0 +1,54 @@
|
||||
/* $NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
LEAF(htons)
|
||||
#ifdef __MIPSEB__
|
||||
move v0, a0
|
||||
#else
|
||||
srl v0, a0, 8
|
||||
and v0, v0, 0xff
|
||||
sll v1, a0, 8
|
||||
and v1, v1, 0xff00
|
||||
or v0, v0, v1
|
||||
#endif
|
||||
j ra
|
||||
END(htons)
|
58
lib/libc/mips/net/ntohl.S
Normal file
58
lib/libc/mips/net/ntohl.S
Normal file
@ -0,0 +1,58 @@
|
||||
/* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Neil A. Carson
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
LEAF(ntohl) # a0 = 0x11223344, return 0x44332211
|
||||
#ifdef __MIPSEB__
|
||||
move v0, a0
|
||||
#else
|
||||
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
|
||||
#endif
|
||||
j ra
|
||||
END(ntohl)
|
53
lib/libc/mips/net/ntohs.S
Normal file
53
lib/libc/mips/net/ntohs.S
Normal file
@ -0,0 +1,53 @@
|
||||
/* $NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Charles M. Hannum.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
LEAF(ntohs)
|
||||
#ifdef __MIPSEB__
|
||||
move v0, a0
|
||||
#else
|
||||
srl v0, a0, 8
|
||||
and v0, v0, 0xff
|
||||
sll v1, a0, 8
|
||||
and v1, v1, 0xff00
|
||||
or v0, v0, v1
|
||||
#endif
|
||||
j ra
|
||||
END(ntohs)
|
48
lib/libc/mips/softfloat/milieu.h
Normal file
48
lib/libc/mips/softfloat/milieu.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEC/IEEE Floating-point
|
||||
Arithmetic Package, Release 2a.
|
||||
|
||||
Written by John R. Hauser. This work was made possible in part by the
|
||||
International Computer Science Institute, located at Suite 600, 1947 Center
|
||||
Street, Berkeley, California 94704. Funding was partially provided by the
|
||||
National Science Foundation under grant MIP-9311980. The original version
|
||||
of this code was written as part of a project to build a fixed-point vector
|
||||
processor in collaboration with the University of California at Berkeley,
|
||||
overseen by Profs. Nelson Morgan and John Wawrzynek. More information
|
||||
is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
|
||||
arithmetic/SoftFloat.html'.
|
||||
|
||||
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
|
||||
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
|
||||
TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
|
||||
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
|
||||
AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
|
||||
|
||||
Derivative works are acceptable, even for commercial purposes, so long as
|
||||
(1) they include prominent notice that the work is derivative, and (2) they
|
||||
include prominent notice akin to these four paragraphs for those parts of
|
||||
this code that are retained.
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Include common integer types and flags.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#include "mips-gcc.h"
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Symbolic Boolean literals.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
enum {
|
||||
FALSE = 0,
|
||||
TRUE = 1
|
||||
};
|
91
lib/libc/mips/softfloat/mips-gcc.h
Normal file
91
lib/libc/mips/softfloat/mips-gcc.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* $NetBSD: arm-gcc.h,v 1.2 2001/02/21 18:09:25 bjh21 Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef __MIPSEB__
|
||||
#define BIGENDIAN
|
||||
#else
|
||||
#define LITTLEENDIAN
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
The macro `BITS64' can be defined to indicate that 64-bit integer types are
|
||||
supported by the compiler.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#define BITS64
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Each of the following `typedef's defines the most convenient type that holds
|
||||
integers of at least as many bits as specified. For example, `uint8' should
|
||||
be the most convenient type that can hold unsigned integers of as many as
|
||||
8 bits. The `flag' type must be able to hold either a 0 or 1. For most
|
||||
implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
|
||||
to the same as `int'.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
typedef int flag;
|
||||
typedef int uint8;
|
||||
typedef int int8;
|
||||
typedef int uint16;
|
||||
typedef int int16;
|
||||
typedef unsigned int uint32;
|
||||
typedef signed int int32;
|
||||
#ifdef BITS64
|
||||
typedef unsigned long long int uint64;
|
||||
typedef signed long long int int64;
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Each of the following `typedef's defines a type that holds integers
|
||||
of _exactly_ the number of bits specified. For instance, for most
|
||||
implementation of C, `bits16' and `sbits16' should be `typedef'ed to
|
||||
`unsigned short int' and `signed short int' (or `short int'), respectively.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
typedef unsigned char bits8;
|
||||
typedef signed char sbits8;
|
||||
typedef unsigned short int bits16;
|
||||
typedef signed short int sbits16;
|
||||
typedef unsigned int bits32;
|
||||
typedef signed int sbits32;
|
||||
#ifdef BITS64
|
||||
typedef unsigned long long int bits64;
|
||||
typedef signed long long int sbits64;
|
||||
#endif
|
||||
|
||||
#ifdef BITS64
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
The `LIT64' macro takes as its argument a textual integer literal and
|
||||
if necessary ``marks'' the literal as having a 64-bit integer type.
|
||||
For example, the GNU C Compiler (`gcc') requires that 64-bit literals be
|
||||
appended with the letters `LL' standing for `long long', which is `gcc's
|
||||
name for the 64-bit integer type. Some compilers may allow `LIT64' to be
|
||||
defined as the identity macro: `#define LIT64( a ) a'.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#define LIT64( a ) a##LL
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
The macro `INLINE' can be used before functions that should be inlined. If
|
||||
a compiler does not support explicit inlining, this macro should be defined
|
||||
to be `static'.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#define INLINE static __inline
|
||||
|
||||
#if defined(SOFTFLOAT_FOR_GCC)
|
||||
/* XXXMIPS: check this one */
|
||||
#define FLOAT64_DEMANGLE(a) (a)
|
||||
#define FLOAT64_MANGLE(a) (a)
|
||||
#endif
|
315
lib/libc/mips/softfloat/softfloat.h
Normal file
315
lib/libc/mips/softfloat/softfloat.h
Normal file
@ -0,0 +1,315 @@
|
||||
/* $NetBSD: softfloat.h,v 1.6 2002/05/12 13:12:46 bjh21 Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/* This is a derivative work. */
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
This C header file is part of the SoftFloat IEC/IEEE Floating-point
|
||||
Arithmetic Package, Release 2a.
|
||||
|
||||
Written by John R. Hauser. This work was made possible in part by the
|
||||
International Computer Science Institute, located at Suite 600, 1947 Center
|
||||
Street, Berkeley, California 94704. Funding was partially provided by the
|
||||
National Science Foundation under grant MIP-9311980. The original version
|
||||
of this code was written as part of a project to build a fixed-point vector
|
||||
processor in collaboration with the University of California at Berkeley,
|
||||
overseen by Profs. Nelson Morgan and John Wawrzynek. More information
|
||||
is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
|
||||
arithmetic/SoftFloat.html'.
|
||||
|
||||
THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
|
||||
has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
|
||||
TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
|
||||
PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
|
||||
AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
|
||||
|
||||
Derivative works are acceptable, even for commercial purposes, so long as
|
||||
(1) they include prominent notice that the work is derivative, and (2) they
|
||||
include prominent notice akin to these four paragraphs for those parts of
|
||||
this code that are retained.
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
The macro `FLOATX80' must be defined to enable the extended double-precision
|
||||
floating-point format `floatx80'. If this macro is not defined, the
|
||||
`floatx80' type will not be defined, and none of the functions that either
|
||||
input or output the `floatx80' type will be defined. The same applies to
|
||||
the `FLOAT128' macro and the quadruple-precision format `float128'.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
/* #define FLOATX80 */
|
||||
/* #define FLOAT128 */
|
||||
|
||||
#include <machine/ieeefp.h>
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE floating-point types.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
typedef unsigned int float32;
|
||||
typedef unsigned long long float64;
|
||||
#ifdef FLOATX80
|
||||
typedef struct {
|
||||
unsigned short high;
|
||||
unsigned long long low;
|
||||
} floatx80;
|
||||
#endif
|
||||
#ifdef FLOAT128
|
||||
typedef struct {
|
||||
unsigned long long high, low;
|
||||
} float128;
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE floating-point underflow tininess-detection mode.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SOFTFLOAT_FOR_GCC
|
||||
extern int float_detect_tininess;
|
||||
#endif
|
||||
enum {
|
||||
float_tininess_after_rounding = 0,
|
||||
float_tininess_before_rounding = 1
|
||||
};
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE floating-point rounding mode.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
extern fp_rnd_t float_rounding_mode;
|
||||
enum {
|
||||
float_round_nearest_even = FP_RN,
|
||||
float_round_to_zero = FP_RZ,
|
||||
float_round_down = FP_RM,
|
||||
float_round_up = FP_RP
|
||||
};
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE floating-point exception flags.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
extern fp_except float_exception_flags;
|
||||
extern fp_except float_exception_mask;
|
||||
enum {
|
||||
float_flag_inexact = FP_X_IMP,
|
||||
float_flag_underflow = FP_X_UFL,
|
||||
float_flag_overflow = FP_X_OFL,
|
||||
float_flag_divbyzero = FP_X_DZ,
|
||||
float_flag_invalid = FP_X_INV
|
||||
};
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Routine to raise any or all of the software IEC/IEEE floating-point
|
||||
exception flags.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
void float_raise( fp_except );
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE integer-to-floating-point conversion routines.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
float32 int32_to_float32( int );
|
||||
float64 int32_to_float64( int );
|
||||
#ifdef FLOATX80
|
||||
floatx80 int32_to_floatx80( int );
|
||||
#endif
|
||||
#ifdef FLOAT128
|
||||
float128 int32_to_float128( int );
|
||||
#endif
|
||||
#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */
|
||||
float32 int64_to_float32( long long );
|
||||
float64 int64_to_float64( long long );
|
||||
#ifdef FLOATX80
|
||||
floatx80 int64_to_floatx80( long long );
|
||||
#endif
|
||||
#ifdef FLOAT128
|
||||
float128 int64_to_float128( long long );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE single-precision conversion routines.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
int float32_to_int32( float32 );
|
||||
int float32_to_int32_round_to_zero( float32 );
|
||||
#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS)
|
||||
unsigned int float32_to_uint32_round_to_zero( float32 );
|
||||
#endif
|
||||
#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */
|
||||
long long float32_to_int64( float32 );
|
||||
long long float32_to_int64_round_to_zero( float32 );
|
||||
#endif
|
||||
float64 float32_to_float64( float32 );
|
||||
#ifdef FLOATX80
|
||||
floatx80 float32_to_floatx80( float32 );
|
||||
#endif
|
||||
#ifdef FLOAT128
|
||||
float128 float32_to_float128( float32 );
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE single-precision operations.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
float32 float32_round_to_int( float32 );
|
||||
float32 float32_add( float32, float32 );
|
||||
float32 float32_sub( float32, float32 );
|
||||
float32 float32_mul( float32, float32 );
|
||||
float32 float32_div( float32, float32 );
|
||||
float32 float32_rem( float32, float32 );
|
||||
float32 float32_sqrt( float32 );
|
||||
int float32_eq( float32, float32 );
|
||||
int float32_le( float32, float32 );
|
||||
int float32_lt( float32, float32 );
|
||||
int float32_eq_signaling( float32, float32 );
|
||||
int float32_le_quiet( float32, float32 );
|
||||
int float32_lt_quiet( float32, float32 );
|
||||
#ifndef SOFTFLOAT_FOR_GCC
|
||||
int float32_is_signaling_nan( float32 );
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE double-precision conversion routines.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
int float64_to_int32( float64 );
|
||||
int float64_to_int32_round_to_zero( float64 );
|
||||
#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS)
|
||||
unsigned int float64_to_uint32_round_to_zero( float64 );
|
||||
#endif
|
||||
#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */
|
||||
long long float64_to_int64( float64 );
|
||||
long long float64_to_int64_round_to_zero( float64 );
|
||||
#endif
|
||||
float32 float64_to_float32( float64 );
|
||||
#ifdef FLOATX80
|
||||
floatx80 float64_to_floatx80( float64 );
|
||||
#endif
|
||||
#ifdef FLOAT128
|
||||
float128 float64_to_float128( float64 );
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE double-precision operations.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
float64 float64_round_to_int( float64 );
|
||||
float64 float64_add( float64, float64 );
|
||||
float64 float64_sub( float64, float64 );
|
||||
float64 float64_mul( float64, float64 );
|
||||
float64 float64_div( float64, float64 );
|
||||
float64 float64_rem( float64, float64 );
|
||||
float64 float64_sqrt( float64 );
|
||||
int float64_eq( float64, float64 );
|
||||
int float64_le( float64, float64 );
|
||||
int float64_lt( float64, float64 );
|
||||
int float64_eq_signaling( float64, float64 );
|
||||
int float64_le_quiet( float64, float64 );
|
||||
int float64_lt_quiet( float64, float64 );
|
||||
#ifndef SOFTFLOAT_FOR_GCC
|
||||
int float64_is_signaling_nan( float64 );
|
||||
#endif
|
||||
|
||||
#ifdef FLOATX80
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE extended double-precision conversion routines.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
int floatx80_to_int32( floatx80 );
|
||||
int floatx80_to_int32_round_to_zero( floatx80 );
|
||||
long long floatx80_to_int64( floatx80 );
|
||||
long long floatx80_to_int64_round_to_zero( floatx80 );
|
||||
float32 floatx80_to_float32( floatx80 );
|
||||
float64 floatx80_to_float64( floatx80 );
|
||||
#ifdef FLOAT128
|
||||
float128 floatx80_to_float128( floatx80 );
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE extended double-precision rounding precision. Valid
|
||||
values are 32, 64, and 80.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
extern int floatx80_rounding_precision;
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE extended double-precision operations.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
floatx80 floatx80_round_to_int( floatx80 );
|
||||
floatx80 floatx80_add( floatx80, floatx80 );
|
||||
floatx80 floatx80_sub( floatx80, floatx80 );
|
||||
floatx80 floatx80_mul( floatx80, floatx80 );
|
||||
floatx80 floatx80_div( floatx80, floatx80 );
|
||||
floatx80 floatx80_rem( floatx80, floatx80 );
|
||||
floatx80 floatx80_sqrt( floatx80 );
|
||||
int floatx80_eq( floatx80, floatx80 );
|
||||
int floatx80_le( floatx80, floatx80 );
|
||||
int floatx80_lt( floatx80, floatx80 );
|
||||
int floatx80_eq_signaling( floatx80, floatx80 );
|
||||
int floatx80_le_quiet( floatx80, floatx80 );
|
||||
int floatx80_lt_quiet( floatx80, floatx80 );
|
||||
int floatx80_is_signaling_nan( floatx80 );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef FLOAT128
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE quadruple-precision conversion routines.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
int float128_to_int32( float128 );
|
||||
int float128_to_int32_round_to_zero( float128 );
|
||||
long long float128_to_int64( float128 );
|
||||
long long float128_to_int64_round_to_zero( float128 );
|
||||
float32 float128_to_float32( float128 );
|
||||
float64 float128_to_float64( float128 );
|
||||
#ifdef FLOATX80
|
||||
floatx80 float128_to_floatx80( float128 );
|
||||
#endif
|
||||
|
||||
/*
|
||||
-------------------------------------------------------------------------------
|
||||
Software IEC/IEEE quadruple-precision operations.
|
||||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
float128 float128_round_to_int( float128 );
|
||||
float128 float128_add( float128, float128 );
|
||||
float128 float128_sub( float128, float128 );
|
||||
float128 float128_mul( float128, float128 );
|
||||
float128 float128_div( float128, float128 );
|
||||
float128 float128_rem( float128, float128 );
|
||||
float128 float128_sqrt( float128 );
|
||||
int float128_eq( float128, float128 );
|
||||
int float128_le( float128, float128 );
|
||||
int float128_lt( float128, float128 );
|
||||
int float128_eq_signaling( float128, float128 );
|
||||
int float128_le_quiet( float128, float128 );
|
||||
int float128_lt_quiet( float128, float128 );
|
||||
int float128_is_signaling_nan( float128 );
|
||||
|
||||
#endif
|
||||
|
4
lib/libc/mips/stdlib/Makefile.inc
Normal file
4
lib/libc/mips/stdlib/Makefile.inc
Normal file
@ -0,0 +1,4 @@
|
||||
# $NetBSD: Makefile.inc,v 1.3 2006/03/22 22:03:58 drochner Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= abs.c div.c labs.c ldiv.c llabs.c
|
8
lib/libc/mips/string/Makefile.inc
Normal file
8
lib/libc/mips/string/Makefile.inc
Normal file
@ -0,0 +1,8 @@
|
||||
# $NetBSD: Makefile.inc,v 1.2 2000/10/10 21:51:54 jeffs Exp $
|
||||
# $FreeBSD$
|
||||
|
||||
SRCS+= bcmp.S bcopy.S bzero.S ffs.S index.S memchr.c memcmp.c memset.c \
|
||||
memcpy.S memmove.S \
|
||||
rindex.S strcat.c strcmp.S strcpy.c strcspn.c strlen.S \
|
||||
strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \
|
||||
strspn.c strstr.c swab.c
|
134
lib/libc/mips/string/bcmp.S
Normal file
134
lib/libc/mips/string/bcmp.S
Normal file
@ -0,0 +1,134 @@
|
||||
/* $NetBSD: bcmp.S,v 1.8 2003/08/07 16:42:16 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)bcmp.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: bcmp.S,v 1.8 2003/08/07 16:42:16 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
#ifdef __MIPSEB__
|
||||
lwl v0, 0(a0) # read 1, 2, or 3 bytes
|
||||
lwl v1, 0(a1)
|
||||
#else
|
||||
lwr v0, 0(a0) # read 1, 2, or 3 bytes
|
||||
lwr v1, 0(a1)
|
||||
#endif
|
||||
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:
|
||||
#ifdef __MIPSEB__
|
||||
lwl v0, 0(a0) # compare words a0 unaligned, a1 aligned
|
||||
lwr v0, 3(a0)
|
||||
#else
|
||||
lwr v0, 0(a0) # compare words a0 unaligned, a1 aligned
|
||||
lwl v0, 3(a0)
|
||||
#endif
|
||||
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)
|
300
lib/libc/mips/string/bcopy.S
Normal file
300
lib/libc/mips/string/bcopy.S
Normal file
@ -0,0 +1,300 @@
|
||||
/* $NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
* Copyright (c) 1993 Carnegie Mellon University
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation.
|
||||
*
|
||||
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
||||
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
||||
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
||||
*
|
||||
* Carnegie Mellon requests users of this software to return to
|
||||
*
|
||||
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
||||
* School of Computer Science
|
||||
* Carnegie Mellon University
|
||||
* Pittsburgh PA 15213-3890
|
||||
*
|
||||
* any improvements or extensions that they make and grant Carnegie Mellon
|
||||
* the rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: mips_bcopy.s
|
||||
* Author: Chris Maeda
|
||||
* Date: June 1993
|
||||
*
|
||||
* Fast copy routine. Derived from aligned_block_copy.
|
||||
*/
|
||||
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93")
|
||||
ASMSTR("$NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/*
|
||||
* bcopy(caddr_t src, caddr_t dst, unsigned int len)
|
||||
*
|
||||
* a0 src address
|
||||
* a1 dst address
|
||||
* a2 length
|
||||
*/
|
||||
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
#ifdef MEMCOPY
|
||||
#define FUNCTION memcpy
|
||||
#else
|
||||
#define FUNCTION memmove
|
||||
#endif
|
||||
#define SRCREG a1
|
||||
#define DSTREG a0
|
||||
#else
|
||||
#define FUNCTION bcopy
|
||||
#define SRCREG a0
|
||||
#define DSTREG a1
|
||||
#endif
|
||||
|
||||
#define SIZEREG a2
|
||||
|
||||
LEAF(FUNCTION)
|
||||
.set noat
|
||||
.set noreorder
|
||||
|
||||
#if defined(MEMCOPY) || defined(MEMMOVE)
|
||||
/* set up return value, while we still can */
|
||||
move v0,DSTREG
|
||||
#endif
|
||||
/*
|
||||
* Make sure we can copy forwards.
|
||||
*/
|
||||
sltu t0,SRCREG,DSTREG # t0 == SRCREG < DSTREG
|
||||
bne t0,zero,6f # copy backwards
|
||||
|
||||
/*
|
||||
* There are four alignment cases (with frequency)
|
||||
* (Based on measurements taken with a DECstation 5000/200
|
||||
* inside a Mach kernel.)
|
||||
*
|
||||
* aligned -> aligned (mostly)
|
||||
* unaligned -> aligned (sometimes)
|
||||
* aligned,unaligned -> unaligned (almost never)
|
||||
*
|
||||
* Note that we could add another case that checks if
|
||||
* the destination and source are unaligned but the
|
||||
* copy is alignable. eg if src and dest are both
|
||||
* on a halfword boundary.
|
||||
*/
|
||||
andi t1,DSTREG,3 # get last 3 bits of dest
|
||||
bne t1,zero,3f
|
||||
andi t0,SRCREG,3 # get last 3 bits of src
|
||||
bne t0,zero,5f
|
||||
|
||||
/*
|
||||
* Forward aligned->aligned copy, 8*4 bytes at a time.
|
||||
*/
|
||||
li AT,-32
|
||||
and t0,SIZEREG,AT # count truncated to multiple of 32 */
|
||||
addu a3,SRCREG,t0 # run fast loop up to this address
|
||||
sltu AT,SRCREG,a3 # any work to do?
|
||||
beq AT,zero,2f
|
||||
subu SIZEREG,t0
|
||||
|
||||
/*
|
||||
* loop body
|
||||
*/
|
||||
1: # cp
|
||||
lw t3,0(SRCREG)
|
||||
lw v1,4(SRCREG)
|
||||
lw t0,8(SRCREG)
|
||||
lw t1,12(SRCREG)
|
||||
addu SRCREG,32
|
||||
sw t3,0(DSTREG)
|
||||
sw v1,4(DSTREG)
|
||||
sw t0,8(DSTREG)
|
||||
sw t1,12(DSTREG)
|
||||
lw t1,-4(SRCREG)
|
||||
lw t0,-8(SRCREG)
|
||||
lw v1,-12(SRCREG)
|
||||
lw t3,-16(SRCREG)
|
||||
addu DSTREG,32
|
||||
sw t1,-4(DSTREG)
|
||||
sw t0,-8(DSTREG)
|
||||
sw v1,-12(DSTREG)
|
||||
bne SRCREG,a3,1b
|
||||
sw t3,-16(DSTREG)
|
||||
|
||||
/*
|
||||
* Copy a word at a time, no loop unrolling.
|
||||
*/
|
||||
2: # wordcopy
|
||||
andi t2,SIZEREG,3 # get byte count / 4
|
||||
subu t2,SIZEREG,t2 # t2 = number of words to copy * 4
|
||||
beq t2,zero,3f
|
||||
addu t0,SRCREG,t2 # stop at t0
|
||||
subu SIZEREG,SIZEREG,t2
|
||||
1:
|
||||
lw t3,0(SRCREG)
|
||||
addu SRCREG,4
|
||||
sw t3,0(DSTREG)
|
||||
bne SRCREG,t0,1b
|
||||
addu DSTREG,4
|
||||
|
||||
3: # bytecopy
|
||||
beq SIZEREG,zero,4f # nothing left to do?
|
||||
nop
|
||||
1:
|
||||
lb t3,0(SRCREG)
|
||||
addu SRCREG,1
|
||||
sb t3,0(DSTREG)
|
||||
subu SIZEREG,1
|
||||
bgtz SIZEREG,1b
|
||||
addu DSTREG,1
|
||||
|
||||
4: # copydone
|
||||
j ra
|
||||
nop
|
||||
|
||||
/*
|
||||
* Copy from unaligned source to aligned dest.
|
||||
*/
|
||||
5: # destaligned
|
||||
andi t0,SIZEREG,3 # t0 = bytecount mod 4
|
||||
subu a3,SIZEREG,t0 # number of words to transfer
|
||||
beq a3,zero,3b
|
||||
nop
|
||||
move SIZEREG,t0 # this many to do after we are done
|
||||
addu a3,SRCREG,a3 # stop point
|
||||
|
||||
1:
|
||||
#ifdef __MIPSEB__
|
||||
lwl t3,0(SRCREG)
|
||||
lwr t3,3(SRCREG)
|
||||
#else
|
||||
lwr t3,0(SRCREG)
|
||||
lwl t3,3(SRCREG)
|
||||
#endif
|
||||
addi SRCREG,4
|
||||
sw t3,0(DSTREG)
|
||||
bne SRCREG,a3,1b
|
||||
addi DSTREG,4
|
||||
|
||||
j 3b
|
||||
nop
|
||||
|
||||
6: # backcopy -- based on above
|
||||
addu SRCREG,SIZEREG
|
||||
addu DSTREG,SIZEREG
|
||||
andi t1,DSTREG,3 # get last 3 bits of dest
|
||||
bne t1,zero,3f
|
||||
andi t0,SRCREG,3 # get last 3 bits of src
|
||||
bne t0,zero,5f
|
||||
|
||||
/*
|
||||
* Forward aligned->aligned copy, 8*4 bytes at a time.
|
||||
*/
|
||||
li AT,-32
|
||||
and t0,SIZEREG,AT # count truncated to multiple of 32
|
||||
beq t0,zero,2f # any work to do?
|
||||
subu SIZEREG,t0
|
||||
subu a3,SRCREG,t0
|
||||
|
||||
/*
|
||||
* loop body
|
||||
*/
|
||||
1: # cp
|
||||
lw t3,-16(SRCREG)
|
||||
lw v1,-12(SRCREG)
|
||||
lw t0,-8(SRCREG)
|
||||
lw t1,-4(SRCREG)
|
||||
subu SRCREG,32
|
||||
sw t3,-16(DSTREG)
|
||||
sw v1,-12(DSTREG)
|
||||
sw t0,-8(DSTREG)
|
||||
sw t1,-4(DSTREG)
|
||||
lw t1,12(SRCREG)
|
||||
lw t0,8(SRCREG)
|
||||
lw v1,4(SRCREG)
|
||||
lw t3,0(SRCREG)
|
||||
subu DSTREG,32
|
||||
sw t1,12(DSTREG)
|
||||
sw t0,8(DSTREG)
|
||||
sw v1,4(DSTREG)
|
||||
bne SRCREG,a3,1b
|
||||
sw t3,0(DSTREG)
|
||||
|
||||
/*
|
||||
* Copy a word at a time, no loop unrolling.
|
||||
*/
|
||||
2: # wordcopy
|
||||
andi t2,SIZEREG,3 # get byte count / 4
|
||||
subu t2,SIZEREG,t2 # t2 = number of words to copy * 4
|
||||
beq t2,zero,3f
|
||||
subu t0,SRCREG,t2 # stop at t0
|
||||
subu SIZEREG,SIZEREG,t2
|
||||
1:
|
||||
lw t3,-4(SRCREG)
|
||||
subu SRCREG,4
|
||||
sw t3,-4(DSTREG)
|
||||
bne SRCREG,t0,1b
|
||||
subu DSTREG,4
|
||||
|
||||
3: # bytecopy
|
||||
beq SIZEREG,zero,4f # nothing left to do?
|
||||
nop
|
||||
1:
|
||||
lb t3,-1(SRCREG)
|
||||
subu SRCREG,1
|
||||
sb t3,-1(DSTREG)
|
||||
subu SIZEREG,1
|
||||
bgtz SIZEREG,1b
|
||||
subu DSTREG,1
|
||||
|
||||
4: # copydone
|
||||
j ra
|
||||
nop
|
||||
|
||||
/*
|
||||
* Copy from unaligned source to aligned dest.
|
||||
*/
|
||||
5: # destaligned
|
||||
andi t0,SIZEREG,3 # t0 = bytecount mod 4
|
||||
subu a3,SIZEREG,t0 # number of words to transfer
|
||||
beq a3,zero,3b
|
||||
nop
|
||||
move SIZEREG,t0 # this many to do after we are done
|
||||
subu a3,SRCREG,a3 # stop point
|
||||
|
||||
1:
|
||||
#ifdef __MIPSEB__
|
||||
lwl t3,-4(SRCREG)
|
||||
lwr t3,-1(SRCREG)
|
||||
#else
|
||||
lwr t3,-4(SRCREG)
|
||||
lwl t3,-1(SRCREG)
|
||||
#endif
|
||||
subu SRCREG,4
|
||||
sw t3,-4(DSTREG)
|
||||
bne SRCREG,a3,1b
|
||||
subu DSTREG,4
|
||||
|
||||
j 3b
|
||||
nop
|
||||
|
||||
.set reorder
|
||||
.set at
|
||||
END(FUNCTION)
|
82
lib/libc/mips/string/bzero.S
Normal file
82
lib/libc/mips/string/bzero.S
Normal file
@ -0,0 +1,82 @@
|
||||
/* $NetBSD: bzero.S,v 1.8 2003/08/07 16:42:16 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)bzero.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: bzero.S,v 1.8 2003/08/07 16:42:16 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
#ifdef __MIPSEB__
|
||||
swl zero, 0(a0) # clear 1, 2, or 3 bytes to align
|
||||
#else
|
||||
swr zero, 0(a0) # clear 1, 2, or 3 bytes to align
|
||||
#endif
|
||||
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 doesnt 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)
|
59
lib/libc/mips/string/ffs.S
Normal file
59
lib/libc/mips/string/ffs.S
Normal file
@ -0,0 +1,59 @@
|
||||
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/* bit = ffs(value) */
|
||||
|
||||
LEAF(ffs)
|
||||
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)
|
59
lib/libc/mips/string/index.S
Normal file
59
lib/libc/mips/string/index.S
Normal file
@ -0,0 +1,59 @@
|
||||
/* $NetBSD: index.S,v 1.8 2005/04/22 06:59:00 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)index.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: index.S,v 1.8 2005/04/22 06:59:00 simonb Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
LEAF(index)
|
||||
1:
|
||||
lbu a2, 0(a0) # get a byte
|
||||
addu a0, a0, 1
|
||||
beq a2, a1, fnd
|
||||
bne a2, zero, 1b
|
||||
notfnd:
|
||||
move v0, zero
|
||||
j ra
|
||||
fnd:
|
||||
subu v0, a0, 1
|
||||
j ra
|
||||
END(index)
|
7
lib/libc/mips/string/memcpy.S
Normal file
7
lib/libc/mips/string/memcpy.S
Normal file
@ -0,0 +1,7 @@
|
||||
/* $NetBSD: memcpy.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define MEMCOPY
|
||||
#include "bcopy.S"
|
7
lib/libc/mips/string/memmove.S
Normal file
7
lib/libc/mips/string/memmove.S
Normal file
@ -0,0 +1,7 @@
|
||||
/* $NetBSD: memmove.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define MEMMOVE
|
||||
#include "bcopy.S"
|
57
lib/libc/mips/string/rindex.S
Normal file
57
lib/libc/mips/string/rindex.S
Normal file
@ -0,0 +1,57 @@
|
||||
/* $NetBSD: rindex.S,v 1.7 2003/08/07 16:42:16 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)rindex.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: rindex.S,v 1.7 2003/08/07 16:42:16 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
LEAF(rindex)
|
||||
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)
|
68
lib/libc/mips/string/strcmp.S
Normal file
68
lib/libc/mips/string/strcmp.S
Normal file
@ -0,0 +1,68 @@
|
||||
/* $NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: this version assumes unsigned chars in order to be "8 bit clean".
|
||||
*/
|
||||
LEAF(strcmp)
|
||||
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)
|
55
lib/libc/mips/string/strlen.S
Normal file
55
lib/libc/mips/string/strlen.S
Normal file
@ -0,0 +1,55 @@
|
||||
/* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifdef __ABICALLS__
|
||||
.abicalls
|
||||
#endif
|
||||
|
||||
LEAF(strlen)
|
||||
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)
|
14
lib/libc/mips/sys/Makefile.inc
Normal file
14
lib/libc/mips/sys/Makefile.inc
Normal file
@ -0,0 +1,14 @@
|
||||
# $FreeBSD$
|
||||
|
||||
MDASM= Ovfork.S brk.S cerror.S exect.S \
|
||||
fork.S pipe.S ptrace.S sbrk.S shmat.S syscall.S
|
||||
|
||||
# Don't generate default code for these syscalls:
|
||||
NOASM= break.o exit.o ftruncate.o getdomainname.o getlogin.o \
|
||||
lseek.o mmap.o openbsd_poll.o pread.o \
|
||||
pwrite.o setdomainname.o sstk.o truncate.o uname.o vfork.o yield.o
|
||||
|
||||
PSEUDO= _exit.o _getlogin.o
|
||||
.if !defined(WITHOUT_SYSCALL_COMPAT)
|
||||
PSEUDO+= _pread.o _pwrite.o _lseek.o _mmap.o _ftruncate.o _truncate.o
|
||||
.endif
|
72
lib/libc/mips/sys/Ovfork.S
Normal file
72
lib/libc/mips/sys/Ovfork.S
Normal file
@ -0,0 +1,72 @@
|
||||
/* $NetBSD: compat_Ovfork.S,v 1.1 2005/09/17 11:49:39 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: compat_Ovfork.S,v 1.1 2005/09/17 11:49:39 tsutsui Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
WARN_REFERENCES(vfork, \
|
||||
"warning: reference to compatibility vfork(); include <unistd.h> for correct reference")
|
||||
|
||||
/*
|
||||
* pid = vfork();
|
||||
*
|
||||
* v1 == 0 in parent process, v1 == 1 in child process.
|
||||
* v0 == pid of child in parent, v0 == pid of parent in child.
|
||||
*/
|
||||
|
||||
LEAF(__sys_vfork)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
WEAK_ALIAS(vfork, __sys_vfork)
|
||||
WEAK_ALIAS(_vfork, __sys_vfork)
|
||||
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
|
||||
END(__sys_vfork)
|
76
lib/libc/mips/sys/brk.S
Normal file
76
lib/libc/mips/sys/brk.S
Normal file
@ -0,0 +1,76 @@
|
||||
/* $NetBSD: brk.S,v 1.16 2003/08/07 16:42:17 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)brk.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: brk.S,v 1.16 2003/08/07 16:42:17 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
.globl _C_LABEL(minbrk)
|
||||
.globl _C_LABEL(curbrk)
|
||||
.globl _C_LABEL(_end)
|
||||
|
||||
.data
|
||||
_C_LABEL(minbrk):
|
||||
.word _C_LABEL(_end)
|
||||
_C_LABEL(curbrk):
|
||||
.word _C_LABEL(_end)
|
||||
.text
|
||||
|
||||
LEAF(__sys_brk)
|
||||
WEAK_ALIAS(brk, __sys_brk)
|
||||
WEAK_ALIAS(_brk, __sys_brk)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
lw v0, _C_LABEL(minbrk)
|
||||
bgeu a0, v0, 1f
|
||||
move a0, v0 # dont allow break < minbrk
|
||||
1:
|
||||
li v0, SYS_break
|
||||
syscall
|
||||
bne a3, zero, 2f
|
||||
sw a0, _C_LABEL(curbrk)
|
||||
move v0, zero
|
||||
j ra
|
||||
2:
|
||||
la t9, _C_LABEL(__cerror)
|
||||
jr t9
|
||||
END(__sys_brk)
|
71
lib/libc/mips/sys/cerror.S
Normal file
71
lib/libc/mips/sys/cerror.S
Normal file
@ -0,0 +1,71 @@
|
||||
/* $NetBSD: cerror.S,v 1.13 2003/08/07 16:42:17 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93")
|
||||
ASMSTR("$NetBSD: cerror.S,v 1.13 2003/08/07 16:42:17 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
||||
/*
|
||||
* The __error() function is thread aware. For non-threaded
|
||||
* programs and the initial threaded in threaded programs,
|
||||
* it returns a pointer to the global errno variable.
|
||||
*/
|
||||
.globl _C_LABEL(__error)
|
||||
.type _C_LABEL(__error),%function
|
||||
|
||||
LEAF(__cerror)
|
||||
.frame sp, CALLFRAME_SIZ, ra
|
||||
PIC_PROLOGUE(__cerror, t9)
|
||||
subu sp, sp, CALLFRAME_SIZ
|
||||
.mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
|
||||
sw ra, CALLFRAME_RA(sp)
|
||||
sw v0, 12(sp) # save errno value
|
||||
|
||||
la t9, _C_LABEL(__error) # locate address of errno
|
||||
jalr t9
|
||||
|
||||
lw t0, 12(sp)
|
||||
lw ra, CALLFRAME_RA(sp)
|
||||
sw t0, 0(v0) # update errno value
|
||||
addiu sp, sp, CALLFRAME_SIZ
|
||||
li v0, -1
|
||||
li v1, -1
|
||||
j ra
|
||||
END(__cerror)
|
56
lib/libc/mips/sys/exect.S
Normal file
56
lib/libc/mips/sys/exect.S
Normal file
@ -0,0 +1,56 @@
|
||||
/* $NetBSD: exect.S,v 1.9 2003/08/07 16:42:17 agc Exp $ */
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)exect.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: exect.S,v 1.9 2003/08/07 16:42:17 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
LEAF(exect)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
li v0, SYS_execve
|
||||
syscall
|
||||
bne a3, zero, 1f
|
||||
j ra
|
||||
1:
|
||||
la t9, _C_LABEL(__cerror)
|
||||
jr t9
|
||||
END(exect)
|
63
lib/libc/mips/sys/fork.S
Normal file
63
lib/libc/mips/sys/fork.S
Normal file
@ -0,0 +1,63 @@
|
||||
/* $NetBSD: fork.S,v 1.11 2003/08/07 16:42:17 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)fork.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: fork.S,v 1.11 2003/08/07 16:42:17 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
LEAF(__sys_fork)
|
||||
WEAK_ALIAS(fork, __sys_fork)
|
||||
WEAK_ALIAS(_fork, __sys_fork)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
fork = __sys_fork
|
||||
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
|
||||
END(__sys_fork)
|
62
lib/libc/mips/sys/pipe.S
Normal file
62
lib/libc/mips/sys/pipe.S
Normal file
@ -0,0 +1,62 @@
|
||||
/* $NetBSD: pipe.S,v 1.11 2005/04/22 06:58:01 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)pipe.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: pipe.S,v 1.11 2005/04/22 06:58:01 simonb Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
LEAF(__sys_pipe)
|
||||
WEAK_ALIAS(pipe, __sys_pipe)
|
||||
WEAK_ALIAS(_pipe, __sys_pipe)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
li v0, SYS_pipe # pipe(fildes) int fildes[2];
|
||||
syscall
|
||||
bne a3, zero, 1f
|
||||
sw v0, 0(a0) # store the two file descriptors
|
||||
sw v1, 4(a0)
|
||||
move v0, zero
|
||||
j ra
|
||||
1:
|
||||
la t9, _C_LABEL(__cerror)
|
||||
jr t9
|
||||
END(__sys_pipe)
|
60
lib/libc/mips/sys/ptrace.S
Normal file
60
lib/libc/mips/sys/ptrace.S
Normal file
@ -0,0 +1,60 @@
|
||||
/* $NetBSD: ptrace.S,v 1.9 2003/08/07 16:42:17 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)ptrace.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: ptrace.S,v 1.9 2003/08/07 16:42:17 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
LEAF(ptrace)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
la t9, _C_LABEL(__error) # locate address of errno
|
||||
jalr t9
|
||||
sw zero, 0(v0)
|
||||
li v0, SYS_ptrace
|
||||
syscall
|
||||
bne a3, zero, 1f
|
||||
j ra
|
||||
1:
|
||||
la t9, _C_LABEL(__cerror)
|
||||
jr t9
|
||||
END(ptrace)
|
85
lib/libc/mips/sys/sbrk.S
Normal file
85
lib/libc/mips/sys/sbrk.S
Normal file
@ -0,0 +1,85 @@
|
||||
/* $NetBSD: sbrk.S,v 1.16 2005/04/22 06:58:01 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)sbrk.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: sbrk.S,v 1.16 2005/04/22 06:58:01 simonb Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
.globl _C_LABEL(__curbrk)
|
||||
.globl _C_LABEL(_end)
|
||||
|
||||
.data
|
||||
_C_LABEL(__curbrk):
|
||||
.word _C_LABEL(_end)
|
||||
.text
|
||||
|
||||
LEAF(__sys_sbrk)
|
||||
WEAK_ALIAS(sbrk, __sys_sbrk)
|
||||
WEAK_ALIAS(_sbrk, __sys_sbrk)
|
||||
#ifdef __ABICALLS__
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
.set reorder
|
||||
#endif
|
||||
addu sp, sp, -16
|
||||
sw s0, 0(sp) # Preserve s0 value in stack
|
||||
# it should be the same on return
|
||||
# We can't use v1 as temporary
|
||||
# register since syscall uses it
|
||||
# to return 64-bit values
|
||||
lw s0, _C_LABEL(__curbrk)
|
||||
li v0, SYS_break
|
||||
addu a0, a0, s0 # compute current break
|
||||
|
||||
syscall
|
||||
|
||||
bne a3, zero, 1f
|
||||
nop
|
||||
move v0, s0 # return old val of curbrk from above
|
||||
lw s0, 0(sp)
|
||||
addu sp, sp, 16
|
||||
sw a0, _C_LABEL(__curbrk) # save current val of curbrk from above
|
||||
j ra
|
||||
|
||||
1:
|
||||
lw s0, 0(sp)
|
||||
addu sp, sp, 16
|
||||
la t9, _C_LABEL(__cerror)
|
||||
jr t9
|
||||
END(__sys_sbrk)
|
7
lib/libc/mips/sys/shmat.S
Normal file
7
lib/libc/mips/sys/shmat.S
Normal file
@ -0,0 +1,7 @@
|
||||
/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:52 itohy Exp $ */
|
||||
|
||||
#include <machine/asm.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
RSYSCALL(shmat)
|
44
lib/libc/mips/sys/syscall.S
Normal file
44
lib/libc/mips/sys/syscall.S
Normal file
@ -0,0 +1,44 @@
|
||||
/* $NetBSD: syscall.S,v 1.5 2003/08/07 16:42:18 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* 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>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#include "SYS.h"
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
ASMSTR("from: @(#)syscall.s 8.1 (Berkeley) 6/4/93")
|
||||
ASMSTR("$NetBSD: syscall.S,v 1.5 2003/08/07 16:42:18 agc Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
RSYSCALL(syscall)
|
Loading…
Reference in New Issue
Block a user