Mon Dec 14 00:39:01 2009 UTC ()
Merge from matt-nb5-mips64


(matt)
diff -r1.9 -r1.10 src/common/lib/libc/arch/mips/atomic/Makefile.inc
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_add.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_and.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_cas.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_dec.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_inc.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_or.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/atomic/atomic_swap.S
diff -r1.3 -r1.4 src/common/lib/libc/arch/mips/atomic/membar_ops.S
diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/gen/byte_swap_2.S
diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/gen/byte_swap_4.S
diff -r0 -r1.2 src/common/lib/libc/arch/mips/gen/byte_swap_8.S
diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/string/bcopy.S
diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/ffs.S
diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strcmp.S
diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strlen.S
diff -r1.1 -r0 src/common/lib/libc/arch/mips/string/memset.S
diff -r1.6 -r1.7 src/common/lib/libc/atomic/atomic_init_testset.c
diff -r0 -r1.2 src/common/lib/libc/string/bzero2.c
diff -r0 -r1.2 src/common/lib/libc/string/memset2.c

cvs diff -r1.9 -r1.10 src/common/lib/libc/arch/mips/atomic/Makefile.inc (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/atomic/Makefile.inc 2009/01/04 17:54:29 1.9
+++ src/common/lib/libc/arch/mips/atomic/Makefile.inc 2009/12/14 00:38:59 1.10
@@ -1,28 +1,45 @@ @@ -1,28 +1,45 @@
1# $NetBSD: Makefile.inc,v 1.9 2009/01/04 17:54:29 pooka Exp $ 1# $NetBSD: Makefile.inc,v 1.10 2009/12/14 00:38:59 matt Exp $
2 2
3.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \ 3.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c" || ${LIB} == "pthread" \
4 || ${LIB} == "rump") 4 || ${LIB} == "rump")
5 5
6SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ 6.if ${MACHINE_ARCH:Mmips64*} == ""
7 atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ 7SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \
8 atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ 8 atomic_and_32_cas.c atomic_and_32_nv_cas.c \
9 atomic_or_32_nv_cas.c atomic_swap_32_cas.c atomic_add_64_cas.c \ 9 atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
10 atomic_add_64_nv_cas.c atomic_and_64_cas.c atomic_and_64_nv_cas.c \ 10 atomic_inc_32_cas.c atomic_inc_32_nv_cas.c \
11 atomic_dec_64_cas.c atomic_dec_64_nv_cas.c atomic_inc_64_cas.c \ 11 atomic_or_32_cas.c atomic_or_32_nv_cas.c \
12 atomic_inc_64_nv_cas.c atomic_or_64_cas.c atomic_or_64_nv_cas.c \ 12 atomic_swap_32_cas.c \
13 atomic_swap_64_cas.c membar_ops.o 13 atomic_add_64_cas.c atomic_add_64_nv_cas.c \
 14 atomic_and_64_cas.c atomic_and_64_nv_cas.c \
 15 atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \
 16 atomic_inc_64_cas.c atomic_inc_64_nv_cas.c \
 17 atomic_or_64_cas.c atomic_or_64_nv_cas.c \
 18 atomic_swap_64_cas.c
14 19
 20CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
 21
 22.else
 23SRCS+= atomic_add.S atomic_dec.S atomic_inc.S
 24SRCS+= atomic_and.S atomic_or.S
 25SRCS+= atomic_swap.S
 26.endif
 27
 28SRCS+= membar_ops.S
15.endif 29.endif
16 30
17.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread") 31.if defined(LIB) && (${LIB} == "c" || ${LIB} == "pthread")
18 32
19SRCS+= membar_ops_nop.c atomic_init_testset.c atomic_cas_up.S 33.if ${MACHINE_ARCH:Mmips64*} == ""
20CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP 34SRCS+= atomic_init_testset.c atomic_cas_up.S
 35.else
 36SRCS+= atomic_cas.S atomic_init_cas.c
 37.endif
21 38
22.endif 39.endif
23 40
24.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "rump") 41.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "rump")
25 42
26SRCS+= membar_ops.S 43SRCS+= membar_ops.S
27 44
28.endif 45.endif

File Added: src/common/lib/libc/arch/mips/atomic/atomic_add.S
/*	$NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

RCSID("$NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $")

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_add_32)
1:	INT_LL		t0, 0(a0)
	 nop
	INT_ADDU	t0, a1
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_32, _atomic_add_32)

LEAF(_atomic_add_32_nv)
1:	INT_LL		v0, 0(a0)
	 nop
	INT_ADDU	v0, a1
	move		t0, v0
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_32_nv, _atomic_add_32_nv)

#if !defined(__mips_o32)
LEAF(_atomic_add_64)
1:	REG_LL		t0, 0(a0)
	 nop
	REG_ADDU	t0, a1
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_add_64)
ATOMIC_OP_ALIAS(atomic_add_64, _atomic_add_64)

LEAF(_atomic_add_64_nv)
1:	REG_LL		v0, 0(a0)
	 nop
	REG_ADDU	v0, a1
	move		t0, v0
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_add_64_nv)
ATOMIC_OP_ALIAS(atomic_add_64_nv, _atomic_add_64_nv)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_add_long,		_atomic_add_64)
STRONG_ALIAS(_atomic_add_long_nv,	_atomic_add_64_nv)
STRONG_ALIAS(_atomic_add_ptr,		_atomic_add_64)
STRONG_ALIAS(_atomic_add_ptr_nv,	_atomic_add_64_nv)
#else
STRONG_ALIAS(_atomic_add_long,		_atomic_add_32)
STRONG_ALIAS(_atomic_add_long_nv,	_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_ptr,		_atomic_add_32)
STRONG_ALIAS(_atomic_add_ptr_nv,	_atomic_add_32_nv)
#endif
STRONG_ALIAS(_atomic_add_int,		_atomic_add_32)
STRONG_ALIAS(_atomic_add_int_nv,	_atomic_add_32_nv)

ATOMIC_OP_ALIAS(atomic_add_int,		_atomic_add_int)
ATOMIC_OP_ALIAS(atomic_add_int_nv,	_atomic_add_int_nv)
ATOMIC_OP_ALIAS(atomic_add_ptr,		_atomic_add_ptr)
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,	_atomic_add_ptr_nv)
ATOMIC_OP_ALIAS(atomic_add_long,	_atomic_add_long)
ATOMIC_OP_ALIAS(atomic_add_long_nv,	_atomic_add_long_nv)

File Added: src/common/lib/libc/arch/mips/atomic/atomic_and.S
/*	$NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

RCSID("$NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $")

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_and_32)
1:	INT_LL		t0, 0(a0)
	 nop
	and		t0, a1
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_32, _atomic_and_32)

LEAF(_atomic_and_32_nv)
1:	INT_LL		v0, 0(a0)
	 nop
	and		v0, a1
	move		t0, v0
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_32_nv, _atomic_and_32_nv)

#if !defined(__mips_o32)
LEAF(_atomic_and_64)
1:	REG_LL		t0, 0(a0)
	 nop
	and		t0, a1
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_and_64)
ATOMIC_OP_ALIAS(atomic_and_64, _atomic_and_64)

LEAF(_atomic_and_64_nv)
1:	REG_LL		v0, 0(a0)
	 nop
	and		v0, a1
	move		t0, v0
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_and_64_nv)
ATOMIC_OP_ALIAS(atomic_and_64_nv, _atomic_and_64_nv)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_and_ulong,		_atomic_and_64)
STRONG_ALIAS(_atomic_and_ulong_nv,	_atomic_and_64_nv)
#else
STRONG_ALIAS(_atomic_and_ulong,		_atomic_and_32)
STRONG_ALIAS(_atomic_and_ulong_nv,	_atomic_and_32_nv)
#endif
STRONG_ALIAS(_atomic_and_uint,		_atomic_and_32)
STRONG_ALIAS(_atomic_and_uint_nv,	_atomic_and_32_nv)

ATOMIC_OP_ALIAS(atomic_and_uint,	_atomic_and_uint)
ATOMIC_OP_ALIAS(atomic_and_uint_nv,	_atomic_and_uint_nv)
ATOMIC_OP_ALIAS(atomic_and_ulong,	_atomic_and_ulong)
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,	_atomic_and_ulong_nv)

File Added: src/common/lib/libc/arch/mips/atomic/atomic_cas.S
/*	$NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

RCSID("$NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $")

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_cas_32)
1:	INT_LL		v0, 0(a0)
	 nop
	bne		v0, a1, 2f
	 nop
	move		t0, a2
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	move		v0, a1
2:
	j		ra
	 nop
END(_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32, _atomic_cas_32)

#if !defined(__mips_o32)
LEAF(_atomic_cas_64)
1:	REG_LL		v0, 0(a0)
	 nop
	bne		v0, a1, 2f
	 nop
	move		t0, a2
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	move		v0, a1
2:
	j		ra
	 nop
END(_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_64, _atomic_cas_64)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_cas_ptr,		_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ptr_ni,	_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ulong,		_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ulong_ni,	_atomic_cas_64)
#else
STRONG_ALIAS(_atomic_cas_ptr,		_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr_ni,	_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,		_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong_ni,	_atomic_cas_32)
#endif
STRONG_ALIAS(_atomic_cas_uint,		_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint_ni,	_atomic_cas_32)

ATOMIC_OP_ALIAS(atomic_cas_ptr,		_atomic_cas_ptr)
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,	_atomic_cas_ptr_ni)
ATOMIC_OP_ALIAS(atomic_cas_uint,	_atomic_cas_uint)
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,	_atomic_cas_uint_ni)
ATOMIC_OP_ALIAS(atomic_cas_ulong,	_atomic_cas_ulong)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,	_atomic_cas_ulong_ni)

File Added: src/common/lib/libc/arch/mips/atomic/atomic_dec.S
/*	$NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

RCSID("$NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $")

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_dec_32)
1:	INT_LL		t0, 0(a0)
	 nop
	INT_ADDU	t0, -1
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_32, _atomic_dec_32)

LEAF(_atomic_dec_32_nv)
1:	INT_LL		v0, 0(a0)
	 nop
	INT_ADDU	v0, -1
	move		t0, v0
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_32_nv, _atomic_dec_32_nv)

#if !defined(__mips_o32)
LEAF(_atomic_dec_64)
1:	REG_LL		t0, 0(a0)
	 nop
	REG_ADDU	t0, -1
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_dec_64)
ATOMIC_OP_ALIAS(atomic_dec_64, _atomic_dec_64)

LEAF(_atomic_dec_64_nv)
1:	REG_LL		v0, 0(a0)
	 nop
	REG_ADDU	v0, -1
	move		t0, v0
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_64_nv, _atomic_dec_64_nv)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_dec_ptr,		_atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ptr_nv,	_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_ulong,		_atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ulong_nv,	_atomic_dec_64_nv)
#else
STRONG_ALIAS(_atomic_dec_ptr,		_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ptr_nv,	_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ulong,		_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ulong_nv,	_atomic_dec_32_nv)
#endif
STRONG_ALIAS(_atomic_dec_uint,		_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_uint_nv,	_atomic_dec_32_nv)

ATOMIC_OP_ALIAS(atomic_dec_ptr,		_atomic_dec_ptr)
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,	_atomic_dec_ptr_nv)
ATOMIC_OP_ALIAS(atomic_dec_uint,	_atomic_dec_uint)
ATOMIC_OP_ALIAS(atomic_dec_uint_nv,	_atomic_dec_uint_nv)
ATOMIC_OP_ALIAS(atomic_dec_ulong,	_atomic_dec_ulong)
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,	_atomic_dec_ulong_nv)

File Added: src/common/lib/libc/arch/mips/atomic/atomic_inc.S
/*	$NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

RCSID("$NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $")

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_inc_32)
1:	INT_LL		t0, 0(a0)
	 nop
	INT_ADDU	t0, 1
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_32, _atomic_inc_32)

LEAF(_atomic_inc_32_nv)
1:	INT_LL		v0, 0(a0)
	 nop
	INT_ADDU	v0, 1
	move		t0, v0
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_32_nv, _atomic_inc_32_nv)

#if !defined(__mips_o32)
LEAF(_atomic_inc_64)
1:	REG_LL		t0, 0(a0)
	 nop
	REG_ADDU	t0, 1
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_inc_64)
ATOMIC_OP_ALIAS(atomic_inc_64, _atomic_inc_64)

LEAF(_atomic_inc_64_nv)
1:	REG_LL		v0, 0(a0)
	 nop
	REG_ADDU	v0, 1
	move		t0, v0
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64_nv, _atomic_inc_64_nv)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_inc_ptr,		_atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ptr_nv,	_atomic_inc_64_nv)
STRONG_ALIAS(_atomic_inc_ulong,		_atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ulong_nv,	_atomic_inc_64_nv)
#else
STRONG_ALIAS(_atomic_inc_ptr,		_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ptr_nv,	_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ulong,		_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ulong_nv,	_atomic_inc_32_nv)
#endif
STRONG_ALIAS(_atomic_inc_uint,		_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_uint_nv,	_atomic_inc_32_nv)

ATOMIC_OP_ALIAS(atomic_inc_ptr,		_atomic_inc_ptr)
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,	_atomic_inc_ptr_nv)
ATOMIC_OP_ALIAS(atomic_inc_uint,	_atomic_inc_uint)
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,	_atomic_inc_uint_nv)
ATOMIC_OP_ALIAS(atomic_inc_ulong,	_atomic_inc_ulong)
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,	_atomic_inc_ulong_nv)

File Added: src/common/lib/libc/arch/mips/atomic/atomic_or.S
/*	$NetBSD: atomic_or.S,v 1.2 2009/12/14 00:39:00 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_or_32)
1:	INT_LL		t0, 0(a0)
	 nop
	or		t0, a1
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_32, _atomic_or_32)

LEAF(_atomic_or_32_nv)
1:	INT_LL		v0, 0(a0)
	 nop
	or		v0, a1
	move		t0, v0
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_32_nv, _atomic_or_32_nv)

#if !defined(__mips_o32)
LEAF(_atomic_or_64)
1:	REG_LL		t0, 0(a0)
	 nop
	or		t0, a1
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_or_64)
ATOMIC_OP_ALIAS(atomic_or_64, _atomic_or_64)

LEAF(_atomic_or_64_nv)
1:	REG_LL		v0, 0(a0)
	 nop
	or		v0, a1
	move		t0, v0
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
	j		ra
	 nop
END(_atomic_or_64_nv)
ATOMIC_OP_ALIAS(atomic_or_64_nv, _atomic_or_64_nv)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_or_ulong,		_atomic_or_64)
STRONG_ALIAS(_atomic_or_ulong_nv,	_atomic_or_64_nv)
#else
STRONG_ALIAS(_atomic_or_ulong,		_atomic_or_32)
STRONG_ALIAS(_atomic_or_ulong_nv,	_atomic_or_32_nv)
#endif
STRONG_ALIAS(_atomic_or_uint,		_atomic_or_32)
STRONG_ALIAS(_atomic_or_uint_nv,	_atomic_or_32_nv)

ATOMIC_OP_ALIAS(atomic_or_uint,		_atomic_or_uint)
ATOMIC_OP_ALIAS(atomic_or_uint_nv,	_atomic_or_uint_nv)
ATOMIC_OP_ALIAS(atomic_or_ulong,	_atomic_or_ulong)
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,	_atomic_or_ulong_nv)

File Added: src/common/lib/libc/arch/mips/atomic/atomic_swap.S
/*	$NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $	*/

/*-
 * Copyright (c) 2008 The NetBSD Foundation, Inc.
 * 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 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>
#include <machine/asm.h>
#include "atomic_op_asm.h"

RCSID("$NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $")

	.text
	.set	noat
	.set	noreorder
	.set	nomacro

LEAF(_atomic_swap_32)
1:	INT_LL		v0, 0(a0)
	 nop
	move		t0, a1
	INT_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
2:
	j		ra
	 nop
END(_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_32, _atomic_swap_32)

#if !defined(__mips_o32)
LEAF(_atomic_swap_64)
1:	REG_LL		v0, 0(a0)
	 nop
	move		t0, a1
	REG_SC		t0, 0(a0)
	beq		t0, zero, 1b
 	 nop
2:
	j		ra
	 nop
END(_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_64, _atomic_swap_64)
#endif

#ifdef _LP64
STRONG_ALIAS(_atomic_swap_ptr,		_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ulong,	_atomic_swap_64)
#else
STRONG_ALIAS(_atomic_swap_ptr,		_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ulong,	_atomic_swap_32)
#endif
STRONG_ALIAS(_atomic_swap_uint,		_atomic_swap_32)

ATOMIC_OP_ALIAS(atomic_swap_ptr,	_atomic_swap_ptr)
ATOMIC_OP_ALIAS(atomic_swap_uint,	_atomic_swap_uint)
ATOMIC_OP_ALIAS(atomic_swap_ulong,	_atomic_swap_ulong)

cvs diff -r1.3 -r1.4 src/common/lib/libc/arch/mips/atomic/membar_ops.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/atomic/membar_ops.S 2008/05/25 15:56:12 1.3
+++ src/common/lib/libc/arch/mips/atomic/membar_ops.S 2009/12/14 00:39:00 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: membar_ops.S,v 1.3 2008/05/25 15:56:12 chs Exp $ */ 1/* $NetBSD: membar_ops.S,v 1.4 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. 4 * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe, and by Andrew Doran. 8 * by Jason R. Thorpe, and by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,50 +21,57 @@ @@ -21,50 +21,57 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include "atomic_op_asm.h" 32#include "atomic_op_asm.h"
33 33
 34#if defined(_KERNEL)
 35
34#ifdef _KERNEL_OPT 36#ifdef _KERNEL_OPT
35#include "opt_cputype.h" 37#include "opt_cputype.h"
36#include "opt_lockdebug.h" 38#include "opt_lockdebug.h"
37#include "opt_multiprocessor.h" 39#include "opt_multiprocessor.h"
38#endif 40#endif
39 41
40#if defined(_KERNEL) 
41 42
42#include <machine/cpu.h> 43#include <machine/cpu.h>
43 44
44#if MIPS_HAS_LLSC != 0 && defined(MULTIPROCESSOR) 45#if (MIPS_HAS_LLSC != 0 && defined(MULTIPROCESSOR)) || !defined(__mips_o32)
 46#define SYNC sync
 47#endif
 48#elif !defined(__mips_o32)
45#define SYNC sync 49#define SYNC sync
46#else 
47#define SYNC /* nothing */ 
48#endif 50#endif
49 51
50 .text 52 .text
51 53
52LEAF(_membar_sync) 54LEAF(_membar_sync)
53 SYNC 
54 j ra 55 j ra
 56#ifdef SYNC
 57 SYNC
 58#else
55 nop 59 nop
 60#endif
56END(_membar_sync) 61END(_membar_sync)
57 62
 63#ifdef _KERNEL
 64STRONG_ALIAS(mb_read, _membar_sync)
 65STRONG_ALIAS(mb_write, _membar_sync)
 66STRONG_ALIAS(mb_memory, _membar_sync)
 67#endif
 68
58ATOMIC_OP_ALIAS(membar_sync,_membar_sync) 69ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
59ATOMIC_OP_ALIAS(membar_enter,_membar_sync) 70ATOMIC_OP_ALIAS(membar_enter,_membar_sync)
60STRONG_ALIAS(_membar_enter,_membar_sync) 71STRONG_ALIAS(_membar_enter,_membar_sync)
61ATOMIC_OP_ALIAS(membar_exit,_membar_sync) 72ATOMIC_OP_ALIAS(membar_exit,_membar_sync)
62STRONG_ALIAS(_membar_exit,_membar_sync) 73STRONG_ALIAS(_membar_exit,_membar_sync)
63ATOMIC_OP_ALIAS(membar_producer,_membar_sync) 74ATOMIC_OP_ALIAS(membar_producer,_membar_sync)
64STRONG_ALIAS(_membar_producer,_membar_sync) 75STRONG_ALIAS(_membar_producer,_membar_sync)
65ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) 76ATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
66STRONG_ALIAS(_membar_consumer,_membar_sync) 77STRONG_ALIAS(_membar_consumer,_membar_sync)
67 
68#else /* _KERNEL */ 
69 
70#endif /* _KERNEL */ 

cvs diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/gen/byte_swap_2.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/gen/byte_swap_2.S 2006/02/08 21:52:36 1.2
+++ src/common/lib/libc/arch/mips/gen/byte_swap_2.S 2009/12/14 00:39:00 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ 1/* $NetBSD: byte_swap_2.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell. 8 * Ralph Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,50 +25,59 @@ @@ -25,50 +25,59 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <mips/asm.h> 35#include <mips/asm.h>
36 36
37#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
38 ASMSTR("from: @(#)htons.s 8.1 (Berkeley) 6/4/93") 38#if 0
39 ASMSTR("$NetBSD: byte_swap_2.S,v 1.2 2006/02/08 21:52:36 simonb Exp $") 39 RCSID("from: @(#)htons.s 8.1 (Berkeley) 6/4/93")
 40#else
 41 RCSID("$NetBSD: byte_swap_2.S,v 1.3 2009/12/14 00:39:00 matt Exp $")
 42#endif
40#endif /* LIBC_SCCS and not lint */ 43#endif /* LIBC_SCCS and not lint */
41 44
42#undef _LOCORE 45#undef _LOCORE
43#define _LOCORE /* XXX not really, just assembly-code source */ 46#define _LOCORE /* XXX not really, just assembly-code source */
44#include <machine/endian.h> 47#include <machine/endian.h>
45 48
46#if defined(_KERNEL) || defined(_STANDALONE) 49#if defined(_KERNEL) || defined(_STANDALONE)
47#define BSWAP16_NAME bswap16 50#define BSWAP16_NAME bswap16
48#else 51#else
49#ifdef __ABICALLS__ 
50 .abicalls 
51#endif 
52#define BSWAP16_NAME __bswap16 52#define BSWAP16_NAME __bswap16
53#endif 53#endif
54 54
55NLEAF(BSWAP16_NAME) 55NLEAF(BSWAP16_NAME)
56#if BYTE_ORDER == LITTLE_ENDIAN 56#if BYTE_ORDER == LITTLE_ENDIAN
57ALEAF(htons) 57ALEAF(htons)
58ALEAF(ntohs) 58ALEAF(ntohs)
59#endif 59#endif
 60#if (__mips == 32 || __mips == 64) && __mips_isa_rev == 2
 61 /*
 62 * If we are on MIPS32r2 or MIPS64r2, use the new instructions
 63 */
 64 wsbh a0, a0 # word swap bytes within halfwords
 65 and v0, a0, 0xffff # bound it to 16bits
 66 j ra
 67#else
60 srl v0, a0, 8 68 srl v0, a0, 8
61 and v0, v0, 0xff 69 and v0, v0, 0xff
62 sll v1, a0, 8 70 sll v1, a0, 8
63 and v1, v1, 0xff00 71 and v1, v1, 0xff00
64 or v0, v0, v1 72 or v0, v0, v1
65 j ra 73 j ra
 74#endif
66END(BSWAP16_NAME) 75END(BSWAP16_NAME)
67 76
68#if BYTE_ORDER == BIG_ENDIAN 77#if BYTE_ORDER == BIG_ENDIAN
69NLEAF(htons) 78NLEAF(htons)
70ALEAF(ntohs) 79ALEAF(ntohs)
71 move v0, a0 80 move v0, a0
72 j ra 81 j ra
73END(htons) 82END(htons)
74#endif 83#endif

cvs diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/gen/byte_swap_4.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/gen/byte_swap_4.S 2006/02/08 21:52:36 1.2
+++ src/common/lib/libc/arch/mips/gen/byte_swap_4.S 2009/12/14 00:39:00 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $ */ 1/* $NetBSD: byte_swap_4.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell. 8 * Ralph Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,54 +25,63 @@ @@ -25,54 +25,63 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <mips/asm.h> 35#include <mips/asm.h>
36 36
37#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
38 ASMSTR("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93") 38#if 0
39 ASMSTR("$NetBSD: byte_swap_4.S,v 1.2 2006/02/08 21:52:36 simonb Exp $") 39 RCSID("from: @(#)htonl.s 8.1 (Berkeley) 6/4/93")
 40#else
 41 RCSID("$NetBSD: byte_swap_4.S,v 1.3 2009/12/14 00:39:00 matt Exp $")
 42#endif
40#endif /* LIBC_SCCS and not lint */ 43#endif /* LIBC_SCCS and not lint */
41 44
42#undef _LOCORE 45#undef _LOCORE
43#define _LOCORE /* XXX not really, just assembly-code source */ 46#define _LOCORE /* XXX not really, just assembly-code source */
44#include <machine/endian.h> 47#include <machine/endian.h>
45 48
46#if defined(_KERNEL) || defined(_STANDALONE) 49#if defined(_KERNEL) || defined(_STANDALONE)
47#define BSWAP32_NAME bswap32 50#define BSWAP32_NAME bswap32
48#else 51#else
49#ifdef __ABICALLS__ 
50 .abicalls 
51#endif 
52#define BSWAP32_NAME __bswap32 52#define BSWAP32_NAME __bswap32
53#endif 53#endif
54 54
55NLEAF(BSWAP32_NAME) # a0 = 0x11223344, return 0x44332211 55NLEAF(BSWAP32_NAME) # a0 = 0x11223344, return 0x44332211
56#if BYTE_ORDER == LITTLE_ENDIAN 56#if BYTE_ORDER == LITTLE_ENDIAN
57ALEAF(htonl) # a0 = 0x11223344, return 0x44332211 57ALEAF(htonl) # a0 = 0x11223344, return 0x44332211
58ALEAF(ntohl) 58ALEAF(ntohl)
59#endif 59#endif
 60#if (__mips == 32 || __mips == 64) && __mips_isa_rev == 2
 61 /*
 62 * If we are on MIPS32R2 or MIPS64R2 it's much easier
 63 */
 64 wsbh a0, a0 # word swap bytes within halfwords
 65 rotr v0, a0, 16 # rotate word 16bits
 66 j ra
 67#else
60 srl v1, a0, 24 # v1 = 0x00000011 68 srl v1, a0, 24 # v1 = 0x00000011
61 sll v0, a0, 24 # v0 = 0x44000000 69 sll v0, a0, 24 # v0 = 0x44000000
62 or v0, v0, v1 70 or v0, v0, v1
63 and v1, a0, 0xff00 71 and v1, a0, 0xff00
64 sll v1, v1, 8 # v1 = 0x00330000 72 sll v1, v1, 8 # v1 = 0x00330000
65 or v0, v0, v1 73 or v0, v0, v1
66 srl v1, a0, 8 74 srl v1, a0, 8
67 and v1, v1, 0xff00 # v1 = 0x00002200 75 and v1, v1, 0xff00 # v1 = 0x00002200
68 or v0, v0, v1 76 or v0, v0, v1
69 j ra 77 j ra
 78#endif
70END(BSWAP32_NAME) 79END(BSWAP32_NAME)
71 80
72#if BYTE_ORDER == BIG_ENDIAN 81#if BYTE_ORDER == BIG_ENDIAN
73NLEAF(htonl) # a0 = 0x11223344, return 0x44332211 82NLEAF(htonl) # a0 = 0x11223344, return 0x44332211
74ALEAF(ntohl) 83ALEAF(ntohl)
75 move v0, a0 84 move v0, a0
76 j ra 85 j ra
77END(htonl) 86END(htonl)
78#endif 87#endif

File Added: src/common/lib/libc/arch/mips/gen/byte_swap_8.S
/*	$NetBSD: byte_swap_8.S,v 1.2 2009/12/14 00:39:00 matt 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 <mips/asm.h>

#if defined(LIBC_SCCS) && !defined(lint)
	RCSID("$NetBSD: byte_swap_8.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
#endif /* LIBC_SCCS and not lint */

#undef _LOCORE
#define _LOCORE		/* XXX not really, just assembly-code source */
#include <machine/endian.h>

NLEAF(bswap64)	# a0 = 0xffeeddccbbaa9988 return 0x8899aabbccddeeff
#if (__mips == 32 || __mips == 64) && __mips_isa_rev == 2
#if !defined(__mips_o32)
	/*
	 * If we are on MIPS32r2 or MIPS64r2 use the new instructions.
	 */
	dsbh	v0, a0			# dwords swap bytes within halfwords
	dshd	v0, v0			# dwords swap halwords within dwords
	j	ra
#else /* defined(__mips_o32) */
	/*
	 * If we are on MIPS32r2 or MIPS64r2 use the new instructions.
	 * (except we must use the 32bit versions) 
	 */
	wsbh	v1, a0			# word swap bytes within halfwords
	wsbh	v0, a1			# word swap bytes within halfwords
	rotr	v1, v1, 16		# rotate word 16bits and swap word
	rotr	v0, v0, 16		# rotate word 16bits and swap word
	j	ra
#endif /* defined(__mips_o32) */
#elif !defined(__mips_o32)
					# a0  = 0xffeeddccbbaa9988
	li	t0, 0xffff		# t0  = 0x000000000000ffff
	dsll	t1, t0, 32		# t1  = 0x0000ffff00000000
	or	t0, t1			# t0  = 0x0000ffff0000ffff
	dsll	t2, t0, 8		# t2  = 0x00ffff0000ffff00
	xor	t2, t0			# t2  = 0x00ff00ff00ff00ff
	/*
	 * We could swap by halfword, but that would be one instruction longer.
	 */
	dsrl	ta0, a0, 32		# ta0 = 0x00000000ffeeddcc
	dsll	ta1, a0, 32		# ta1 = 0xbbaa998800000000
	or	a1, ta0, ta1		# a1  = 0xbbaa9988ffeeddcc
					# words swapped
	and	ta0, a1, t0		# ta0 = 0x000099880000ddcc
	dsrl	ta1, a1, 16		# ta1 = 0x0000bbaa9988ffee
	and	ta1, t0			# ta1 = 0x0000bbaa0000ffee
	dsll	a2, ta0, 16		# a2  = 0x99880000ddcc0000
	or	a2, ta1			# a2  = 0x9988bbaaddccffee
					# halfwords swapped
	and	ta0, a2, t2		# ta0 = 0x008800aa00cc00ee
	dsrl	ta1, a2, 8		# ta1 = 0x009988bbaaddccff
	and	ta1, t2			# ta1 = 0x009900bb00dd00ff
	dsll	v0, ta0, 8		# v0  = 0x8800aa00cc00ee00
	or	v0, ta1			# v0  = 0x8899aabbccddeeff
					# bytes swapped
	j	ra
#else /* defined(__mips_o32) */
	/*
	 * 32bit ABI.
	 */
					# a0  = 0xccddeeff
					# a1  = 0x8899aabb
	srl	t0, a0, 24		# t0  = 0x000000cc
	srl	t1, a1, 24		# t1  = 0x00000088
	sll	ta0, a0, 24		# ta0 = 0xff000000
	sll	ta1, a1, 24		# ta1 = 0xbb000000
	or	ta0, ta0, t0		# ta0 = 0xff0000cc
	or	ta1, ta1, t1		# ta1 = 0xbb000088
	and	t0, a0, 0xff00		# t0  = 0x0000ee00
	and	t1, a1, 0xff00		# t1  = 0x0000aa00
	sll	t0, t0, 8		# t0  = 0x00ee0000
	sll	t1, t1, 8		# t1  = 0x00aa0000
	or	ta0, ta0, t0		# ta0 = 0xffee00cc
	or	ta1, ta1, t1		# ta1 = 0xbbaa0088
	srl	t0, a0, 8		# t0  = 0x00ccddee
	srl	t1, a1, 8		# t1  = 0x008899aa
	and	t0, t0, 0xff00		# t0  = 0x0000dd00
	and	t1, t1, 0xff00		# t1  = 0x00009900
	or	v1, ta0, t0		# v1  = 0xffeeddcc
	or	v0, ta1, t1		# v0  = 0xbbaa9988
	j	ra
#endif /* defined(__mips_o32) */
END(bswap64)

cvs diff -r1.2 -r1.3 src/common/lib/libc/arch/mips/string/bcopy.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/string/bcopy.S 2005/12/27 11:23:53 1.2
+++ src/common/lib/libc/arch/mips/string/bcopy.S 2009/12/14 00:39:00 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $ */ 1/* $NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */
2 2
3/* 3/*
4 * Mach Operating System 4 * Mach Operating System
5 * Copyright (c) 1993 Carnegie Mellon University 5 * Copyright (c) 1993 Carnegie Mellon University
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Permission to use, copy, modify and distribute this software and its 8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright 9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the 10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions 11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation. 12 * thereof, and that both notices appear in supporting documentation.
13 * 13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
@@ -33,33 +33,32 @@ @@ -33,33 +33,32 @@
33 * 33 *
34 * Fast copy routine. Derived from aligned_block_copy. 34 * Fast copy routine. Derived from aligned_block_copy.
35 */ 35 */
36 36
37 37
38#include <mips/asm.h> 38#include <mips/asm.h>
39#ifndef _LOCORE 39#ifndef _LOCORE
40#define _LOCORE /* XXX not really, just assembly-code source */ 40#define _LOCORE /* XXX not really, just assembly-code source */
41#endif 41#endif
42#include <machine/endian.h> 42#include <machine/endian.h>
43 43
44 44
45#if defined(LIBC_SCCS) && !defined(lint) 45#if defined(LIBC_SCCS) && !defined(lint)
46 ASMSTR("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93") 46#if 0
47 ASMSTR("$NetBSD: bcopy.S,v 1.2 2005/12/27 11:23:53 tsutsui Exp $") 47 RCSID("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93")
48#endif /* LIBC_SCCS and not lint */ 48#else
49 49 RCSID("$NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $")
50#ifdef __ABICALLS__ 
51 .abicalls 
52#endif 50#endif
 51#endif /* LIBC_SCCS and not lint */
53 52
54/* 53/*
55 * bcopy(caddr_t src, caddr_t dst, unsigned int len) 54 * bcopy(caddr_t src, caddr_t dst, unsigned int len)
56 * 55 *
57 * a0 src address 56 * a0 src address
58 * a1 dst address 57 * a1 dst address
59 * a2 length 58 * a2 length
60 */ 59 */
61 60
62#if defined(MEMCOPY) || defined(MEMMOVE) 61#if defined(MEMCOPY) || defined(MEMMOVE)
63#ifdef MEMCOPY 62#ifdef MEMCOPY
64#define FUNCTION memcpy 63#define FUNCTION memcpy
65#else 64#else
@@ -93,202 +92,203 @@ LEAF(FUNCTION) @@ -93,202 +92,203 @@ LEAF(FUNCTION)
93 * There are four alignment cases (with frequency) 92 * There are four alignment cases (with frequency)
94 * (Based on measurements taken with a DECstation 5000/200 93 * (Based on measurements taken with a DECstation 5000/200
95 * inside a Mach kernel.) 94 * inside a Mach kernel.)
96 * 95 *
97 * aligned -> aligned (mostly) 96 * aligned -> aligned (mostly)
98 * unaligned -> aligned (sometimes) 97 * unaligned -> aligned (sometimes)
99 * aligned,unaligned -> unaligned (almost never) 98 * aligned,unaligned -> unaligned (almost never)
100 * 99 *
101 * Note that we could add another case that checks if 100 * Note that we could add another case that checks if
102 * the destination and source are unaligned but the 101 * the destination and source are unaligned but the
103 * copy is alignable. eg if src and dest are both 102 * copy is alignable. eg if src and dest are both
104 * on a halfword boundary. 103 * on a halfword boundary.
105 */ 104 */
106 andi t1,DSTREG,3 # get last 3 bits of dest 105 andi t1,DSTREG,(SZREG-1) # get last bits of dest
107 bne t1,zero,3f 106 bne t1,zero,3f # dest unaligned
108 andi t0,SRCREG,3 # get last 3 bits of src 107 andi t0,SRCREG,(SZREG-1) # get last bits of src
109 bne t0,zero,5f 108 bne t0,zero,5f
110 109
111 /* 110 /*
112 * Forward aligned->aligned copy, 8*4 bytes at a time. 111 * Forward aligned->aligned copy, 8 words at a time.
113 */ 112 */
114 li AT,-32 11398:
115 and t0,SIZEREG,AT # count truncated to multiple of 32 */ 114 li AT,-(SZREG*8)
116 addu a3,SRCREG,t0 # run fast loop up to this address 115 and t0,SIZEREG,AT # count truncated to multiples
117 sltu AT,SRCREG,a3 # any work to do? 116 PTR_ADDU a3,SRCREG,t0 # run fast loop up to this addr
118 beq AT,zero,2f 117 sltu AT,SRCREG,a3 # any work to do?
119 subu SIZEREG,t0 118 beq AT,zero,2f
 119 PTR_SUBU SIZEREG,t0
120 120
121 /* 121 /*
122 * loop body 122 * loop body
123 */ 123 */
1241: # cp 1241: # cp
125 lw t3,0(SRCREG) 125 REG_L t3,(0*SZREG)(SRCREG)
126 lw v1,4(SRCREG) 126 REG_L v1,(1*SZREG)(SRCREG)
127 lw t0,8(SRCREG) 127 REG_L t0,(2*SZREG)(SRCREG)
128 lw t1,12(SRCREG) 128 REG_L t1,(3*SZREG)(SRCREG)
129 addu SRCREG,32 129 PTR_ADDU SRCREG,SZREG*8
130 sw t3,0(DSTREG) 130 REG_S t3,(0*SZREG)(DSTREG)
131 sw v1,4(DSTREG) 131 REG_S v1,(1*SZREG)(DSTREG)
132 sw t0,8(DSTREG) 132 REG_S t0,(2*SZREG)(DSTREG)
133 sw t1,12(DSTREG) 133 REG_S t1,(3*SZREG)(DSTREG)
134 lw t1,-4(SRCREG) 134 REG_L t1,(-1*SZREG)(SRCREG)
135 lw t0,-8(SRCREG) 135 REG_L t0,(-2*SZREG)(SRCREG)
136 lw v1,-12(SRCREG) 136 REG_L v1,(-3*SZREG)(SRCREG)
137 lw t3,-16(SRCREG) 137 REG_L t3,(-4*SZREG)(SRCREG)
138 addu DSTREG,32 138 PTR_ADDU DSTREG,SZREG*8
139 sw t1,-4(DSTREG) 139 REG_S t1,(-1*SZREG)(DSTREG)
140 sw t0,-8(DSTREG) 140 REG_S t0,(-2*SZREG)(DSTREG)
141 sw v1,-12(DSTREG) 141 REG_S v1,(-3*SZREG)(DSTREG)
142 bne SRCREG,a3,1b 142 bne SRCREG,a3,1b
143 sw t3,-16(DSTREG) 143 REG_S t3,(-4*SZREG)(DSTREG)
144 144
145 /* 145 /*
146 * Copy a word at a time, no loop unrolling. 146 * Copy a word at a time, no loop unrolling.
147 */ 147 */
1482: # wordcopy 1482: # wordcopy
149 andi t2,SIZEREG,3 # get byte count / 4 149 andi t2,SIZEREG,(SZREG-1) # get byte count / SZREG
150 subu t2,SIZEREG,t2 # t2 = number of words to copy * 4 150 PTR_SUBU t2,SIZEREG,t2 # t2 = words to copy * SZREG
151 beq t2,zero,3f 151 beq t2,zero,3f
152 addu t0,SRCREG,t2 # stop at t0 152 PTR_ADDU t0,SRCREG,t2 # stop at t0
153 subu SIZEREG,SIZEREG,t2 153 PTR_SUBU SIZEREG,SIZEREG,t2
1541: 1541:
155 lw t3,0(SRCREG) 155 REG_L t3,0(SRCREG)
156 addu SRCREG,4 156 PTR_ADDU SRCREG,SZREG
157 sw t3,0(DSTREG) 157 REG_S t3,0(DSTREG)
158 bne SRCREG,t0,1b 158 bne SRCREG,t0,1b
159 addu DSTREG,4 159 PTR_ADDU DSTREG,SZREG
160 160
1613: # bytecopy 1613: # bytecopy
162 beq SIZEREG,zero,4f # nothing left to do? 162 beq SIZEREG,zero,4f # nothing left to do?
163 nop 163 nop
1641: 1641:
165 lb t3,0(SRCREG) 165 lb t3,0(SRCREG)
166 addu SRCREG,1 166 PTR_ADDU SRCREG,1
167 sb t3,0(DSTREG) 167 sb t3,0(DSTREG)
168 subu SIZEREG,1 168 PTR_SUBU SIZEREG,1
169 bgtz SIZEREG,1b 169 bgtz SIZEREG,1b
170 addu DSTREG,1 170 PTR_ADDU DSTREG,1
171 171
1724: # copydone 1724: # copydone
173 j ra 173 j ra
174 nop 174 nop
175 175
176 /* 176 /*
177 * Copy from unaligned source to aligned dest. 177 * Copy from unaligned source to aligned dest.
178 */ 178 */
1795: # destaligned 1795: # destaligned
180 andi t0,SIZEREG,3 # t0 = bytecount mod 4 180 andi t0,SIZEREG,(SZREG-1) # t0 = bytecount mod SZREG
181 subu a3,SIZEREG,t0 # number of words to transfer 181 PTR_SUBU a3,SIZEREG,t0 # number of words to transfer
182 beq a3,zero,3b 182 beq a3,zero,3b
183 nop 183 nop
184 move SIZEREG,t0 # this many to do after we are done 184 move SIZEREG,t0 # this many to do after we are done
185 addu a3,SRCREG,a3 # stop point 185 PTR_ADDU a3,SRCREG,a3 # stop point
186 186
1871: 1871:
188 LWHI t3,0(SRCREG) 188 REG_LHI t3,0(SRCREG)
189 LWLO t3,3(SRCREG) 189 REG_LLO t3,SZREG-1(SRCREG)
190 addi SRCREG,4 190 PTR_ADDI SRCREG,SZREG
191 sw t3,0(DSTREG) 191 REG_S t3,0(DSTREG)
192 bne SRCREG,a3,1b 192 bne SRCREG,a3,1b
193 addi DSTREG,4 193 PTR_ADDI DSTREG,SZREG
194 194
195 j 3b 195 b 3b
196 nop 196 nop
197 197
1986: # backcopy -- based on above 1986: # backcopy -- based on above
199 addu SRCREG,SIZEREG 199 PTR_ADDU SRCREG,SIZEREG
200 addu DSTREG,SIZEREG 200 PTR_ADDU DSTREG,SIZEREG
201 andi t1,DSTREG,3 # get last 3 bits of dest 201 andi t1,DSTREG,SZREG-1 # get last 3 bits of dest
202 bne t1,zero,3f 202 bne t1,zero,3f
203 andi t0,SRCREG,3 # get last 3 bits of src 203 andi t0,SRCREG,SZREG-1 # get last 3 bits of src
204 bne t0,zero,5f 204 bne t0,zero,5f
205 205
206 /* 206 /*
207 * Forward aligned->aligned copy, 8*4 bytes at a time. 207 * Forward aligned->aligned copy, 8*4 bytes at a time.
208 */ 208 */
209 li AT,-32 209 li AT,(-8*SZREG)
210 and t0,SIZEREG,AT # count truncated to multiple of 32 210 and t0,SIZEREG,AT # count truncated to multiple of 32
211 beq t0,zero,2f # any work to do? 211 beq t0,zero,2f # any work to do?
212 subu SIZEREG,t0 212 PTR_SUBU SIZEREG,t0
213 subu a3,SRCREG,t0 213 PTR_SUBU a3,SRCREG,t0
214 214
215 /* 215 /*
216 * loop body 216 * loop body
217 */ 217 */
2181: # cp 2181: # cp
219 lw t3,-16(SRCREG) 219 REG_L t3,(-4*SZREG)(SRCREG)
220 lw v1,-12(SRCREG) 220 REG_L v1,(-3*SZREG)(SRCREG)
221 lw t0,-8(SRCREG) 221 REG_L t0,(-2*SZREG)(SRCREG)
222 lw t1,-4(SRCREG) 222 REG_L t1,(-1*SZREG)(SRCREG)
223 subu SRCREG,32 223 PTR_SUBU SRCREG,8*SZREG
224 sw t3,-16(DSTREG) 224 REG_S t3,(-4*SZREG)(DSTREG)
225 sw v1,-12(DSTREG) 225 REG_S v1,(-3*SZREG)(DSTREG)
226 sw t0,-8(DSTREG) 226 REG_S t0,(-2*SZREG)(DSTREG)
227 sw t1,-4(DSTREG) 227 REG_S t1,(-1*SZREG)(DSTREG)
228 lw t1,12(SRCREG) 228 REG_L t1,(3*SZREG)(SRCREG)
229 lw t0,8(SRCREG) 229 REG_L t0,(2*SZREG)(SRCREG)
230 lw v1,4(SRCREG) 230 REG_L v1,(1*SZREG)(SRCREG)
231 lw t3,0(SRCREG) 231 REG_L t3,(0*SZREG)(SRCREG)
232 subu DSTREG,32 232 PTR_SUBU DSTREG,8*SZREG
233 sw t1,12(DSTREG) 233 REG_S t1,(3*SZREG)(DSTREG)
234 sw t0,8(DSTREG) 234 REG_S t0,(2*SZREG)(DSTREG)
235 sw v1,4(DSTREG) 235 REG_S v1,(1*SZREG)(DSTREG)
236 bne SRCREG,a3,1b 236 bne SRCREG,a3,1b
237 sw t3,0(DSTREG) 237 REG_S t3,(0*SZREG)(DSTREG)
238 238
239 /* 239 /*
240 * Copy a word at a time, no loop unrolling. 240 * Copy a word at a time, no loop unrolling.
241 */ 241 */
2422: # wordcopy 2422: # wordcopy
243 andi t2,SIZEREG,3 # get byte count / 4 243 andi t2,SIZEREG,SZREG-1 # get byte count / 4
244 subu t2,SIZEREG,t2 # t2 = number of words to copy * 4 244 PTR_SUBU t2,SIZEREG,t2 # t2 = number of words to copy
245 beq t2,zero,3f 245 beq t2,zero,3f
246 subu t0,SRCREG,t2 # stop at t0 246 PTR_SUBU t0,SRCREG,t2 # stop at t0
247 subu SIZEREG,SIZEREG,t2 247 PTR_SUBU SIZEREG,SIZEREG,t2
2481: 2481:
249 lw t3,-4(SRCREG) 249 REG_L t3,-SZREG(SRCREG)
250 subu SRCREG,4 250 PTR_SUBU SRCREG,SZREG
251 sw t3,-4(DSTREG) 251 REG_S t3,-SZREG(DSTREG)
252 bne SRCREG,t0,1b 252 bne SRCREG,t0,1b
253 subu DSTREG,4 253 PTR_SUBU DSTREG,SZREG
254 254
2553: # bytecopy 2553: # bytecopy
256 beq SIZEREG,zero,4f # nothing left to do? 256 beq SIZEREG,zero,4f # nothing left to do?
257 nop 257 nop
2581: 2581:
259 lb t3,-1(SRCREG) 259 lb t3,-1(SRCREG)
260 subu SRCREG,1 260 PTR_SUBU SRCREG,1
261 sb t3,-1(DSTREG) 261 sb t3,-1(DSTREG)
262 subu SIZEREG,1 262 PTR_SUBU SIZEREG,1
263 bgtz SIZEREG,1b 263 bgtz SIZEREG,1b
264 subu DSTREG,1 264 PTR_SUBU DSTREG,1
265 265
2664: # copydone 2664: # copydone
267 j ra 267 j ra
268 nop 268 nop
269 269
270 /* 270 /*
271 * Copy from unaligned source to aligned dest. 271 * Copy from unaligned source to aligned dest.
272 */ 272 */
2735: # destaligned 2735: # destaligned
274 andi t0,SIZEREG,3 # t0 = bytecount mod 4 274 andi t0,SIZEREG,SZREG-1 # t0 = bytecount mod 4
275 subu a3,SIZEREG,t0 # number of words to transfer 275 PTR_SUBU a3,SIZEREG,t0 # number of words to transfer
276 beq a3,zero,3b 276 beq a3,zero,3b
277 nop 277 nop
278 move SIZEREG,t0 # this many to do after we are done 278 move SIZEREG,t0 # this many to do after we are done
279 subu a3,SRCREG,a3 # stop point 279 PTR_SUBU a3,SRCREG,a3 # stop point
280 280
2811: 2811:
282 LWHI t3,-4(SRCREG) 282 REG_LHI t3,-SZREG(SRCREG)
283 LWLO t3,-1(SRCREG) 283 REG_LLO t3,-1(SRCREG)
284 subu SRCREG,4 284 PTR_SUBU SRCREG,SZREG
285 sw t3,-4(DSTREG) 285 REG_S t3,-SZREG(DSTREG)
286 bne SRCREG,a3,1b 286 bne SRCREG,a3,1b
287 subu DSTREG,4 287 PTR_SUBU DSTREG,SZREG
288 288
289 j 3b 289 b 3b
290 nop 290 nop
291 291
292 .set reorder 292 .set reorder
293 .set at 293 .set at
294 END(FUNCTION) 294 END(FUNCTION)

cvs diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/ffs.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/string/ffs.S 2005/12/20 19:28:49 1.1
+++ src/common/lib/libc/arch/mips/string/ffs.S 2009/12/14 00:39:00 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */ 1/* $NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell. 8 * Ralph Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,34 +25,30 @@ @@ -25,34 +25,30 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <mips/asm.h> 35#include <mips/asm.h>
36 36
37#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
38 ASMSTR("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") 38 /* RCSID("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") */
39 ASMSTR("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $") 39 RCSID("$NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
40#endif /* LIBC_SCCS and not lint */ 40#endif /* LIBC_SCCS and not lint */
41 41
42#ifdef __ABICALLS__ 
43 .abicalls 
44#endif 
45 
46/* bit = ffs(value) */ 42/* bit = ffs(value) */
47 43
48LEAF(ffs) 44LEAF(ffs)
49 move v0, zero 45 move v0, zero
50 beq a0, zero, done 46 beq a0, zero, done
511: 471:
52 and v1, a0, 1 # bit set? 48 and v1, a0, 1 # bit set?
53 addu v0, v0, 1 49 addu v0, v0, 1
54 srl a0, a0, 1 50 srl a0, a0, 1
55 beq v1, zero, 1b # no, continue 51 beq v1, zero, 1b # no, continue
56done: 52done:
57 j ra 53 j ra
58END(ffs) 54END(ffs)

cvs diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strcmp.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/string/strcmp.S 2005/12/20 19:28:50 1.1
+++ src/common/lib/libc/arch/mips/string/strcmp.S 2009/12/14 00:39:00 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */ 1/* $NetBSD: strcmp.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell. 8 * Ralph Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,43 +25,39 @@ @@ -25,43 +25,39 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <mips/asm.h> 35#include <mips/asm.h>
36 36
37#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
38 ASMSTR("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93") 38 /* RCSID("from: @(#)strcmp.s 8.1 (Berkeley) 6/4/93") */
39 ASMSTR("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:50 christos Exp $") 39 RCSID("$NetBSD: strcmp.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
40#endif /* LIBC_SCCS and not lint */ 40#endif /* LIBC_SCCS and not lint */
41 41
42#ifdef __ABICALLS__ 
43 .abicalls 
44#endif 
45 
46/* 42/*
47 * NOTE: this version assumes unsigned chars in order to be "8 bit clean". 43 * NOTE: this version assumes unsigned chars in order to be "8 bit clean".
48 */ 44 */
49LEAF(strcmp) 45LEAF(strcmp)
501: 461:
51 lbu t0, 0(a0) # get two bytes and compare them 47 lbu t0, 0(a0) # get two bytes and compare them
52 lbu t1, 0(a1) 48 lbu t1, 0(a1)
53 beq t0, zero, LessOrEq # end of first string? 49 beq t0, zero, LessOrEq # end of first string?
54 bne t0, t1, NotEq 50 bne t0, t1, NotEq
55 lbu t0, 1(a0) # unroll loop 51 lbu t0, 1(a0) # unroll loop
56 lbu t1, 1(a1) 52 lbu t1, 1(a1)
57 add a0, a0, 2 53 PTR_ADD a0, a0, 2
58 beq t0, zero, LessOrEq # end of first string? 54 beq t0, zero, LessOrEq # end of first string?
59 add a1, a1, 2 55 PTR_ADD a1, a1, 2
60 beq t0, t1, 1b 56 beq t0, t1, 1b
61NotEq: 57NotEq:
62 subu v0, t0, t1 58 subu v0, t0, t1
63 j ra 59 j ra
64LessOrEq: 60LessOrEq:
65 subu v0, zero, t1 61 subu v0, zero, t1
66 j ra 62 j ra
67END(strcmp) 63END(strcmp)

cvs diff -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strlen.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/mips/string/strlen.S 2005/12/20 19:28:50 1.1
+++ src/common/lib/libc/arch/mips/string/strlen.S 2009/12/14 00:39:00 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */ 1/* $NetBSD: strlen.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Ralph Campbell. 8 * Ralph Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,30 +25,26 @@ @@ -25,30 +25,26 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include <mips/asm.h> 35#include <mips/asm.h>
36 36
37#if defined(LIBC_SCCS) && !defined(lint) 37#if defined(LIBC_SCCS) && !defined(lint)
38 ASMSTR("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93") 38 /* RCSID("from: @(#)strlen.s 8.1 (Berkeley) 6/4/93") */
39 ASMSTR("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $") 39 RCSID("$NetBSD: strlen.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
40#endif /* LIBC_SCCS and not lint */ 40#endif /* LIBC_SCCS and not lint */
41 41
42#ifdef __ABICALLS__ 
43 .abicalls 
44#endif 
45 
46LEAF(strlen) 42LEAF(strlen)
47 addu v1, a0, 1 43 PTR_ADDU v1, a0, 1
481: 441:
49 lb v0, 0(a0) # get byte from string 45 lb v0, 0(a0) # get byte from string
50 addu a0, a0, 1 # increment pointer 46 PTR_ADDU a0, a0, 1 # increment pointer
51 bne v0, zero, 1b # continue if not end 47 bne v0, zero, 1b # continue if not end
52 subu v0, a0, v1 # compute length - 1 for '\0' char 48 PTR_SUBU v0, a0, v1 # compute length - 1 for '\0' char
53 j ra 49 j ra
54END(strlen) 50END(strlen)

File Deleted: src/common/lib/libc/arch/mips/string/Attic/memset.S

cvs diff -r1.6 -r1.7 src/common/lib/libc/atomic/atomic_init_testset.c (expand / switch to unified diff)

--- src/common/lib/libc/atomic/atomic_init_testset.c 2009/01/30 14:29:44 1.6
+++ src/common/lib/libc/atomic/atomic_init_testset.c 2009/12/14 00:39:00 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: atomic_init_testset.c,v 1.6 2009/01/30 14:29:44 skrll Exp $ */ 1/* $NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * libc glue for atomic operations where the hardware does not provide 30 * libc glue for atomic operations where the hardware does not provide
31 * compare-and-swap. It's assumed that this will only be used on 32-bit 31 * compare-and-swap. It's assumed that this will only be used on 32-bit
32 * platforms. 32 * platforms.
33 * 33 *
34 * This should be compiled with '-fno-reorder-blocks -fomit-frame-pointer' 34 * This should be compiled with '-fno-reorder-blocks -fomit-frame-pointer'
35 * if using gcc. 35 * if using gcc.
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__RCSID("$NetBSD: atomic_init_testset.c,v 1.6 2009/01/30 14:29:44 skrll Exp $"); 39__RCSID("$NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $");
40 40
41#include "atomic_op_namespace.h" 41#include "atomic_op_namespace.h"
42 42
43#include <sys/types.h> 43#include <sys/types.h>
44#include <sys/atomic.h> 44#include <sys/atomic.h>
45#include <sys/lock.h> 45#include <sys/lock.h>
46#include <sys/ras.h> 46#include <sys/ras.h>
47#include <sys/sysctl.h> 47#include <sys/sysctl.h>
48 48
49#include <string.h> 49#include <string.h>
50 50
51#define I2 __SIMPLELOCK_UNLOCKED, __SIMPLELOCK_UNLOCKED, 51#define I2 __SIMPLELOCK_UNLOCKED, __SIMPLELOCK_UNLOCKED,
52#define I16 I2 I2 I2 I2 I2 I2 I2 I2 52#define I16 I2 I2 I2 I2 I2 I2 I2 I2
@@ -81,27 +81,27 @@ _atomic_cas_up(volatile uint32_t *ptr, u @@ -81,27 +81,27 @@ _atomic_cas_up(volatile uint32_t *ptr, u
81 *ptr = new; 81 *ptr = new;
82 RAS_END(_atomic_cas); 82 RAS_END(_atomic_cas);
83 83
84 return ret; 84 return ret;
85} 85}
86#endif 86#endif
87 87
88static uint32_t 88static uint32_t
89_atomic_cas_mp(volatile uint32_t *ptr, uint32_t old, uint32_t new) 89_atomic_cas_mp(volatile uint32_t *ptr, uint32_t old, uint32_t new)
90{ 90{
91 __cpu_simple_lock_t *lock; 91 __cpu_simple_lock_t *lock;
92 uint32_t ret; 92 uint32_t ret;
93 93
94 lock = &atomic_locks[((uint32_t)ptr >> 3) & 127]; 94 lock = &atomic_locks[((uintptr_t)ptr >> 3) & 127];
95 __cpu_simple_lock(lock); 95 __cpu_simple_lock(lock);
96 ret = *ptr; 96 ret = *ptr;
97 if (__predict_true(ret == old)) { 97 if (__predict_true(ret == old)) {
98 *ptr = new; 98 *ptr = new;
99 } 99 }
100 __cpu_simple_unlock(lock); 100 __cpu_simple_unlock(lock);
101 101
102 return ret; 102 return ret;
103} 103}
104 104
105uint32_t 105uint32_t
106_atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new) 106_atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new)
107{ 107{

File Added: src/common/lib/libc/string/bzero2.c
/*-
 * Copyright (c) 2009 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Matt Thomas <matt@3am-software.com>.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 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.
 */

#define	BZERO

#include "memset2.c"

#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: bzero2.c,v 1.2 2009/12/14 00:39:01 matt Exp $");
#endif /* LIBC_SCCS and not lint */

File Added: src/common/lib/libc/string/memset2.c
/*-
 * Copyright (c) 2009 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Matt Thomas <matt@3am-software.com>.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 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/types.h>

#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <inttypes.h>
#else
#include <lib/libkern/libkern.h>
#include <machine/limits.h>
#endif 

#include <sys/endian.h>
#include <machine/types.h>

#ifdef TEST
#include <assert.h>
#define _DIAGASSERT(a)		assert(a)
#endif

#ifdef _FORTIFY_SOURCE
#undef bzero
#undef memset
#endif

#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: memset2.c,v 1.2 2009/12/14 00:39:01 matt Exp $");    
#endif /* LIBC_SCCS and not lint */

/*
 * Assume uregister_t is the widest non-synthetic unsigned type.
 */
typedef uregister_t memword_t;

#ifdef BZERO
static inline
#define	memset memset0
#endif

#ifdef TEST
static
#define memset test_memset
#endif

#ifdef CTASSERT
CTASSERT((~(memword_t)0U >> 1) != ~(memword_t)0U);
#endif

void *
memset(void *addr, int c, size_t len)
{
	memword_t *dstp = addr;
	memword_t *edstp;
	memword_t fill;
#ifndef __OPTIMIZE_SIZE__
	memword_t keep_mask = 0;
#endif
	size_t fill_count;

	_DIAGASSERT(addr != 0);

	if (__predict_false(len == 0))
		return addr;

	/*
	 * Pad out the fill byte (v) across a memword_t.
	 * The conditional at the end prevents GCC from complaing about
	 * shift count >= width of type 
	 */
	fill = c;
	fill |= fill << 8;
	fill |= fill << 16;
	fill |= fill << (sizeof(c) < sizeof(fill) ? 32 : 0);

	/*
	 * Get the number of unaligned bytes to fill in the first word.
	 */
	fill_count = -(uintptr_t)addr & (sizeof(memword_t) - 1);

	if (__predict_false(fill_count != 0)) {
#ifndef __OPTIMIZE_SIZE__
		/*
		 * We want to clear <fill_count> trailing bytes in the word.
		 * On big/little endian, these are the least/most significant,
		 * bits respectively.  So as we shift, the keep_mask will only
		 * have bits set for the bytes we won't be filling.
		 */
#if BYTE_ORDER == BIG_ENDIAN
		keep_mask = ~(memword_t)0U << (fill_count * 8);
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
		keep_mask = ~(memword_t)0U >> (fill_count * 8);
#endif
		/*
		 * Make sure dstp is aligned to a memword_t boundary.
		 */
		dstp = (memword_t *)((uintptr_t)addr & -sizeof(memword_t));
		if (len >= fill_count) {
			/*
			 * If we can fill the rest of this word, then we mask
			 * off the bytes we are filling and then fill in those
			 * bytes with the new fill value.
			 */
			*dstp = (*dstp & keep_mask) | (fill & ~keep_mask);
			len -= fill_count;
			if (__predict_false(len == 0))
				return addr;
			/*
			 * Since we were able to fill the rest of this word,
			 * we will advance to the next word and thus have no
			 * bytes to preserve.
			 *
			 * If we don't have enough to fill the rest of this
			 * word, we will fall through the following loop
			 * (since there are no full words to fill).  Then we
			 * use the keep_mask above to preserve the leading
			 * bytes of word.
			 */
			dstp++;
			keep_mask = 0;
		} else {
			len += (uintptr_t)addr & (sizeof(memword_t) - 1);
		}
#else /* __OPTIMIZE_SIZE__ */
		uint8_t *dp, *ep;
		if (len < fill_count)
			fill_count = len;
		for (dp = (uint8_t *)dstp, ep = dp + fill_count;
		     dp != ep; dp++)
			*dp = fill;
		if ((len -= fill_count) == 0)
			return addr;
		dstp = (memword_t *)ep;
#endif /* __OPTIMIZE_SIZE__ */
	}

	/*
	 * Simply fill memory one word at time (for as many full words we have
	 * to write).
	 */
	for (edstp = dstp + len / sizeof(memword_t); dstp != edstp; dstp++)
		*dstp = fill;

	/*
	 * We didn't subtract out the full words we just filled since we know
	 * by the time we get here we will have less than a words worth to
	 * write.  So we can concern ourselves with only the subword len bits.
	 */
	len &= sizeof(memword_t)-1;
	if (len > 0) {
#ifndef __OPTIMIZE_SIZE__
		/*
		 * We want to clear <len> leading bytes in the word.
		 * On big/little endian, these are the most/least significant
		 * bits, respectively,  But as we want the mask of the bytes to
		 * keep, we have to complement the mask.  So after we shift,
		 * the keep_mask will only have bits set for the bytes we won't
		 * be filling.
		 *
		 * But the keep_mask could already have bytes to preserve
		 * if the amount to fill was less than the amount of traiing
		 * space in the first word.
		 */
#if BYTE_ORDER == BIG_ENDIAN
		keep_mask |= ~(memword_t)0U >> (len * 8);
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
		keep_mask |= ~(memword_t)0U << (len * 8);
#endif
		/*
		 * Now we mask off the bytes we are filling and then fill in
		 * those bytes with the new fill value.
		 */
		*dstp = (*dstp & keep_mask) | (fill & ~keep_mask);
#else /* __OPTIMIZE_SIZE__ */
		uint8_t *dp, *ep;
		for (dp = (uint8_t *)dstp, ep = dp + len;
		     dp != ep; dp++)
			*dp = fill;
#endif /* __OPTIMIZE_SIZE__ */
	}

	/*
	 * Return the initial addr
	 */
	return addr;
}

#ifdef BZERO
/*
 * For bzero, simply inline memset and let the compiler optimize things away.
 */
void
bzero(void *addr, size_t len)
{
	memset(addr, 0, len);
}
#endif

#ifdef TEST
#include <stdbool.h>
#include <stdio.h>

#undef memset

static union {
	uint8_t bytes[sizeof(memword_t) * 4];
	memword_t words[4];
} testmem;

int
main(int argc, char **argv)
{
	size_t start;
	size_t len;
	bool failed = false;

	for (start = 1; start < sizeof(testmem) - 1; start++) {
		for (len = 1; start + len < sizeof(testmem) - 1; len++) {
			bool ok = true;
			size_t i;
			uint8_t check_value;
			memset(testmem.bytes, 0xff, sizeof(testmem));
			test_memset(testmem.bytes + start, 0x00, len);
			for (i = 0; i < sizeof(testmem); i++) {
				if (i == 0 || i == start + len)
					check_value = 0xff;
				else if (i == start)
					check_value = 0x00;
				if (testmem.bytes[i] != check_value) {
					if (ok)
						printf("pass @ %zu .. %zu failed",
						    start, start + len - 1);
					ok = false;
					printf(" [%zu]=0x%02x(!0x%02x)",
					    i, testmem.bytes[i], check_value);
				}
			}
			if (!ok) {
				printf("\n");
				failed = 1;
			}
		}
	}

	return failed ? 1 : 0;
}
#endif /* TEST */