Libraries updates and cleanup
* Updating common/lib * Updating lib/csu * Updating lib/libc * Updating libexec/ld.elf_so * Corrected test on __minix in featuretest to actually follow the meaning of the comment. * Cleaned up _REENTRANT-related defintions. * Disabled -D_REENTRANT for libfetch * Removing some unneeded __NBSD_LIBC defines and tests Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
parent
f6aac1c3b5
commit
f14fb60209
1285 changed files with 44244 additions and 14308 deletions
|
@ -16,6 +16,7 @@
|
|||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -696,7 +696,7 @@ unsigned short mon_len[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|||
void fill_date(entry)
|
||||
DIRECTORY *entry;
|
||||
{
|
||||
register long cur_time = time((long *) 0) - DOS_TIME;
|
||||
register long cur_time = time(NULL) - DOS_TIME;
|
||||
unsigned short year = 0, month = 1, day, hour, minutes, seconds;
|
||||
int i;
|
||||
long tmp;
|
||||
|
|
|
@ -251,7 +251,8 @@ extern char *malloc();
|
|||
#endif
|
||||
|
||||
/* everybody but Amiga wants lseek declared here */
|
||||
#if !AMIGA
|
||||
/* LSC: MINIX Does not want it either! */
|
||||
#if !AMIGA && !defined(__minix)
|
||||
extern long lseek();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -419,11 +419,11 @@ int main(int argc, char **argv)
|
|||
if (rflag) {
|
||||
if (aflag) usage();
|
||||
if ((argc - i) != 1) usage();
|
||||
fprintf(stderr, "%s: -r is not yet implemented\n");
|
||||
fprintf(stderr, "%s: -r is not yet implemented\n", __func__);
|
||||
exit(1);
|
||||
} else {
|
||||
if ((argc - i) < 1) usage();
|
||||
if (aflag) fprintf(stderr, "%s: -a is not yet implemented\n");
|
||||
if (aflag) fprintf(stderr, "%s: -a is not yet implemented\n", __func__);
|
||||
|
||||
device= argv[i++];
|
||||
geometry();
|
||||
|
|
|
@ -70,7 +70,7 @@ void usage()
|
|||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
int i, r, audio, file;
|
||||
char *buffer, *file_name;
|
||||
char *buffer, *file_name = NULL;
|
||||
unsigned int sign;
|
||||
unsigned int fragment_size;
|
||||
unsigned int channels;
|
||||
|
|
|
@ -112,7 +112,6 @@ int diocntl(dev_t device, int request, struct partition *entry)
|
|||
{
|
||||
char *name;
|
||||
int r, f, err;
|
||||
struct partition geometry;
|
||||
|
||||
name= finddev(device);
|
||||
if ((f= open(name, O_RDONLY)) < 0) return -1;
|
||||
|
@ -164,7 +163,7 @@ int main(int argc, char **argv)
|
|||
struct stat hdst;
|
||||
struct partition whole, entry;
|
||||
struct part_entry table[4], *pe;
|
||||
int drive, par, device, incr;
|
||||
int drive, par = 0, device, incr;
|
||||
int partf;
|
||||
char *table_file;
|
||||
int hd_major, hd_minor;
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
COMMON_DIR:=${.PARSEDIR}
|
||||
.if defined(__MINIX)
|
||||
COMMON_CODEDIRS=atomic gen inet md net quad stdlib string
|
||||
COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160
|
||||
.else
|
||||
COMMON_CODEDIRS=atomic gen gmon inet md net quad stdlib string sys
|
||||
COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 hash/murmurhash
|
||||
.endif
|
||||
COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 hash/murmurhash
|
||||
|
||||
.if defined(COMMON_MACHINE_ARCH) && !empty(COMMON_MACHINE_ARCH) && \
|
||||
exists(${COMMON_DIR}/arch/${COMMON_MACHINE_ARCH})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_add_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_add_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -40,6 +40,11 @@ ENTRY_NP(_atomic_add_32)
|
|||
strex ip, r2, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return old value */
|
||||
END(_atomic_add_32)
|
||||
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
|
||||
|
@ -57,6 +62,11 @@ ENTRY_NP(_atomic_add_32_nv)
|
|||
strex r2, r0, [r3] /* try to store */
|
||||
cmp r2, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_add_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
|
||||
|
|
81
common/lib/libc/arch/arm/atomic/atomic_add_64.S
Normal file
81
common/lib/libc/arch/arm/atomic/atomic_add_64.S
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* $NetBSD: atomic_add_64.S,v 1.3 2012/09/13 00:36:12 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_add_64)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
mov r4, r0 /* need r0 for return value */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
#endif
|
||||
1: ldrexd r0, [r4] /* load old value (to be returned) */
|
||||
adds NLO, LO, NLO /* calculate new value */
|
||||
adc NHI, HI, NHI /* calculate new value */
|
||||
strexd ip, r2, [r4] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET /* return old value */
|
||||
END(_atomic_add_64)
|
||||
ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
|
||||
|
||||
ENTRY_NP(_atomic_add_64_nv)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
mov r4, r0 /* need r0 for return value */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
#endif
|
||||
1: ldrexd r0, [r4] /* load old value */
|
||||
adds LO, LO, NLO /* calculate new value lo */
|
||||
adc HI, HI, NHI /* calculate new value hi */
|
||||
strexd ip, r0, [r4] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET /* return new value */
|
||||
END(_atomic_add_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_and_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_and_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -40,6 +40,11 @@ ENTRY_NP(_atomic_and_32)
|
|||
strex ip, r2, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return old value */
|
||||
END(_atomic_and_32)
|
||||
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
|
||||
|
@ -55,6 +60,11 @@ ENTRY_NP(_atomic_and_32_nv)
|
|||
strex r2, r0, [r3] /* try to store */
|
||||
cmp r2, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_and_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
|
||||
|
|
81
common/lib/libc/arch/arm/atomic/atomic_and_64.S
Normal file
81
common/lib/libc/arch/arm/atomic/atomic_and_64.S
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* $NetBSD: atomic_and_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_and_64)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
#endif
|
||||
mov r4, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r4] /* load old value (to be returned) */
|
||||
and r2, r0, r2 /* calculate new value */
|
||||
and r3, r1, r3 /* calculate new value */
|
||||
strexd ip, r2, [r4] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET /* return old value */
|
||||
END(_atomic_and_64)
|
||||
ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64)
|
||||
|
||||
ENTRY_NP(_atomic_and_64_nv)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
#endif
|
||||
mov r4, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r4] /* load old value */
|
||||
and r0, r0, r2 /* calculate new value */
|
||||
and r1, r1, r3 /* calculate new value */
|
||||
strexd ip, r0, [r4] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET /* return new value */
|
||||
END(_atomic_and_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_cas_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_cas_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -44,15 +44,28 @@ ENTRY_NP(_atomic_cas_32)
|
|||
strex ip, r2, [r3] /* store new value */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* nope, try again. */
|
||||
RET /* yes, return. */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dsb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
|
||||
#endif
|
||||
RET /* return. */
|
||||
END(_atomic_cas_32)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
|
||||
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
|
||||
|
||||
#endif /* _ARCH_ARM_6 */
|
||||
|
|
69
common/lib/libc/arch/arm/atomic/atomic_cas_64.S
Normal file
69
common/lib/libc/arch/arm/atomic/atomic_cas_64.S
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* $NetBSD: atomic_cas_64.S,v 1.1 2012/09/11 20:51:25 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 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 "atomic_op_asm.h"
|
||||
|
||||
#if defined(_ARM_ARCH_6)
|
||||
/*
|
||||
* ARMv6 has load-exclusive/store-exclusive which works for both user
|
||||
* and kernel.
|
||||
*/
|
||||
ENTRY_NP(_atomic_cas_64)
|
||||
stmfd sp!, {r4, r5, r6} /* save temporaries */
|
||||
mov r6, r0 /* we need r0 for return value */
|
||||
#ifdef __ARM_EABI__
|
||||
ldrd r4, [sp] /* fetch new value */
|
||||
#else
|
||||
ldr r5, [sp, #4] /* fetch new value */
|
||||
ldr r4, [sp, #0] /* fetch new value */
|
||||
mov r3, r2 /* r2 will be overwritten by r1 which ... */
|
||||
mov r2, r1 /* r1 will be overwritten by ldrexd */
|
||||
#endif
|
||||
1:
|
||||
ldrexd r0, [r6] /* load current value */
|
||||
teq r0, r2 /* compare to old? 1st half */
|
||||
teqeq r1, r3 /* compare to old? 2nd half */
|
||||
bne 2f /* jump to return if different */
|
||||
strexd ip, r4, [r6] /* store new value */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* nope, try again. */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dsb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
|
||||
#endif
|
||||
2:
|
||||
ldmfd sp!, {r4, r5, r6} /* restore temporaries */
|
||||
RET /* return. */
|
||||
END(_atomic_cas_64)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
|
||||
|
||||
#endif /* _ARCH_ARM_6 */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_cas_8.S,v 1.1 2008/11/18 15:22:56 matt Exp $ */
|
||||
/* $NetBSD: atomic_cas_8.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -27,37 +27,33 @@
|
|||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: atomic_cas_8.S,v 1.1 2008/11/18 15:22:56 matt Exp $")
|
||||
#include "atomic_op_asm.h"
|
||||
|
||||
ENTRY(atomic_cas_8)
|
||||
XPUSH {r4,r5} /* we need some more registers */
|
||||
and r3, r0, #3 /* which byte do we replace? */
|
||||
#if __ARMEB__
|
||||
eor r3, r3, #3 /* bytes are reversed on BE */
|
||||
#endif
|
||||
mov r3, r3, lsl #3 /* multiply by 8 */
|
||||
mov r1, r1, lsl r3 /* mov old value to correct byte */
|
||||
eor r2, r1, r2, lsl r3 /* move new value to correct byte */
|
||||
/* eor r2, r2, r1 */ /* new value is now (old ^ new) */
|
||||
mov r5, #0xff /* load mask */
|
||||
mov r5, r5, lsl r3 /* and move to correct byte */
|
||||
mov r3, r0 /* move pointer */
|
||||
|
||||
1: ldrex r4, [r3] /* load 32bit value */
|
||||
and r0, r4, r5 /* clear other bytes */
|
||||
teq r0, r1 /* equal old value? */
|
||||
bne 2f /* nope, bail. */
|
||||
eor r4, r4, r2 /* new == old ^ (old ^ new) */
|
||||
strex ip, r4, [r3] /* attempt to store it */
|
||||
#if defined(_ARM_ARCH_6)
|
||||
/*
|
||||
* ARMv6 has load-exclusive/store-exclusive which works for both user
|
||||
* and kernel.
|
||||
*/
|
||||
ENTRY_NP(_atomic_cas_8)
|
||||
mov r3, r0 /* we need r0 for return value */
|
||||
1:
|
||||
ldrexb r0, [r3] /* load old value */
|
||||
teq r0, r1 /* compare? */
|
||||
RETc(ne) /* return if different */
|
||||
strexb ip, r2, [r3] /* store new value */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* nope, try again. */
|
||||
|
||||
2: XPOP {r4,r5} /* don't need these anymore */
|
||||
and r1, r3, #3
|
||||
#if __ARMEB__
|
||||
eor r1, r1, #3
|
||||
#ifdef _ARM_ARCH_7
|
||||
dsb /* data synchronization barrier */
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 4 /* data synchronization barrier */
|
||||
#endif
|
||||
mov r0, r0, lsr r1 /* shift it back to lsb byte */
|
||||
RET
|
||||
RET /* return. */
|
||||
END(_atomic_cas_8)
|
||||
|
||||
ATOMIC_OP_ALIAS(atomic_cas_8,_atomic_cas_8)
|
||||
STRONG_ALIAS(_atomic_cas_char,_atomic_cas_8)
|
||||
STRONG_ALIAS(_atomic_cas_uchar,_atomic_cas_8)
|
||||
|
||||
#endif /* _ARCH_ARM_6 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_dec_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_dec_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -39,6 +39,11 @@ ENTRY_NP(_atomic_dec_32)
|
|||
strex r3, r1, [r2] /* try to store */
|
||||
cmp r3, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_dec_32)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
|
||||
|
@ -56,6 +61,11 @@ ENTRY_NP(_atomic_dec_32_nv)
|
|||
strex r1, r0, [r2] /* try to store */
|
||||
cmp r1, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_dec_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
|
||||
|
|
73
common/lib/libc/arch/arm/atomic/atomic_dec_64.S
Normal file
73
common/lib/libc/arch/arm/atomic/atomic_dec_64.S
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* $NetBSD: atomic_dec_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_dec_64)
|
||||
mvn r2, #0
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r3] /* load old value (return value) */
|
||||
adds LO, LO, r2 /* calculate new value */
|
||||
adc HI, HI, r2 /* calculate new value */
|
||||
strexd ip, r0, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
adds LO, LO, #1
|
||||
adc HI, HI, #0
|
||||
RET /* return old value */
|
||||
END(_atomic_dec_64)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64)
|
||||
|
||||
ENTRY_NP(_atomic_dec_64_nv)
|
||||
mvn r2, #0
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r3] /* load old value */
|
||||
adds LO, LO, r2 /* calculate new value */
|
||||
adc HI, HI, r2 /* calculate new value */
|
||||
strexd ip, r0, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_dec_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_inc_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_inc_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -39,6 +39,11 @@ ENTRY_NP(_atomic_inc_32)
|
|||
strex r3, r1, [r2] /* try to store */
|
||||
cmp r3, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_inc_32)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
|
||||
|
@ -56,6 +61,11 @@ ENTRY_NP(_atomic_inc_32_nv)
|
|||
strex r1, r0, [r2] /* try to store */
|
||||
cmp r1, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_inc_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
|
||||
|
|
72
common/lib/libc/arch/arm/atomic/atomic_inc_64.S
Normal file
72
common/lib/libc/arch/arm/atomic/atomic_inc_64.S
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* $NetBSD: atomic_inc_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_inc_64)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r3] /* load old value (return value) */
|
||||
adds LO, LO, #1 /* calculate new value */
|
||||
adc HI, HI, #0 /* zero means we carried */
|
||||
strexd ip, r0, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
mvn r2, #0 /* r2 = -1 */
|
||||
adds LO, LO, r2 /* add it */
|
||||
adc HI, HI, r2 /* add with carry */
|
||||
RET /* return orig value */
|
||||
END(_atomic_inc_64)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)
|
||||
|
||||
ENTRY_NP(_atomic_inc_64_nv)
|
||||
mov r3, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r3] /* load old value */
|
||||
add LO, LO, #1 /* calculate new value (return value) */
|
||||
adc HI, HI, #0 /* fold carry into high */
|
||||
strexd ip, r0, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_inc_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
|
||||
|
||||
#endif /* _ARCH_ARM_6 */
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_op_asm.h,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_op_asm.h,v 1.3 2012/09/11 20:51:25 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -51,4 +51,16 @@
|
|||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#ifdef __ARMEB__
|
||||
#define HI r0
|
||||
#define LO r1
|
||||
#define NHI r2
|
||||
#define NLO r3
|
||||
#else
|
||||
#define LO r0
|
||||
#define HI r1
|
||||
#define NLO r2
|
||||
#define NHI r3
|
||||
#endif
|
||||
|
||||
#endif /* _ATOMIC_OP_ASM_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_or_32.S,v 1.2 2008/08/16 07:12:39 matt Exp $ */
|
||||
/* $NetBSD: atomic_or_32.S,v 1.3 2012/08/31 23:41:52 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -39,6 +39,11 @@ ENTRY_NP(_atomic_or_32)
|
|||
strex ip, r2, [r3] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return old value */
|
||||
END(_atomic_or_32)
|
||||
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
|
||||
|
@ -54,6 +59,11 @@ ENTRY_NP(_atomic_or_32_nv)
|
|||
strex r2, r0, [r3] /* try to store */
|
||||
cmp r2, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET /* return new value */
|
||||
END(_atomic_or_32_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
|
||||
|
|
81
common/lib/libc/arch/arm/atomic/atomic_or_64.S
Normal file
81
common/lib/libc/arch/arm/atomic/atomic_or_64.S
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* $NetBSD: atomic_or_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 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 "atomic_op_asm.h"
|
||||
|
||||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_atomic_or_64)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
#endif
|
||||
mov r4, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r4] /* load old value (to be returned) */
|
||||
orr r2, r0, r2 /* calculate new value */
|
||||
orr r3, r1, r3 /* calculate new value */
|
||||
strexd ip, r2, [r4] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET /* return old value */
|
||||
END(_atomic_or_64)
|
||||
ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64)
|
||||
|
||||
ENTRY_NP(_atomic_or_64_nv)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
#endif
|
||||
mov r4, r0 /* need r0 for return value */
|
||||
1: ldrexd r0, [r4] /* load old value */
|
||||
orr r0, r0, r2 /* calculate new value (return value) */
|
||||
orr r1, r1, r3 /* calculate new value (return value) */
|
||||
strexd ip, r0, [r4] /* try to store */
|
||||
cmp ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again? */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET /* return new value */
|
||||
END(_atomic_or_64_nv)
|
||||
ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
|
||||
|
||||
#endif /* _ARM_ARCH_6 */
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: atomic_swap.S,v 1.2 2008/08/16 07:12:40 matt Exp $ */
|
||||
/* $NetBSD: atomic_swap.S,v 1.4 2012/08/31 23:41:52 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2007,2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
|
@ -15,13 +15,6 @@
|
|||
* 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
|
||||
|
@ -38,8 +31,38 @@
|
|||
|
||||
#include "atomic_op_asm.h"
|
||||
|
||||
/*
|
||||
* While SWP{B} is sufficient on its own for pre-ARMv7 CPUs, on MP ARMv7 cores
|
||||
* SWP{B} is disabled since it's no longer atomic among multiple CPUs. They
|
||||
* will actually raise an UNDEFINED exception.
|
||||
*
|
||||
* So if we use the LDREX/STREX template, but use a SWP instruction followed
|
||||
* by a MOV instruction (using a temporary register), that gives a handler
|
||||
* for the SWP UNDEFINED exception enough information to "patch" this instance
|
||||
* SWP with correct forms of LDREX/STREX. (note that this would happen even
|
||||
* "read-only" pages. If the page gets tossed, we will get another exception
|
||||
* and fix yet again).
|
||||
*/
|
||||
|
||||
ENTRY_NP(_atomic_swap_32)
|
||||
swp r0, r1, [r0]
|
||||
mov r2, r0
|
||||
1:
|
||||
#ifdef _ARM_ARCH_6
|
||||
ldrex r0, [r2]
|
||||
cmp r0, r1
|
||||
strexne ip, r1, [r2]
|
||||
#else
|
||||
swp r0, r1, [r2]
|
||||
cmp r0, r1
|
||||
movsne ip, #0
|
||||
#endif
|
||||
cmpne ip, #0
|
||||
bne 1b
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET
|
||||
END(_atomic_swap_32)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
|
||||
|
@ -51,11 +74,26 @@ STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
|
|||
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
|
||||
|
||||
ENTRY_NP(_atomic_swap_8)
|
||||
swpb r0, r1, [r0]
|
||||
mov r2, r0
|
||||
1:
|
||||
#ifdef _ARM_ARCH_6
|
||||
ldrexb r0, [r2]
|
||||
strexb r3, r1, [r2]
|
||||
#else
|
||||
swpb r0, r1, [r2]
|
||||
mov r3, #0
|
||||
#endif
|
||||
cmp r3, #0
|
||||
bne 1b
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
RET
|
||||
END(_atomic_swap_8)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_8,_atomic_swap_8)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_char,_atomic_swap_8)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_uchar,_atomic_swap_8)
|
||||
STRONG_ALIAS(_atomic_swap_char,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_32)
|
||||
STRONG_ALIAS(_atomic_swap_char,_atomic_swap_8)
|
||||
STRONG_ALIAS(_atomic_swap_uchar,_atomic_swap_8)
|
||||
|
|
53
common/lib/libc/arch/arm/atomic/atomic_swap_64.S
Normal file
53
common/lib/libc/arch/arm/atomic/atomic_swap_64.S
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* $NetBSD: atomic_swap_64.S,v 1.2 2012/09/13 00:36:12 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by 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.
|
||||
*
|
||||
* 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 "atomic_op_asm.h"
|
||||
|
||||
ENTRY_NP(_atomic_swap_64)
|
||||
str r4, [sp, #-4]! /* save temporary */
|
||||
mov r4, r0 /* return value will be in r0 */
|
||||
#ifndef __ARM_EABI__
|
||||
mov r3, r2 /* r2 will be overwriten by r1 */
|
||||
mov r2, r1 /* and r1 will be overwritten by ldrexd */
|
||||
#endif
|
||||
1:
|
||||
ldrexd r0, [r4] /* load old value */
|
||||
strexd ip, r2, [r4] /* store new value */
|
||||
cmpne ip, #0 /* succeed? */
|
||||
bne 1b /* no, try again */
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, ip, c7, c10, 5 /* data memory barrier */
|
||||
#endif
|
||||
ldr r4, [sp], #4 /* restore temporary */
|
||||
RET
|
||||
END(_atomic_swap_64)
|
||||
ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: membar_ops.S,v 1.2 2008/08/16 07:12:40 matt Exp $ */
|
||||
/* $NetBSD: membar_ops.S,v 1.3 2012/08/16 16:49:10 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -33,7 +33,11 @@
|
|||
#ifdef _ARM_ARCH_6
|
||||
|
||||
ENTRY_NP(_membar_producer)
|
||||
#ifdef _ARM_ARCH_7
|
||||
dsb
|
||||
#else
|
||||
mcr p15, 0, r0, c7, c10, 4 /* Data Synchronization Barrier */
|
||||
#endif
|
||||
RET
|
||||
END(_membar_producer)
|
||||
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
|
||||
|
@ -41,7 +45,11 @@ ATOMIC_OP_ALIAS(membar_write,_membar_producer)
|
|||
STRONG_ALIAS(_membar_write,_membar_producer)
|
||||
|
||||
ENTRY_NP(_membar_sync)
|
||||
#ifdef _ARM_ARCH_7
|
||||
dmb
|
||||
#else
|
||||
mcr p15, 0, r0, c7, c10, 5 /* Data Memory Barrier */
|
||||
#endif
|
||||
RET
|
||||
END(_membar_sync)
|
||||
ATOMIC_OP_ALIAS(membar_sync,_membar_sync)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: divsi3.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
/* $NetBSD: divsi3.S,v 1.3 2012/10/10 02:16:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
|
@ -21,22 +21,6 @@
|
|||
* which makes a C call
|
||||
*/
|
||||
|
||||
ENTRY(__umodsi3)
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl .L_udivide
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r0, r1
|
||||
ldmfd sp!, {pc}
|
||||
|
||||
ENTRY(__modsi3)
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl .L_divide
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r0, r1
|
||||
ldmfd sp!, {pc}
|
||||
|
||||
.L_overflow:
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
mov r0, #8 /* SIGFPE */
|
||||
|
@ -48,6 +32,8 @@ ENTRY(__modsi3)
|
|||
#endif
|
||||
RET
|
||||
|
||||
ENTRY_NP(__aeabi_uidivmod)
|
||||
ENTRY_NP(__aeabi_uidiv)
|
||||
ENTRY(__udivsi3)
|
||||
.L_udivide: /* r0 = r0 / r1; r1 = r0 % r1 */
|
||||
eor r0, r1, r0
|
||||
|
@ -70,6 +56,8 @@ ENTRY(__udivsi3)
|
|||
mov r1, #0
|
||||
RET
|
||||
|
||||
ENTRY_NP(__aeabi_idivmod)
|
||||
ENTRY_NP(__aeabi_idiv)
|
||||
ENTRY(__divsi3)
|
||||
.L_divide: /* r0 = r0 / r1; r1 = r0 % r1 */
|
||||
eor r0, r1, r0
|
||||
|
|
31
common/lib/libc/arch/arm/gen/modsi3.S
Normal file
31
common/lib/libc/arch/arm/gen/modsi3.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* $NetBSD: modsi3.S,v 1.1 2012/10/10 02:16:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
/*
|
||||
* stack is aligned as there's a possibility of branching to .L_overflow
|
||||
* which makes a C call
|
||||
*/
|
||||
|
||||
ENTRY(__modsi3)
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl PIC_SYM(__divsi3, PLT)
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r0, r1
|
||||
ldmfd sp!, {pc}
|
||||
|
30
common/lib/libc/arch/arm/gen/umodsi3.S
Normal file
30
common/lib/libc/arch/arm/gen/umodsi3.S
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* $NetBSD: umodsi3.S,v 1.1 2012/10/10 02:16:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
/*
|
||||
* stack is aligned as there's a possibility of branching to .L_overflow
|
||||
* which makes a C call
|
||||
*/
|
||||
|
||||
ENTRY(__umodsi3)
|
||||
stmfd sp!, {lr}
|
||||
sub sp, sp, #4 /* align stack */
|
||||
bl PIC_SYM(__udivsi3, PLT)
|
||||
add sp, sp, #4 /* unalign stack */
|
||||
mov r0, r1
|
||||
ldmfd sp!, {pc}
|
55
common/lib/libc/arch/arm/quad/__aeabi_lcmp.c
Normal file
55
common/lib/libc/arch/arm/quad/__aeabi_lcmp.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* 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>
|
||||
|
||||
__RCSID("$NetBSD: __aeabi_lcmp.c,v 1.2 2012/08/06 02:15:51 matt Exp $");
|
||||
|
||||
#include "quad.h"
|
||||
#include <arm/aeabi.h>
|
||||
|
||||
/*
|
||||
* Return -1, 0, 1 (like strcmp) if a [<, =, >] b
|
||||
*/
|
||||
int
|
||||
__aeabi_lcmp(long long a, long long b)
|
||||
{
|
||||
const union uu aa = { .q = a }, bb = { .q = b };
|
||||
|
||||
if (aa.sl[H] < bb.sl[H])
|
||||
return -1;
|
||||
if (aa.sl[H] > bb.sl[H])
|
||||
return 1;
|
||||
|
||||
if (aa.sl[L] < bb.sl[L])
|
||||
return -1;
|
||||
if (aa.sl[L] > bb.sl[L])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
128
common/lib/libc/arch/arm/quad/__aeabi_ldivmod.S
Normal file
128
common/lib/libc/arch/arm/quad/__aeabi_ldivmod.S
Normal file
|
@ -0,0 +1,128 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: __aeabi_ldivmod.S,v 1.1 2012/08/05 06:33:51 matt Exp $")
|
||||
|
||||
ENTRY(__aeabi_ldivmod)
|
||||
push {r4-r5, sl, lr}
|
||||
#define NEG r5
|
||||
mov NEG, #0
|
||||
|
||||
#ifdef __ARMEB__
|
||||
#define ALO r1 /* incoming numerator, outgoing quotient */
|
||||
#define AHI r0 /* incoming numerator, outgoing quotient */
|
||||
#define BLO r3 /* incoming denominator, outgoing remainder */
|
||||
#define BHI r2 /* incoming denominator, outgoing remainder */
|
||||
#else
|
||||
#define ALO r0 /* incoming numerator, outgoing quotient */
|
||||
#define AHI r1 /* incoming numerator, outgoing quotient */
|
||||
#define BLO r2 /* incoming denominator, outgoing remainder */
|
||||
#define BHI r3 /* incoming denominator, outgoing remainder */
|
||||
#endif
|
||||
|
||||
cmp BHI, #0
|
||||
bge 2f
|
||||
eor NEG, NEG, #1 /* flip quotient sign */
|
||||
bl .Lnegate_b
|
||||
bcs .Lmaxdenom
|
||||
|
||||
2:
|
||||
cmp AHI, #0
|
||||
/* bge 3f */
|
||||
eorlt NEG, NEG, #3 /* flip quotient sign, flip remainder sign */
|
||||
bllt .Lnegate_a
|
||||
3:
|
||||
/*
|
||||
* Arguments are setup, allocate some stack for the remainder
|
||||
* and call __qdivrem for the heavy lifting.
|
||||
*/
|
||||
sub sp, sp, #8
|
||||
mov r4, sp /* pointer to remainder */
|
||||
bl PLT_SYM(__qdivrem)
|
||||
|
||||
teq NEG, #0 /* any signs to flip? */
|
||||
/*
|
||||
* The quotient is already in the right place and neither value
|
||||
* needs its sign flipped.
|
||||
*/
|
||||
popeq {r2-r5, sl, lr}
|
||||
RETc(eq)
|
||||
|
||||
pop {r2, r3}
|
||||
tst NEG, #2 /* does remainder need to be negative? */
|
||||
bleq .Lnegate_b
|
||||
tst NEG, #1 /* does quotient need to be negative? */
|
||||
bleq .Lnegate_a
|
||||
pop {r4-r5, sl, lr}
|
||||
RET
|
||||
|
||||
.Lnegate_a:
|
||||
rsbs ALO, ALO, #0
|
||||
rsc AHI, AHI, #0
|
||||
RET
|
||||
|
||||
.Lnegate_b:
|
||||
rsbs BLO, BLO, #0
|
||||
rsc BHI, BHI, #0
|
||||
RET
|
||||
|
||||
.Lmaxdenom:
|
||||
/*
|
||||
* We had a carry so the denominator must have INT64_MIN
|
||||
* Also BLO and BHI never changed values so we can use
|
||||
* them to see if the numerator has the same value. We
|
||||
* don't have to worry about sign.
|
||||
*/
|
||||
teq BHI, AHI
|
||||
teqeq BLO, ALO
|
||||
bne 1f
|
||||
|
||||
/*
|
||||
* They were equal, so we return a quotient of 1 and remainder of 0.
|
||||
*/
|
||||
mov ALO, #1
|
||||
mov AHI, #0
|
||||
mov BLO, #0
|
||||
mov BHI, #0
|
||||
pop {r4-r5, sl, lr}
|
||||
RET
|
||||
|
||||
/*
|
||||
* Our remainder must be the numerator and our quotient is 0.
|
||||
*/
|
||||
1: mov BLO, ALO
|
||||
mov BHI, AHI
|
||||
mov ALO, #0
|
||||
mov AHI, #0
|
||||
pop {r4-r5, sl, lr}
|
||||
RET
|
||||
|
||||
END(__aeabi_ldivmod)
|
55
common/lib/libc/arch/arm/quad/__aeabi_ulcmp.c
Normal file
55
common/lib/libc/arch/arm/quad/__aeabi_ulcmp.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* 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>
|
||||
|
||||
__RCSID("$NetBSD: __aeabi_ulcmp.c,v 1.2 2012/08/06 02:15:51 matt Exp $");
|
||||
|
||||
#include "quad.h"
|
||||
#include <arm/aeabi.h>
|
||||
|
||||
/*
|
||||
* Return -1, 0, 1 (like strcmp) if a [<, =, >] b
|
||||
*/
|
||||
int
|
||||
__aeabi_ulcmp(unsigned long long a, unsigned long long b)
|
||||
{
|
||||
const union uu aa = { .uq = a }, bb = { .uq = b };
|
||||
|
||||
if (aa.ul[H] < bb.ul[H])
|
||||
return -1;
|
||||
if (aa.ul[H] > bb.ul[H])
|
||||
return 1;
|
||||
|
||||
if (aa.ul[L] < bb.ul[L])
|
||||
return -1;
|
||||
if (aa.ul[L] > bb.ul[L])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
51
common/lib/libc/arch/arm/quad/__aeabi_uldivmod.S
Normal file
51
common/lib/libc/arch/arm/quad/__aeabi_uldivmod.S
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: __aeabi_uldivmod.S,v 1.2 2012/08/05 06:34:09 matt Exp $")
|
||||
|
||||
/*
|
||||
* typedef struct { unsigned long long quo, rem } ulldiv_t;
|
||||
* __value_in_regs ulldiv_t __aeabi_uldivmod(unsigned long long n,
|
||||
* unsigned long long d);
|
||||
*/
|
||||
|
||||
ENTRY(__aeabi_uldivmod)
|
||||
push {r4,lr}
|
||||
sub sp, sp, #8
|
||||
mov r4, sp
|
||||
bl PLT_SYM(__qdivrem)
|
||||
/*
|
||||
* The remainder is already on the stack just waiting to be popped
|
||||
* into r2/r3.
|
||||
*/
|
||||
pop {r2-r4,lr}
|
||||
RET
|
||||
END(__aeabi_uldivmod)
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
/* $NetBSD: ffs.S,v 1.2 2011/07/03 07:13:31 matt Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001 Christopher Gilbert
|
||||
* All rights reserved.
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
RCSID("$NetBSD: ffs.S,v 1.2 2011/07/03 07:13:31 matt Exp $")
|
||||
|
||||
/*
|
||||
* ffs - find first set bit, this algorithm isolates the first set
|
||||
|
@ -44,7 +44,7 @@ RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
|||
* This is the ffs algorithm devised by d.seal and posted to comp.sys.arm on
|
||||
* 16 Feb 1994.
|
||||
*/
|
||||
|
||||
WEAK_ALIAS(__ffssi2,ffs)
|
||||
ENTRY(ffs)
|
||||
#ifdef _ARM_ARCH_5
|
||||
/* (X & -X) gives LSB or zero. */
|
||||
|
|
50
common/lib/libc/arch/i386/string/small/memcmp.S
Normal file
50
common/lib/libc/arch/i386/string/small/memcmp.S
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* $NetBSD: memcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: memcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
|
||||
ENTRY(memcmp)
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl 12(%esp), %edi
|
||||
movl 16(%esp), %esi
|
||||
movl 20(%esp), %ecx
|
||||
xorl %eax, %eax
|
||||
rep
|
||||
cmpsb
|
||||
popl %edi
|
||||
popl %esi
|
||||
ja 1f
|
||||
setnz %al
|
||||
ret
|
||||
1:
|
||||
decl %eax
|
||||
ret
|
71
common/lib/libc/arch/i386/string/small/memcpy.S
Normal file
71
common/lib/libc/arch/i386/string/small/memcpy.S
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* $NetBSD: memcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: memcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
|
||||
# ifdef BCOPY
|
||||
ENTRY(bcopy)
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl 12(%esp), %esi
|
||||
movl 16(%esp), %edi
|
||||
jmp __memmove_start
|
||||
# endif
|
||||
# if defined(MEMMOVE)
|
||||
ENTRY(memcpy)
|
||||
ENTRY(memmove)
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl 12(%esp), %edi
|
||||
movl 16(%esp), %esi
|
||||
.globl __memmove_start
|
||||
__memmove_start:
|
||||
movl 20(%esp), %ecx
|
||||
pushl %edi
|
||||
testl %ecx, %ecx
|
||||
jz 2f
|
||||
cmpl %esi, %edi
|
||||
jb 1f
|
||||
addl %ecx, %esi
|
||||
decl %esi
|
||||
addl %ecx, %edi
|
||||
decl %edi
|
||||
std
|
||||
1:
|
||||
rep
|
||||
movsb
|
||||
2:
|
||||
cld
|
||||
popl %eax
|
||||
popl %edi
|
||||
popl %esi
|
||||
ret
|
||||
# endif /* MEMMOVE */
|
4
common/lib/libc/arch/i386/string/small/memmove.S
Normal file
4
common/lib/libc/arch/i386/string/small/memmove.S
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* $NetBSD: memmove.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
|
||||
#define MEMMOVE
|
||||
#include "memcpy.S"
|
45
common/lib/libc/arch/i386/string/small/memset.S
Normal file
45
common/lib/libc/arch/i386/string/small/memset.S
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* $NetBSD: memset.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: memset.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
|
||||
ENTRY(memset)
|
||||
pushl %edi
|
||||
movl 8(%esp), %edi
|
||||
movl 12(%esp), %eax
|
||||
movl 16(%esp), %ecx
|
||||
pushl %edi
|
||||
rep
|
||||
stosb
|
||||
popl %eax
|
||||
popl %edi
|
||||
ret
|
51
common/lib/libc/arch/i386/string/small/strchr.S
Normal file
51
common/lib/libc/arch/i386/string/small/strchr.S
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* $NetBSD: strchr.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: strchr.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
|
||||
ENTRY(strchr)
|
||||
popl %edx /* Return address */
|
||||
popl %eax /* String pointer */
|
||||
popl %ecx /* Character to find */
|
||||
pushl %ecx
|
||||
pushl %eax
|
||||
pushl %edx
|
||||
1:
|
||||
cmpb $0, 0(%eax)
|
||||
je 2f
|
||||
cmpb %cl, 0(%eax)
|
||||
je 3f
|
||||
incl %eax
|
||||
jmp 1b
|
||||
2:
|
||||
xorl %eax, %eax
|
||||
3:
|
||||
ret
|
50
common/lib/libc/arch/i386/string/small/strcmp.S
Normal file
50
common/lib/libc/arch/i386/string/small/strcmp.S
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* $NetBSD: strcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: strcmp.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
|
||||
ENTRY(strcmp)
|
||||
pushl %esi
|
||||
movl 12(%esp), %ecx
|
||||
movl 8(%esp), %esi
|
||||
decl %ecx
|
||||
1:
|
||||
incl %ecx
|
||||
lodsb
|
||||
cmpb 0(%ecx), %al
|
||||
jne 2f
|
||||
testb %al, %al
|
||||
jne 1b
|
||||
2:
|
||||
subb 0(%ecx), %al
|
||||
movsbl %al, %eax
|
||||
popl %esi
|
||||
ret
|
48
common/lib/libc/arch/i386/string/small/strcpy.S
Normal file
48
common/lib/libc/arch/i386/string/small/strcpy.S
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* $NetBSD: strcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Joerg Sonnenberger.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: strcpy.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
|
||||
ENTRY(strcpy)
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
movl 12(%esp), %edi
|
||||
movl 16(%esp), %esi
|
||||
pushl %edi
|
||||
1:
|
||||
lodsb
|
||||
stosb
|
||||
testb %al, %al
|
||||
jne 1b
|
||||
popl %eax
|
||||
popl %edi
|
||||
popl %esi
|
||||
ret
|
41
common/lib/libc/arch/i386/string/small/strlen.S
Normal file
41
common/lib/libc/arch/i386/string/small/strlen.S
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* $NetBSD: strlen.S,v 1.1 2011/06/16 16:39:14 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2011 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by David Laight.
|
||||
*
|
||||
* 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 <machine/asm.h>
|
||||
RCSID("$NetBSD: strlen.S,v 1.1 2011/06/16 16:39:14 joerg Exp $")
|
||||
ENTRY(strlen)
|
||||
movl 8(%esp), %ecx
|
||||
xorl %eax, %eax
|
||||
dec %eax
|
||||
1:
|
||||
incl %eax
|
||||
cmpb $0, 0(%ecx,%eax,1)
|
||||
jnz 1b
|
||||
ret
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
|
||||
/* $NetBSD: ffs.S,v 1.2 2011/07/09 14:57:29 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -39,12 +39,14 @@
|
|||
#if 0
|
||||
RCSID("from: @(#)ffs.s 5.1 (Berkeley) 5/12/90")
|
||||
#else
|
||||
RCSID("$NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
|
||||
RCSID("$NetBSD: ffs.S,v 1.2 2011/07/09 14:57:29 mrg Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/* bit = ffs(value) */
|
||||
|
||||
WEAK_ALIAS(__ffssi2,ffs)
|
||||
|
||||
#ifndef __mc68010__
|
||||
|
||||
ENTRY(ffs)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_add.S,v 1.2 2009/12/14 00:38:59 matt Exp $ */
|
||||
/* $NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,16 +26,24 @@
|
|||
* 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 $")
|
||||
RCSID("$NetBSD: atomic_add.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_cputype.h"
|
||||
#ifndef MIPS3_LOONGSON2F
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif
|
||||
#else /* _KERNEL_OPT */
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif /* _KERNEL_OPT */
|
||||
|
||||
|
||||
LEAF(_atomic_add_32)
|
||||
1: INT_LL t0, 0(a0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_and.S,v 1.2 2009/12/14 00:38:59 matt Exp $ */
|
||||
/* $NetBSD: atomic_and.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,16 +26,24 @@
|
|||
* 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 $")
|
||||
RCSID("$NetBSD: atomic_and.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_cputype.h"
|
||||
#ifndef MIPS3_LOONGSON2F
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif
|
||||
#else /* _KERNEL_OPT */
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif /* _KERNEL_OPT */
|
||||
|
||||
|
||||
LEAF(_atomic_and_32)
|
||||
1: INT_LL t0, 0(a0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_cas.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: atomic_cas.S,v 1.3 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,11 +26,10 @@
|
|||
* 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 $")
|
||||
RCSID("$NetBSD: atomic_cas.S,v 1.3 2012/03/14 16:50:34 christos Exp $")
|
||||
|
||||
.text
|
||||
.set noat
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_dec.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,16 +26,23 @@
|
|||
* 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 $")
|
||||
RCSID("$NetBSD: atomic_dec.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_cputype.h"
|
||||
#ifndef MIPS3_LOONGSON2F
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif
|
||||
#else /* _KERNEL_OPT */
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif /* _KERNEL_OPT */
|
||||
|
||||
LEAF(_atomic_dec_32)
|
||||
1: INT_LL t0, 0(a0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_inc.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,16 +26,24 @@
|
|||
* 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 $")
|
||||
RCSID("$NetBSD: atomic_inc.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_cputype.h"
|
||||
#ifndef MIPS3_LOONGSON2F
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif
|
||||
#else /* _KERNEL_OPT */
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif /* _KERNEL_OPT */
|
||||
|
||||
|
||||
LEAF(_atomic_inc_32)
|
||||
1: INT_LL t0, 0(a0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_or.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: atomic_or.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,14 +26,21 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/asm.h>
|
||||
#include "atomic_op_asm.h"
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_cputype.h"
|
||||
#ifndef MIPS3_LOONGSON2F
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif
|
||||
#else /* _KERNEL_OPT */
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif /* _KERNEL_OPT */
|
||||
|
||||
LEAF(_atomic_or_32)
|
||||
1: INT_LL t0, 0(a0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_swap.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: atomic_swap.S,v 1.4 2012/03/14 16:50:34 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -26,16 +26,24 @@
|
|||
* 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 $")
|
||||
RCSID("$NetBSD: atomic_swap.S,v 1.4 2012/03/14 16:50:34 christos Exp $")
|
||||
|
||||
.text
|
||||
.set noat
|
||||
.set noreorder
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_cputype.h"
|
||||
#ifndef MIPS3_LOONGSON2F
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif
|
||||
#else /* _KERNEL_OPT */
|
||||
.set noat
|
||||
.set nomacro
|
||||
#endif /* _KERNEL_OPT */
|
||||
|
||||
|
||||
LEAF(_atomic_swap_32)
|
||||
1: INT_LL v0, 0(a0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: membar_ops.S,v 1.4 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: membar_ops.S,v 1.5 2012/08/03 06:06:44 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -50,6 +50,7 @@
|
|||
#endif
|
||||
|
||||
.text
|
||||
.set noreorder
|
||||
|
||||
LEAF(_membar_sync)
|
||||
j ra
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: bcopy.S,v 1.4 2011/08/27 13:23:52 bouyer Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -46,7 +46,7 @@
|
|||
#if 0
|
||||
RCSID("from: @(#)mips_bcopy.s 2.2 CMU 18/06/93")
|
||||
#else
|
||||
RCSID("$NetBSD: bcopy.S,v 1.3 2009/12/14 00:39:00 matt Exp $")
|
||||
RCSID("$NetBSD: bcopy.S,v 1.4 2011/08/27 13:23:52 bouyer Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -170,8 +170,10 @@ LEAF(FUNCTION)
|
|||
PTR_ADDU DSTREG,1
|
||||
|
||||
4: # copydone
|
||||
.set at #-mfix-loongson2f-btb
|
||||
j ra
|
||||
nop
|
||||
.set noat
|
||||
|
||||
/*
|
||||
* Copy from unaligned source to aligned dest.
|
||||
|
@ -264,8 +266,10 @@ LEAF(FUNCTION)
|
|||
PTR_SUBU DSTREG,1
|
||||
|
||||
4: # copydone
|
||||
.set at #-mfix-loongson2f-btb
|
||||
j ra
|
||||
nop
|
||||
.set noat
|
||||
|
||||
/*
|
||||
* Copy from unaligned source to aligned dest.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: ffs.S,v 1.4 2011/07/04 11:35:26 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Ralph Campbell.
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Matt Thomas of 3am Software Foundry.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -15,40 +15,96 @@
|
|||
* 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.
|
||||
* 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 <mips/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
/* RCSID("from: @(#)ffs.s 8.1 (Berkeley) 6/4/93") */
|
||||
RCSID("$NetBSD: ffs.S,v 1.2 2009/12/14 00:39:00 matt Exp $")
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
RCSID("$NetBSD: ffs.S,v 1.4 2011/07/04 11:35:26 mrg Exp $")
|
||||
|
||||
/* bit = ffs(value) */
|
||||
|
||||
.text
|
||||
.set noreorder
|
||||
|
||||
WEAK_ALIAS(__ffssi2,ffs)
|
||||
#if __mips == 64 || __mips == 32
|
||||
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:
|
||||
#ifndef _LP64
|
||||
XLEAF(ffsl)
|
||||
#endif
|
||||
.set push
|
||||
.set mips32
|
||||
li v1, 32
|
||||
#if __mips == 64
|
||||
sll a0, a0, 0
|
||||
#endif
|
||||
negu a1, a0
|
||||
and a0, a1
|
||||
clz v0, a0
|
||||
j ra
|
||||
subu v0, v1, v0
|
||||
.set pop
|
||||
END(ffs)
|
||||
#if defined(_LP64) && __mips == 64
|
||||
LEAF(ffsl)
|
||||
li v1, 64
|
||||
negu a1, a0
|
||||
and a0, a1
|
||||
dclz v0, a0
|
||||
j ra
|
||||
subu v0, v1, v0
|
||||
END(ffsl)
|
||||
#endif
|
||||
#else /* __mips != 64 && __mips != 32 */
|
||||
|
||||
#ifdef _LP64
|
||||
XLEAF(ffsl)
|
||||
beqz a0, 6f # fast escape if 0
|
||||
li v0, 0
|
||||
|
||||
li v0, 1
|
||||
li a3, 0xffffffff # initial mask
|
||||
b 1f
|
||||
li a2, 32 # bit count of mask
|
||||
#endif /* _LP64 */
|
||||
LEAF(ffs)
|
||||
#ifndef _LP64
|
||||
XLEAF(ffsl)
|
||||
#endif /* !_LP64 */
|
||||
beqz a0, 6f
|
||||
li v0, 0
|
||||
|
||||
li v0, 1
|
||||
li a3, 0xffff # initial mask
|
||||
li a2, 16 # bit count of mask
|
||||
1:
|
||||
and v1, a0, a3 # focus no lower half of bits left
|
||||
bnez v1, 2f # any of the lower half set?
|
||||
nop
|
||||
addu v0, a2 # nope, then bit is in the upper half
|
||||
#ifdef _LP64
|
||||
dsrlv a0, a0, a2 # discard low bits
|
||||
#else
|
||||
srlv a0, a0, a2 # discard low bits
|
||||
#endif
|
||||
2:
|
||||
srl a2, 1 # divide bit count by 2
|
||||
bnez a2, 1b # still bits left to text?
|
||||
srlv a3, a3, a2 # shrink mask in half
|
||||
6:
|
||||
j ra
|
||||
nop
|
||||
END(ffs)
|
||||
#endif /* __mips == 64 || __mips == 32 */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
/* $NetBSD: ffs.S,v 1.3 2011/07/04 12:18:05 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -32,7 +32,7 @@
|
|||
#include <machine/asm.h>
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
RCSID("$NetBSD: ffs.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
|
||||
RCSID("$NetBSD: ffs.S,v 1.3 2011/07/04 12:18:05 mrg Exp $")
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -42,6 +42,7 @@
|
|||
* The remaining 8bit is tested in every 2bit.
|
||||
*/
|
||||
|
||||
WEAK_ALIAS(__ffssi2,ffs)
|
||||
ENTRY(ffs)
|
||||
mov r4,r0 ! using r0 specific instructions
|
||||
tst #0xff,r0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_cas.S,v 1.10 2009/03/13 16:40:22 nakayama Exp $ */
|
||||
/* $NetBSD: atomic_cas.S,v 1.11 2011/02/22 18:45:10 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -63,15 +63,29 @@
|
|||
#if defined(MULTIPROCESSOR)
|
||||
.section .bss
|
||||
.align 1024
|
||||
#ifdef PIC
|
||||
.globl _C_LABEL(_atomic_cas_locktab)
|
||||
#endif
|
||||
OTYPE(_C_LABEL(_atomic_cas_locktab))
|
||||
_C_LABEL(_atomic_cas_locktab):
|
||||
.space 1024
|
||||
|
||||
#ifdef PIC
|
||||
/* o4 is not used for PSR in PIC cases, so we can use it here */
|
||||
#define GETLOCKTAB \
|
||||
PIC_PROLOGUE(%o3,%o4) ;\
|
||||
set _C_LABEL(_atomic_cas_locktab), %o4 ;\
|
||||
ld [%o3 + %o4], %o3
|
||||
#else
|
||||
#define GETLOCKTAB \
|
||||
sethi %hi(_C_LABEL(_atomic_cas_locktab)), %o3
|
||||
#endif
|
||||
|
||||
#define ACQUIRE_INTERLOCK \
|
||||
DISABLE_INTERRUPTS ;\
|
||||
srl %o0, 3, %o5 /* get lock address */ ;\
|
||||
and %o5, 1023, %o5 ;\
|
||||
sethi %hi(_C_LABEL(_atomic_cas_locktab)), %o3 ;\
|
||||
GETLOCKTAB ;\
|
||||
add %o5, %o3, %o5 ;\
|
||||
;\
|
||||
/* %o5 has interlock address */ ;\
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs.S,v 1.2 2009/12/19 19:09:48 pooka Exp $ */
|
||||
/* $NetBSD: ffs.S,v 1.3 2011/07/04 11:18:23 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -40,7 +40,7 @@
|
|||
#if 0
|
||||
.asciz "@(#)ffs.s 8.1 (Berkeley) 6/4/93"
|
||||
#else
|
||||
RCSID("$NetBSD: ffs.S,v 1.2 2009/12/19 19:09:48 pooka Exp $")
|
||||
RCSID("$NetBSD: ffs.S,v 1.3 2011/07/04 11:18:23 mrg Exp $")
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -58,6 +58,7 @@
|
|||
* one, we just return the table value plus 24. This means
|
||||
* that ffstab[0] must be -24 so that ffs(0) will return 0.
|
||||
*/
|
||||
WEAK_ALIAS(__ffssi2,ffs)
|
||||
ENTRY(ffs)
|
||||
#ifdef PIC
|
||||
PICCY_SET(ffstab, %o2, %o3)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bswap16.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
/* $NetBSD: bswap16.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
|
@ -31,14 +31,17 @@
|
|||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: bswap16.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
ENTRY(_C_LABEL(bswap16), 0)
|
||||
ALTENTRY(_C_LABEL(bswap16))
|
||||
#else
|
||||
ALTENTRY(_C_LABEL(ntohs))
|
||||
ALTENTRY(_C_LABEL(htons))
|
||||
ENTRY(_C_LABEL(__bswap16), 0)
|
||||
#endif
|
||||
ENTRY(_C_LABEL(__bswap16), 0)
|
||||
movl 4(%ap), %r1
|
||||
extzv $8, $8, %r1, %r0
|
||||
insv %r1, $8, $8, %r0
|
||||
ret
|
||||
END(_C_LABEL(__bswap16))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bswap32.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
|
||||
/* $NetBSD: bswap32.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -31,18 +31,18 @@
|
|||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: bswap32.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
ENTRY(_C_LABEL(bswap32), 0)
|
||||
ALTENTRY(_C_LABEL(bswap32))
|
||||
#else
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
ALTENTRY(_C_LABEL(ntohl))
|
||||
ALTENTRY(_C_LABEL(htonl))
|
||||
#endif
|
||||
ENTRY(_C_LABEL(__bswap32), 0)
|
||||
#endif
|
||||
rotl $-8, 4(%ap), %r0
|
||||
insv %r0, $16, $8, %r0
|
||||
rotl $8, 4(%ap), %r1
|
||||
movb %r1, %r0
|
||||
ret
|
||||
|
||||
END(_C_LABEL(__bswap32))
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
/* Written by Anders Magnusson. Public Domain */
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.asciz "$NetBSD: bswap64.S,v 1.2 2005/12/24 08:33:32 matt Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
RCSID("$NetBSD: bswap64.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
ENTRY(bswap64, 0)
|
||||
movq 4(%ap),%r3
|
||||
rotl $-8,%r3,%r1
|
||||
|
@ -17,3 +15,4 @@ ENTRY(bswap64, 0)
|
|||
rotl $8,%r4,%r2
|
||||
movb %r2,%r0
|
||||
ret
|
||||
END(bswap64)
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#include <machine/asm.h>
|
||||
|
||||
/* .asciz "@(#)udiv.s 8.1 (Berkeley) 6/4/93" */
|
||||
.asciz "$NetBSD: udiv.S,v 1.2 2005/12/24 08:33:32 matt Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
RCSID("$NetBSD: udiv.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
/*
|
||||
* Unsigned division, PCC flavor.
|
||||
|
@ -41,16 +41,10 @@
|
|||
* audiv() takes a pointer to a dividend and an ordinary divisor.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#define DIVIDEND 4(%ap)
|
||||
#define DIVISOR 8(%ap)
|
||||
|
||||
#ifdef __ELF__
|
||||
ASENTRY(__udiv,0)
|
||||
#else
|
||||
ASENTRY(udiv,0)
|
||||
#endif
|
||||
movl DIVISOR,%r2
|
||||
jlss Leasy # big divisor: settle by comparison
|
||||
movl DIVIDEND,%r0
|
||||
|
@ -69,12 +63,9 @@ Leasy:
|
|||
Lone:
|
||||
movl $1,%r0
|
||||
ret
|
||||
END(__udiv)
|
||||
|
||||
#ifdef __ELF__
|
||||
ASENTRY(__audiv,0)
|
||||
#else
|
||||
ASENTRY(audiv,0)
|
||||
#endif
|
||||
movl DIVIDEND,%r3
|
||||
movl DIVISOR,%r2
|
||||
jlss La_easy # big divisor: settle by comparison
|
||||
|
@ -98,3 +89,4 @@ La_one:
|
|||
movl $1,%r0
|
||||
movl %r0,(%r3)
|
||||
ret
|
||||
END(__audiv)
|
||||
|
|
|
@ -30,13 +30,11 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
/* .asciz "@(#)urem.s 8.1 (Berkeley) 6/4/93" */
|
||||
.asciz "$NetBSD: urem.S,v 1.2 2005/12/24 08:33:32 matt Exp $"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
/* .asciz "@(#)urem.s 8.1 (Berkeley) 6/4/93" */
|
||||
RCSID("$NetBSD: urem.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
/*
|
||||
* Unsigned modulus, PCC flavor.
|
||||
* urem() takes an ordinary dividend/divisor pair;
|
||||
|
@ -46,11 +44,7 @@
|
|||
#define DIVIDEND 4(%ap)
|
||||
#define DIVISOR 8(%ap)
|
||||
|
||||
#ifdef __ELF__
|
||||
ASENTRY(__urem,0)
|
||||
#else
|
||||
ASENTRY(urem,0)
|
||||
#endif
|
||||
movl DIVISOR,%r2
|
||||
jlss Leasy # big divisor: settle by comparison
|
||||
movl DIVIDEND,%r0
|
||||
|
@ -69,12 +63,9 @@ Leasy:
|
|||
movl DIVIDEND,%r0 # if divisor is bigger, return dividend
|
||||
Ldifference:
|
||||
ret
|
||||
END(__urem)
|
||||
|
||||
#ifdef __ELF__
|
||||
ASENTRY(__aurem,0)
|
||||
#else
|
||||
ASENTRY(aurem,0)
|
||||
#endif
|
||||
movl DIVIDEND,%r3
|
||||
movl DIVISOR,%r2
|
||||
jlss La_easy # big divisor: settle by comparison
|
||||
|
@ -98,3 +89,4 @@ La_easy:
|
|||
La_dividend:
|
||||
movl (%r3),%r0
|
||||
ret
|
||||
END(__aurem)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memcpy.S,v 1.2 2005/12/24 08:33:32 matt Exp $ */
|
||||
/* $NetBSD: memcpy.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -28,9 +28,10 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.asciz "@(#)memcpy.s 8.1 (Berkeley) 6/4/93"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <machine/asm.h>
|
||||
|
||||
/* .asciz "@(#)memcpy.s 8.1 (Berkeley) 6/4/93" */
|
||||
RCSID("$NetBSD: memcpy.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
/*
|
||||
* void *memcpy(dst, src, size)
|
||||
|
@ -40,8 +41,6 @@
|
|||
* of some extra memory references and branches when count >= 65536.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(memcpy, 0)
|
||||
movzwl $65535,%r0 /* %r0 = 64K (needed below) */
|
||||
movq 8(%ap),%r1 /* %r1 = src, %r2 = length */
|
||||
|
@ -88,3 +87,4 @@ ENTRY(memcpy, 0)
|
|||
subl2 %r0,%r1
|
||||
subl2 %r0,%r3
|
||||
brb 5b
|
||||
END(memcpy)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memmove.S,v 1.2 2005/12/24 08:33:32 matt Exp $ */
|
||||
/* $NetBSD: memmove.S,v 1.3 2011/01/25 04:45:28 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -28,9 +28,10 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.asciz "@(#)memmove.s 8.1 (Berkeley) 6/4/93"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <machine/asm.h>
|
||||
|
||||
/* .asciz "@(#)memmove.s 8.1 (Berkeley) 6/4/93" */
|
||||
RCSID("$NetBSD: memmove.S,v 1.3 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
/*
|
||||
* void *memmove(dst, src, size)
|
||||
|
@ -40,8 +41,6 @@
|
|||
* of some extra memory references and branches when count >= 65536.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(memmove, 0)
|
||||
movzwl $65535,%r0 /* %r0 = 64K (needed below) */
|
||||
movq 8(%ap),%r1 /* %r1 = src, %r2 = length */
|
||||
|
@ -88,3 +87,4 @@ ENTRY(memmove, 0)
|
|||
subl2 %r0,%r1
|
||||
subl2 %r0,%r3
|
||||
brb 5b
|
||||
END(memmove)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memset.S,v 1.1 2010/03/12 09:12:34 uwe Exp $ */
|
||||
/* $NetBSD: memset.S,v 1.2 2011/01/25 04:45:28 matt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -28,14 +28,13 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
.asciz "@(#)memset.s 8.1 (Berkeley) 6/4/93"
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <machine/asm.h>
|
||||
|
||||
/* .asciz "@(#)memset.s 8.1 (Berkeley) 6/4/93" */
|
||||
RCSID("$NetBSD: memset.S,v 1.2 2011/01/25 04:45:28 matt Exp $")
|
||||
|
||||
/* void *memset(base, c, length) */
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(memset, 0)
|
||||
movl 4(%ap),%r3
|
||||
1:
|
||||
|
@ -50,3 +49,4 @@ ENTRY(memset, 0)
|
|||
subl2 %r0,12(%ap)
|
||||
movc5 $0,(%r3),%r1,%r0,(%r3)
|
||||
jbr 1b
|
||||
END(memset)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $ */
|
||||
/* $NetBSD: atomic_init_testset.c,v 1.8 2012/02/28 20:41:19 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: atomic_init_testset.c,v 1.7 2009/12/14 00:39:00 matt Exp $");
|
||||
__RCSID("$NetBSD: atomic_init_testset.c,v 1.8 2012/02/28 20:41:19 joerg Exp $");
|
||||
|
||||
#include "atomic_op_namespace.h"
|
||||
|
||||
|
@ -139,6 +139,10 @@ __libc_atomic_init(void)
|
|||
#undef atomic_cas_uint
|
||||
#undef atomic_cas_ulong
|
||||
#undef atomic_cas_ptr
|
||||
#undef atomic_cas_32_ni
|
||||
#undef atomic_cas_uint_ni
|
||||
#undef atomic_cas_ulong_ni
|
||||
#undef atomic_cas_ptr_ni
|
||||
|
||||
atomic_op_alias(atomic_cas_32,_atomic_cas_32)
|
||||
atomic_op_alias(atomic_cas_uint,_atomic_cas_32)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bswap16.c,v 1.2 2008/02/16 17:37:13 apb Exp $ */
|
||||
/* $NetBSD: bswap16.c,v 1.4 2012/03/17 20:57:35 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: bswap16.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
|
||||
__RCSID("$NetBSD: bswap16.c,v 1.4 2012/03/17 20:57:35 martin Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -16,8 +16,8 @@ __RCSID("$NetBSD: bswap16.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
|
|||
#undef bswap16
|
||||
|
||||
uint16_t
|
||||
bswap16(x)
|
||||
uint16_t x;
|
||||
bswap16(uint16_t x)
|
||||
{
|
||||
/*LINTED*/
|
||||
return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bswap32.c,v 1.2 2008/02/16 17:37:13 apb Exp $ */
|
||||
/* $NetBSD: bswap32.c,v 1.3 2011/07/04 21:20:27 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Written by Manuel Bouyer <bouyer@NetBSD.org>.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: bswap32.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
|
||||
__RCSID("$NetBSD: bswap32.c,v 1.3 2011/07/04 21:20:27 joerg Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -16,8 +16,7 @@ __RCSID("$NetBSD: bswap32.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
|
|||
#undef bswap32
|
||||
|
||||
uint32_t
|
||||
bswap32(x)
|
||||
uint32_t x;
|
||||
bswap32(uint32_t x)
|
||||
{
|
||||
return ((x << 24) & 0xff000000 ) |
|
||||
((x << 8) & 0x00ff0000 ) |
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $ */
|
||||
/* $NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -40,7 +40,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/systm.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $");
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
@ -53,7 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
|
|||
#else
|
||||
#define KASSERT(e) do { } while (/*CONSTCOND*/ 0)
|
||||
#endif
|
||||
__RCSID("$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
|
||||
__RCSID("$NetBSD: ptree.c,v 1.10 2012/10/06 22:15:09 matt Exp $");
|
||||
#endif /* _KERNEL || _STANDALONE */
|
||||
|
||||
#ifdef _LIBC
|
||||
|
@ -77,7 +77,7 @@ __RCSID("$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
|
|||
*
|
||||
* However, allocation for these branching nodes is problematic since the
|
||||
* allocation could fail. This would cause insertions to fail for reasons
|
||||
* beyond the users control. So to prevent this, in this implementation
|
||||
* beyond the user's control. So to prevent this, in this implementation
|
||||
* each node has two identities: its leaf identity and its branch identity.
|
||||
* Each is separate from the other. Every branch is tagged as to whether
|
||||
* it points to a leaf or a branch. This is not an attribute of the object
|
||||
|
@ -93,7 +93,7 @@ __RCSID("$NetBSD: ptree.c,v 1.5 2009/06/07 03:12:40 yamt Exp $");
|
|||
*
|
||||
* Branching nodes also has a bit offset and a bit length which determines
|
||||
* which branch slot is used. The bit length can be zero resulting in a
|
||||
* one-way branch. This is happens in two special cases: the root and
|
||||
* one-way branch. This happens in two special cases: the root and
|
||||
* interior mask nodes.
|
||||
*
|
||||
* To support longest match first lookups, when a mask node (one that only
|
||||
|
@ -124,8 +124,8 @@ ptree_matchnode(const pt_tree_t *pt, const pt_node_t *target,
|
|||
pt_bitoff_t *bitoff_p, pt_slot_t *slots_p)
|
||||
{
|
||||
return (*pt->pt_ops->ptto_matchnode)(NODETOKEY(pt, target),
|
||||
(ptn != NULL ? NODETOKEY(pt, ptn) : NULL), max_bitoff,
|
||||
bitoff_p, slots_p);
|
||||
(ptn != NULL ? NODETOKEY(pt, ptn) : NULL),
|
||||
max_bitoff, bitoff_p, slots_p, pt->pt_context);
|
||||
}
|
||||
|
||||
static inline pt_slot_t
|
||||
|
@ -134,10 +134,9 @@ ptree_testnode(const pt_tree_t *pt, const pt_node_t *target,
|
|||
{
|
||||
const pt_bitlen_t bitlen = PTN_BRANCH_BITLEN(ptn);
|
||||
if (bitlen == 0)
|
||||
return PT_SLOT_ROOT;
|
||||
return PT_SLOT_ROOT; /* mask or root, doesn't matter */
|
||||
return (*pt->pt_ops->ptto_testnode)(NODETOKEY(pt, target),
|
||||
PTN_BRANCH_BITOFF(ptn),
|
||||
bitlen);
|
||||
PTN_BRANCH_BITOFF(ptn), bitlen, pt->pt_context);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
@ -145,15 +144,17 @@ ptree_matchkey(const pt_tree_t *pt, const void *key,
|
|||
const pt_node_t *ptn, pt_bitoff_t bitoff, pt_bitlen_t bitlen)
|
||||
{
|
||||
return (*pt->pt_ops->ptto_matchkey)(key, NODETOKEY(pt, ptn),
|
||||
bitoff, bitlen);
|
||||
bitoff, bitlen, pt->pt_context);
|
||||
}
|
||||
|
||||
static inline pt_slot_t
|
||||
ptree_testkey(const pt_tree_t *pt, const void *key, const pt_node_t *ptn)
|
||||
{
|
||||
return (*pt->pt_ops->ptto_testkey)(key,
|
||||
PTN_BRANCH_BITOFF(ptn),
|
||||
PTN_BRANCH_BITLEN(ptn));
|
||||
const pt_bitlen_t bitlen = PTN_BRANCH_BITLEN(ptn);
|
||||
if (bitlen == 0)
|
||||
return PT_SLOT_ROOT; /* mask or root, doesn't matter */
|
||||
return (*pt->pt_ops->ptto_testkey)(key, PTN_BRANCH_BITOFF(ptn),
|
||||
PTN_BRANCH_BITLEN(ptn), pt->pt_context);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -166,12 +167,13 @@ ptree_set_position(uintptr_t node, pt_slot_t position)
|
|||
}
|
||||
|
||||
void
|
||||
ptree_init(pt_tree_t *pt, const pt_tree_ops_t *ops, size_t node_offset,
|
||||
size_t key_offset)
|
||||
ptree_init(pt_tree_t *pt, const pt_tree_ops_t *ops, void *context,
|
||||
size_t node_offset, size_t key_offset)
|
||||
{
|
||||
memset(pt, 0, sizeof(*pt));
|
||||
pt->pt_node_offset = node_offset;
|
||||
pt->pt_key_offset = key_offset;
|
||||
pt->pt_context = context;
|
||||
pt->pt_ops = ops;
|
||||
}
|
||||
|
||||
|
@ -456,6 +458,12 @@ ptree_insert_node_common(pt_tree_t *pt, void *item)
|
|||
pt_insertfunc_t insertfunc;
|
||||
pt_insertdata_t id;
|
||||
|
||||
/*
|
||||
* If this node already exists in the tree, return failure.
|
||||
*/
|
||||
if (target == PT_NODE(pt->pt_root))
|
||||
return false;
|
||||
|
||||
/*
|
||||
* We need a leaf so we can match against. Until we get a leaf
|
||||
* we having nothing to test against.
|
||||
|
@ -477,6 +485,12 @@ ptree_insert_node_common(pt_tree_t *pt, void *item)
|
|||
pt_node_t * const ptn = PT_NODE(*id.id_insertp);
|
||||
id.id_node = *id.id_insertp;
|
||||
|
||||
/*
|
||||
* If this node already exists in the tree, return failure.
|
||||
*/
|
||||
if (target == ptn)
|
||||
return false;
|
||||
|
||||
/*
|
||||
* If we hit a leaf, try to insert target at leaf. We could
|
||||
* have inlined ptree_insert_leaf here but that would have
|
||||
|
@ -614,7 +628,7 @@ ptree_insert_mask_node(pt_tree_t *pt, void *item, pt_bitlen_t mask_len)
|
|||
#endif /* !PTNOMASH */
|
||||
|
||||
void *
|
||||
ptree_find_filtered_node(pt_tree_t *pt, void *key, pt_filter_t filter,
|
||||
ptree_find_filtered_node(pt_tree_t *pt, const void *key, pt_filter_t filter,
|
||||
void *filter_arg)
|
||||
{
|
||||
#ifndef PTNOMASK
|
||||
|
@ -1200,3 +1214,17 @@ ptree_check(const pt_tree_t *pt)
|
|||
#endif
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
ptree_mask_node_p(pt_tree_t *pt, const void *item, pt_bitlen_t *lenp)
|
||||
{
|
||||
const pt_node_t * const mask = ITEMTONODE(pt, item);
|
||||
|
||||
if (!PTN_ISMASK_P(mask))
|
||||
return false;
|
||||
|
||||
if (lenp != NULL)
|
||||
*lenp = PTN_MASK_BITLEN(mask);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
1466
common/lib/libc/gen/radixtree.c
Normal file
1466
common/lib/libc/gen/radixtree.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rb.c,v 1.9 2010/11/17 13:19:32 tron Exp $ */
|
||||
/* $NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -39,8 +39,10 @@
|
|||
#else
|
||||
#define KASSERT(s) do { } while (/*CONSTCOND*/ 0)
|
||||
#endif
|
||||
__RCSID("$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $");
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rb.c,v 1.11 2011/06/20 09:11:16 mrg Exp $");
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
|
@ -89,7 +91,7 @@ rb_tree_init(struct rb_tree *rbt, const rb_tree_ops_t *ops)
|
|||
{
|
||||
|
||||
rbt->rbt_ops = ops;
|
||||
*((const struct rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE;
|
||||
rbt->rbt_root = RB_SENTINEL_NODE;
|
||||
RB_TAILQ_INIT(&rbt->rbt_nodes);
|
||||
#ifndef RBSMALL
|
||||
rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $ */
|
||||
/* $NetBSD: rpst.c,v 1.11 2011/04/26 20:53:34 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2009 YAMAMOTO Takashi,
|
||||
|
@ -42,11 +42,15 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if defined(_KERNEL)
|
||||
__KERNEL_RCSID(0, "$NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $");
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
__KERNEL_RCSID(0, "$NetBSD: rpst.c,v 1.11 2011/04/26 20:53:34 yamt Exp $");
|
||||
#include <sys/param.h>
|
||||
#else /* defined(_KERNEL) */
|
||||
__RCSID("$NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $");
|
||||
#include <lib/libkern/libkern.h>
|
||||
#if defined(_STANDALONE)
|
||||
#include <lib/libsa/stand.h>
|
||||
#endif /* defined(_STANDALONE) */
|
||||
#else /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
__RCSID("$NetBSD: rpst.c,v 1.11 2011/04/26 20:53:34 yamt Exp $");
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
@ -55,7 +59,7 @@ __RCSID("$NetBSD: rpst.c,v 1.9 2009/05/26 22:39:15 yamt Exp $");
|
|||
#else
|
||||
#define KASSERT(a)
|
||||
#endif
|
||||
#endif /* defined(_KERNEL) */
|
||||
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
|
||||
|
||||
#include <sys/rpst.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mcount.c,v 1.8 2009/01/05 18:06:57 pooka Exp $ */
|
||||
/* $NetBSD: mcount.c,v 1.10 2012/03/20 16:21:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003, 2004 Wasabi Systems, Inc.
|
||||
|
@ -76,7 +76,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: mcount.c,v 1.8 2009/01/05 18:06:57 pooka Exp $");
|
||||
__RCSID("$NetBSD: mcount.c,v 1.10 2012/03/20 16:21:41 matt Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -93,11 +93,13 @@ extern struct gmonparam _gmondummy;
|
|||
struct gmonparam *_m_gmon_alloc(void);
|
||||
#endif
|
||||
|
||||
_MCOUNT_DECL __P((u_long, u_long))
|
||||
#ifndef __LINT__
|
||||
_MCOUNT_DECL(u_long, u_long)
|
||||
#ifdef _KERNEL
|
||||
__attribute__((__no_instrument_function__))
|
||||
#endif
|
||||
__used;
|
||||
#endif
|
||||
|
||||
/* XXX: make these interfaces */
|
||||
#ifdef _RUMPKERNEL
|
||||
|
@ -124,8 +126,9 @@ _MCOUNT_DECL __P((u_long, u_long))
|
|||
* both frompcindex and frompc. Any reasonable, modern compiler will
|
||||
* perform this optimization.
|
||||
*/
|
||||
_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
|
||||
u_long frompc, selfpc;
|
||||
#ifndef __LINT__
|
||||
/* _mcount; may be static, inline, etc */
|
||||
_MCOUNT_DECL(u_long frompc, u_long selfpc)
|
||||
{
|
||||
u_short *frompcindex;
|
||||
struct tostruct *top, *prevtop;
|
||||
|
@ -258,6 +261,7 @@ overflow:
|
|||
#endif
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MCOUNT
|
||||
/*
|
||||
|
|
90
common/lib/libc/hash/murmurhash/murmurhash.c
Normal file
90
common/lib/libc/hash/murmurhash/murmurhash.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* $NetBSD: murmurhash.c,v 1.4 2012/07/10 17:05:38 christos Exp $ */
|
||||
|
||||
/*
|
||||
* MurmurHash2 -- from the original code:
|
||||
*
|
||||
* "MurmurHash2 was written by Austin Appleby, and is placed in the public
|
||||
* domain. The author hereby disclaims copyright to this source code."
|
||||
*
|
||||
* References:
|
||||
* http://code.google.com/p/smhasher/
|
||||
* https://sites.google.com/site/murmurhash/
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
__KERNEL_RCSID(0, "$NetBSD: murmurhash.c,v 1.4 2012/07/10 17:05:38 christos Exp $");
|
||||
|
||||
#else
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: murmurhash.c,v 1.4 2012/07/10 17:05:38 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/hash.h>
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(murmurhash2,_murmurhash2)
|
||||
#endif
|
||||
|
||||
uint32_t
|
||||
murmurhash2(const void *key, size_t len, uint32_t seed)
|
||||
{
|
||||
/*
|
||||
* Note: 'm' and 'r' are mixing constants generated offline.
|
||||
* They're not really 'magic', they just happen to work well.
|
||||
* Initialize the hash to a 'random' value.
|
||||
*/
|
||||
const uint32_t m = 0x5bd1e995;
|
||||
const int r = 24;
|
||||
|
||||
const uint8_t *data = key;
|
||||
uint32_t h = seed ^ (uint32_t)len;
|
||||
|
||||
while (len >= sizeof(uint32_t)) {
|
||||
uint32_t k;
|
||||
|
||||
k = data[0];
|
||||
k |= data[1] << 8;
|
||||
k |= data[2] << 16;
|
||||
k |= data[3] << 24;
|
||||
|
||||
k *= m;
|
||||
k ^= k >> r;
|
||||
k *= m;
|
||||
|
||||
h *= m;
|
||||
h ^= k;
|
||||
|
||||
data += sizeof(uint32_t);
|
||||
len -= sizeof(uint32_t);
|
||||
}
|
||||
|
||||
/* Handle the last few bytes of the input array. */
|
||||
switch (len) {
|
||||
case 3:
|
||||
h ^= data[2] << 16;
|
||||
/* FALLTHROUGH */
|
||||
case 2:
|
||||
h ^= data[1] << 8;
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
h ^= data[0];
|
||||
h *= m;
|
||||
}
|
||||
|
||||
/*
|
||||
* Do a few final mixes of the hash to ensure the last few
|
||||
* bytes are well-incorporated.
|
||||
*/
|
||||
h ^= h >> 13;
|
||||
h *= m;
|
||||
h ^= h >> 15;
|
||||
|
||||
return h;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: inet_addr.c,v 1.2 2008/02/16 17:37:13 apb Exp $ */
|
||||
/* $NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1990, 1993
|
||||
|
@ -77,7 +77,7 @@
|
|||
static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
|
||||
static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: inet_addr.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
|
||||
__RCSID("$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -125,7 +125,8 @@ inet_addr(const char *cp) {
|
|||
int
|
||||
inet_aton(const char *cp, struct in_addr *addr) {
|
||||
uint32_t val;
|
||||
int base, n;
|
||||
int base;
|
||||
size_t n;
|
||||
char c;
|
||||
uint8_t parts[4];
|
||||
uint8_t *pp = parts;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md4c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $ */
|
||||
/* $NetBSD: md4c.c,v 1.5 2012/03/20 16:21:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* This file is derived from the RSA Data Security, Inc. MD4 Message-Digest
|
||||
|
@ -31,7 +31,7 @@
|
|||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: md4c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $");
|
||||
__RCSID("$NetBSD: md4c.c,v 1.5 2012/03/20 16:21:41 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
@ -76,10 +76,10 @@ typedef uint32_t UINT4;
|
|||
#define S33 11
|
||||
#define S34 15
|
||||
|
||||
static void MD4Transform __P((UINT4 [4], const unsigned char [64]));
|
||||
static void MD4Transform(UINT4 [4], const unsigned char [64]);
|
||||
|
||||
static void Encode __P((unsigned char *, UINT4 *, unsigned int));
|
||||
static void Decode __P((UINT4 *, const unsigned char *, unsigned int));
|
||||
static void Encode(unsigned char *, UINT4 *, unsigned int);
|
||||
static void Decode(UINT4 *, const unsigned char *, unsigned int);
|
||||
|
||||
static const unsigned char PADDING[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md5c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $ */
|
||||
/* $NetBSD: md5c.c,v 1.5 2012/03/20 16:21:41 matt Exp $ */
|
||||
|
||||
/*
|
||||
* This file is derived from the RSA Data Security, Inc. MD5 Message-Digest
|
||||
|
@ -36,7 +36,7 @@
|
|||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: md5c.c,v 1.4 2009/03/16 05:59:21 cegger Exp $");
|
||||
__RCSID("$NetBSD: md5c.c,v 1.5 2012/03/20 16:21:41 matt Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include "namespace.h"
|
||||
#include <sys/types.h>
|
||||
|
@ -84,10 +84,10 @@ __weak_alias(MD5Final,_MD5Final)
|
|||
__weak_alias(MD5Transform,_MD5Transform)
|
||||
#endif
|
||||
|
||||
static void MD5Transform __P((UINT4 [4], const unsigned char [64]));
|
||||
static void MD5Transform(UINT4 [4], const unsigned char [64]);
|
||||
|
||||
static void Encode __P((unsigned char *, UINT4 *, unsigned int));
|
||||
static void Decode __P((UINT4 *, const unsigned char *, unsigned int));
|
||||
static void Encode(unsigned char *, UINT4 *, unsigned int);
|
||||
static void Decode(UINT4 *, const unsigned char *, unsigned int);
|
||||
|
||||
/*
|
||||
* Encodes input (UINT4) into output (unsigned char). Assumes len is
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: htonl.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
/* $NetBSD: htonl.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: htonl.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
__RCSID("$NetBSD: htonl.c,v 1.3 2012/03/21 20:02:56 he Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -15,11 +15,10 @@ __RCSID("$NetBSD: htonl.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
|||
#undef htonl
|
||||
|
||||
uint32_t
|
||||
htonl(x)
|
||||
uint32_t x;
|
||||
htonl(uint32_t x)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_char *s = (u_char *)&x;
|
||||
u_char *s = (void *)&x;
|
||||
return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
|
||||
#else
|
||||
return x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: htons.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
/* $NetBSD: htons.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: htons.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
__RCSID("$NetBSD: htons.c,v 1.3 2012/03/21 20:02:56 he Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -15,11 +15,10 @@ __RCSID("$NetBSD: htons.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
|||
#undef htons
|
||||
|
||||
uint16_t
|
||||
htons(x)
|
||||
uint16_t x;
|
||||
htons(uint16_t x)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_char *s = (u_char *) &x;
|
||||
u_char *s = (void *) &x;
|
||||
return (uint16_t)(s[0] << 8 | s[1]);
|
||||
#else
|
||||
return x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntohl.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
/* $NetBSD: ntohl.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: ntohl.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
__RCSID("$NetBSD: ntohl.c,v 1.3 2012/03/21 20:02:56 he Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -15,11 +15,10 @@ __RCSID("$NetBSD: ntohl.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
|||
#undef ntohl
|
||||
|
||||
uint32_t
|
||||
ntohl(x)
|
||||
uint32_t x;
|
||||
ntohl(uint32_t x)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_char *s = (u_char *)&x;
|
||||
u_char *s = (void *)&x;
|
||||
return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
|
||||
#else
|
||||
return x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntohs.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */
|
||||
/* $NetBSD: ntohs.c,v 1.3 2012/03/21 20:02:56 he Exp $ */
|
||||
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@NetBSD.org>.
|
||||
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: ntohs.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
||||
__RCSID("$NetBSD: ntohs.c,v 1.3 2012/03/21 20:02:56 he Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -15,11 +15,10 @@ __RCSID("$NetBSD: ntohs.c,v 1.1 2005/12/20 19:28:51 christos Exp $");
|
|||
#undef ntohs
|
||||
|
||||
uint16_t
|
||||
ntohs(x)
|
||||
uint16_t x;
|
||||
ntohs(uint16_t x)
|
||||
{
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
u_char *s = (u_char *) &x;
|
||||
u_char *s = (void *) &x;
|
||||
return (uint16_t)(s[0] << 8 | s[1]);
|
||||
#else
|
||||
return x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ashldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
|
||||
/* $NetBSD: ashldi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ashldi3.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: ashldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
||||
__RCSID("$NetBSD: ashldi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -57,7 +57,7 @@ __ashldi3(quad_t a, qshift_t shift)
|
|||
return(a);
|
||||
aa.q = a;
|
||||
if (shift >= INT_BITS) {
|
||||
aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
|
||||
aa.ul[H] = aa.ul[L] << (unsigned int)(shift - INT_BITS);
|
||||
aa.ul[L] = 0;
|
||||
} else {
|
||||
aa.ul[H] = (aa.ul[H] << shift) |
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ashrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
|
||||
/* $NetBSD: ashrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,12 +38,14 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ashrdi3.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: ashrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
||||
__RCSID("$NetBSD: ashrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "quad.h"
|
||||
|
||||
ARM_EABI_ALIAS(__aeabi_lasr, __ashrdi3) /* no semicolon */
|
||||
|
||||
/*
|
||||
* Shift a (signed) quad value right (arithmetic shift right).
|
||||
*/
|
||||
|
@ -72,7 +74,7 @@ __ashrdi3(quad_t a, qshift_t shift)
|
|||
aa.ul[H] = s;
|
||||
} else {
|
||||
aa.ul[L] = (aa.ul[L] >> shift) |
|
||||
(aa.ul[H] << (INT_BITS - shift));
|
||||
(aa.ul[H] << (unsigned int)(INT_BITS - shift));
|
||||
/* LINTED inherits machine dependency */
|
||||
aa.sl[H] >>= shift;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lshldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
|
||||
/* $NetBSD: lshldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,12 +38,14 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)lshldi3.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lshldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
||||
__RCSID("$NetBSD: lshldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "quad.h"
|
||||
|
||||
ARM_EABI_ALIAS(__aeabi_llsl, __lshldi3) /* no semicolon */
|
||||
|
||||
/*
|
||||
* Shift an (unsigned) quad value left (logical shift left).
|
||||
* This is the same as arithmetic shift left!
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lshrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
|
||||
/* $NetBSD: lshrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,12 +38,14 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)lshrdi3.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lshrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
||||
__RCSID("$NetBSD: lshrdi3.c,v 1.4 2012/08/06 02:31:54 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "quad.h"
|
||||
|
||||
ARM_EABI_ALIAS(__aeabi_llsr, __lshrdi3) /* no semicolon */
|
||||
|
||||
/*
|
||||
* Shift an (unsigned) quad value right (logical shift right).
|
||||
*/
|
||||
|
@ -60,7 +62,7 @@ __lshrdi3(quad_t a, qshift_t shift)
|
|||
aa.ul[H] = 0;
|
||||
} else {
|
||||
aa.ul[L] = (aa.ul[L] >> shift) |
|
||||
(aa.ul[H] << (INT_BITS - shift));
|
||||
(aa.ul[H] << (unsigned int)(INT_BITS - shift));
|
||||
aa.ul[H] >>= shift;
|
||||
}
|
||||
return (aa.q);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: muldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
|
||||
/* $NetBSD: muldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,12 +38,14 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)muldi3.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: muldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
||||
__RCSID("$NetBSD: muldi3.c,v 1.3 2012/08/06 02:31:54 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "quad.h"
|
||||
|
||||
ARM_EABI_ALIAS(__aeabi_lmul, __muldi3) /* no semicolon */
|
||||
|
||||
/*
|
||||
* Multiply two quads.
|
||||
*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $ */
|
||||
/* $NetBSD: qdivrem.c,v 1.4 2012/03/20 16:21:41 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)qdivrem.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
||||
__RCSID("$NetBSD: qdivrem.c,v 1.4 2012/03/20 16:21:41 matt Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -49,10 +49,10 @@ __RCSID("$NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
|
|||
|
||||
#include "quad.h"
|
||||
|
||||
#define B ((int)1 << HALF_BITS) /* digit base */
|
||||
#define B ((int)1 << (unsigned int)HALF_BITS) /* digit base */
|
||||
|
||||
/* Combine two `digits' to make a single two-digit number. */
|
||||
#define COMBINE(a, b) (((u_int)(a) << HALF_BITS) | (b))
|
||||
#define COMBINE(a, b) (((u_int)(a) << (unsigned int)HALF_BITS) | (b))
|
||||
|
||||
/* select a type for digits in base B: use unsigned short if they fit */
|
||||
#if UINT_MAX == 0xffffffffU && USHRT_MAX >= 0xffff
|
||||
|
@ -61,7 +61,7 @@ typedef unsigned short digit;
|
|||
typedef u_int digit;
|
||||
#endif
|
||||
|
||||
static void shl __P((digit *p, int len, int sh));
|
||||
static void shl(digit *p, int len, int sh);
|
||||
|
||||
/*
|
||||
* __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
|
||||
|
@ -173,7 +173,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq)
|
|||
* D1: choose multiplier 1 << d to ensure v[1] >= B/2.
|
||||
*/
|
||||
d = 0;
|
||||
for (t = v[1]; t < B / 2; t <<= 1)
|
||||
for (t = v[1]; t < B / 2; t <<= (unsigned int)1)
|
||||
d++;
|
||||
if (d > 0) {
|
||||
shl(&u[0], m + n, d); /* u <<= d */
|
||||
|
@ -254,7 +254,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq)
|
|||
if (d) {
|
||||
for (i = m + n; i > m; --i)
|
||||
u[i] = (digit)(((u_int)u[i] >> d) |
|
||||
LHALF((u_int)u[i - 1] << (HALF_BITS - d)));
|
||||
LHALF((u_int)u[i - 1] << (unsigned int)(HALF_BITS - d)));
|
||||
u[i] = 0;
|
||||
}
|
||||
tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: quad.h,v 1.1 2005/12/20 20:29:40 christos Exp $ */
|
||||
/* $NetBSD: quad.h,v 1.7 2012/08/06 02:31:54 matt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -58,6 +58,12 @@
|
|||
#include <machine/limits.h>
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_EABI__) && !defined(lint)
|
||||
#define ARM_EABI_ALIAS(alias,sym) __strong_alias(alias,sym);
|
||||
#else
|
||||
#define ARM_EABI_ALIAS(alias,sym) /* nothing */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Depending on the desired operation, we view a `long long' (aka quad_t) in
|
||||
* one or more of the following formats.
|
||||
|
@ -94,8 +100,8 @@ union uu {
|
|||
* (sizeof(int)*CHAR_BIT/2).
|
||||
*/
|
||||
#define HHALF(x) ((u_int)(x) >> HALF_BITS)
|
||||
#define LHALF(x) ((u_int)(x) & (((int)1 << HALF_BITS) - 1))
|
||||
#define LHUP(x) ((u_int)(x) << HALF_BITS)
|
||||
#define LHALF(x) ((u_int)(x) & (((int)1 << (u_int)HALF_BITS) - 1))
|
||||
#define LHUP(x) ((u_int)(x) << (u_int)HALF_BITS)
|
||||
|
||||
/*
|
||||
* XXX
|
||||
|
@ -110,30 +116,35 @@ typedef u_quad_t qshift_t;
|
|||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
quad_t __adddi3 __P((quad_t, quad_t));
|
||||
quad_t __anddi3 __P((quad_t, quad_t));
|
||||
quad_t __ashldi3 __P((quad_t, qshift_t));
|
||||
quad_t __ashrdi3 __P((quad_t, qshift_t));
|
||||
int __cmpdi2 __P((quad_t, quad_t));
|
||||
quad_t __divdi3 __P((quad_t, quad_t));
|
||||
quad_t __fixdfdi __P((double));
|
||||
quad_t __fixsfdi __P((float));
|
||||
u_quad_t __fixunsdfdi __P((double));
|
||||
u_quad_t __fixunssfdi __P((float));
|
||||
double __floatdidf __P((quad_t));
|
||||
float __floatdisf __P((quad_t));
|
||||
double __floatunsdidf __P((u_quad_t));
|
||||
quad_t __iordi3 __P((quad_t, quad_t));
|
||||
quad_t __lshldi3 __P((quad_t, qshift_t));
|
||||
quad_t __lshrdi3 __P((quad_t, qshift_t));
|
||||
quad_t __moddi3 __P((quad_t, quad_t));
|
||||
quad_t __muldi3 __P((quad_t, quad_t));
|
||||
quad_t __negdi2 __P((quad_t));
|
||||
quad_t __one_cmpldi2 __P((quad_t));
|
||||
u_quad_t __qdivrem __P((u_quad_t, u_quad_t, u_quad_t *));
|
||||
quad_t __subdi3 __P((quad_t, quad_t));
|
||||
int __ucmpdi2 __P((u_quad_t, u_quad_t));
|
||||
u_quad_t __udivdi3 __P((u_quad_t, u_quad_t ));
|
||||
u_quad_t __umoddi3 __P((u_quad_t, u_quad_t ));
|
||||
quad_t __xordi3 __P((quad_t, quad_t));
|
||||
quad_t __adddi3(quad_t, quad_t);
|
||||
quad_t __anddi3(quad_t, quad_t);
|
||||
quad_t __ashldi3(quad_t, qshift_t);
|
||||
quad_t __ashrdi3(quad_t, qshift_t);
|
||||
int __cmpdi2(quad_t, quad_t);
|
||||
quad_t __divdi3(quad_t, quad_t);
|
||||
quad_t __fixtfdi(long double);
|
||||
quad_t __fixdfdi(double);
|
||||
quad_t __fixsfdi(float);
|
||||
u_quad_t __fixunstfdi(long double);
|
||||
u_quad_t __fixunsdfdi(double);
|
||||
u_quad_t __fixunssfdi(float);
|
||||
long double __floatditf(quad_t);
|
||||
double __floatdidf(quad_t);
|
||||
float __floatdisf(quad_t);
|
||||
long double __floatunditf(u_quad_t);
|
||||
double __floatundidf(u_quad_t);
|
||||
float __floatundisf(u_quad_t);
|
||||
quad_t __iordi3(quad_t, quad_t);
|
||||
quad_t __lshldi3(quad_t, qshift_t);
|
||||
quad_t __lshrdi3(quad_t, qshift_t);
|
||||
quad_t __moddi3(quad_t, quad_t);
|
||||
quad_t __muldi3(quad_t, quad_t);
|
||||
quad_t __negdi2(quad_t);
|
||||
quad_t __one_cmpldi2(quad_t);
|
||||
u_quad_t __qdivrem(u_quad_t, u_quad_t, u_quad_t *);
|
||||
quad_t __subdi3(quad_t, quad_t);
|
||||
int __ucmpdi2(u_quad_t, u_quad_t);
|
||||
u_quad_t __udivdi3(u_quad_t, u_quad_t );
|
||||
u_quad_t __umoddi3(u_quad_t, u_quad_t );
|
||||
quad_t __xordi3(quad_t, quad_t);
|
||||
__END_DECLS
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: _strtol.h,v 1.2 2009/05/20 22:03:29 christos Exp $ */
|
||||
/* $NetBSD: _strtol.h,v 1.3 2012/03/09 15:41:16 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -109,7 +109,7 @@ _FUNCNAME(const char *nptr, char **endptr, int base)
|
|||
* Set any if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
cutoff = (neg ? __INT_MIN : __INT_MAX);
|
||||
cutoff = (__INT)(neg ? __INT_MIN : __INT_MAX);
|
||||
cutlim = (int)(cutoff % base);
|
||||
cutoff /= base;
|
||||
if (neg) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: _strtoul.h,v 1.1 2008/08/20 12:42:26 joerg Exp $ */
|
||||
/* $NetBSD: _strtoul.h,v 1.3 2012/03/22 15:57:29 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -91,8 +91,8 @@ _FUNCNAME(const char *nptr, char **endptr, int base)
|
|||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
cutoff = __UINT_MAX / (__UINT)base;
|
||||
cutlim = (int)(__UINT_MAX % (__UINT)base);
|
||||
cutoff = ((__UINT)__UINT_MAX / (__UINT)base);
|
||||
cutlim = (int)((__UINT)__UINT_MAX % (__UINT)base);
|
||||
for (acc = 0, any = 0;; c = *s++) {
|
||||
if (isdigit(c))
|
||||
i = c - '0';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bcmp.c,v 1.6 2009/04/25 12:20:48 skrll Exp $ */
|
||||
/* $NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: bcmp.c,v 1.6 2009/04/25 12:20:48 skrll Exp $");
|
||||
__RCSID("$NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -66,5 +66,5 @@ bcmp(const void *b1, const void *b2, size_t length)
|
|||
if (*p1++ != *p2++)
|
||||
break;
|
||||
while (--length);
|
||||
return(length);
|
||||
return length != 0;
|
||||
}
|
||||
|
|
19
common/lib/libc/string/consttime_bcmp.c
Normal file
19
common/lib/libc/string/consttime_bcmp.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* $NetBSD: consttime_bcmp.c,v 1.1 2012/08/30 12:16:49 drochner Exp $ */
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <string.h>
|
||||
#define consttime_bcmp __consttime_bcmp
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
#endif
|
||||
|
||||
int
|
||||
consttime_bcmp(const void *b1, const void *b2, size_t len)
|
||||
{
|
||||
const char *c1 = b1, *c2 = b2;
|
||||
int res = 0;
|
||||
|
||||
while (len --)
|
||||
res |= *c1++ ^ *c2++;
|
||||
return res;
|
||||
}
|
22
common/lib/libc/string/explicit_bzero.c
Normal file
22
common/lib/libc/string/explicit_bzero.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
/* $NetBSD: explicit_bzero.c,v 1.1 2012/08/30 12:16:49 drochner Exp $ */
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <string.h>
|
||||
#define explicit_bzero __explicit_bzero
|
||||
#define explicit_memset_impl __explicit_memset_impl
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The use of a volatile pointer guarantees that the compiler
|
||||
* will not optimise the call away.
|
||||
*/
|
||||
void *(* volatile explicit_memset_impl)(void *, int, size_t) = memset;
|
||||
|
||||
void
|
||||
explicit_bzero(void *b, size_t len)
|
||||
{
|
||||
|
||||
(*explicit_memset_impl)(b, 0, len);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $ */
|
||||
/* $NetBSD: ffs.c,v 1.4 2011/08/07 01:52:47 mrg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $");
|
||||
__RCSID("$NetBSD: ffs.c,v 1.4 2011/08/07 01:52:47 mrg Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -53,6 +53,7 @@ __RCSID("$NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $");
|
|||
/*
|
||||
* ffs -- vax ffs instruction
|
||||
*/
|
||||
__weak_alias(__ffssi2,ffs)
|
||||
int
|
||||
ffs(int mask)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memcmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */
|
||||
/* $NetBSD: memcmp.c,v 1.3 2011/11/08 16:52:11 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: memcmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
|
||||
__RCSID("$NetBSD: memcmp.c,v 1.3 2011/11/08 16:52:11 joerg Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -48,6 +48,7 @@ __RCSID("$NetBSD: memcmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
|
|||
#include <lib/libkern/libkern.h>
|
||||
#endif
|
||||
|
||||
#undef memcmp
|
||||
/*
|
||||
* Compare memory regions.
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: memset.c,v 1.8 2009/03/18 12:25:06 tsutsui Exp $ */
|
||||
/* $NetBSD: memset.c,v 1.9 2011/11/08 16:52:11 joerg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: memset.c,v 1.8 2009/03/18 12:25:06 tsutsui Exp $");
|
||||
__RCSID("$NetBSD: memset.c,v 1.9 2011/11/08 16:52:11 joerg Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -60,8 +60,8 @@ __RCSID("$NetBSD: memset.c,v 1.8 2009/03/18 12:25:06 tsutsui Exp $");
|
|||
|
||||
#ifdef _FORTIFY_SOURCE
|
||||
#undef bzero
|
||||
#undef memset
|
||||
#endif
|
||||
#undef memset
|
||||
|
||||
#ifndef __OPTIMIZE_SIZE__
|
||||
#ifdef BZERO
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: memset2.c,v 1.5 2012/03/02 16:22:27 apb Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
|
@ -49,18 +54,16 @@
|
|||
|
||||
#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 */
|
||||
#undef memset
|
||||
|
||||
/*
|
||||
* Assume uregister_t is the widest non-synthetic unsigned type.
|
||||
*/
|
||||
typedef uregister_t memword_t;
|
||||
|
||||
__CTASSERT((~(memword_t)0U >> 1) != ~(memword_t)0U);
|
||||
|
||||
#ifdef BZERO
|
||||
static inline
|
||||
#define memset memset0
|
||||
|
@ -71,10 +74,6 @@ 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)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: popcount32.c,v 1.3 2009/07/21 19:56:55 drochner Exp $ */
|
||||
/* $NetBSD: popcount32.c,v 1.4 2011/08/21 21:25:04 dholland Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -32,10 +32,11 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: popcount32.c,v 1.3 2009/07/21 19:56:55 drochner Exp $");
|
||||
__RCSID("$NetBSD: popcount32.c,v 1.4 2011/08/21 21:25:04 dholland Exp $");
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <strings.h>
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: popcount64.c,v 1.5 2009/08/05 15:04:15 joerg Exp $ */
|
||||
/* $NetBSD: popcount64.c,v 1.7 2012/03/09 15:41:16 christos Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -32,10 +32,11 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: popcount64.c,v 1.5 2009/08/05 15:04:15 joerg Exp $");
|
||||
__RCSID("$NetBSD: popcount64.c,v 1.7 2012/03/09 15:41:16 christos Exp $");
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <strings.h>
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
|
@ -63,10 +64,12 @@ popcount64(uint64_t v)
|
|||
{
|
||||
unsigned int c;
|
||||
|
||||
v = v - ((v >> 1) & 0x5555555555555555ULL);
|
||||
v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
|
||||
v = ((v + (v >> 4)) & 0x0f0f0f0f0f0f0f0fULL) * 0x0101010101010101ULL;
|
||||
c = v >> 56;
|
||||
v = v - ((v >> 1) & (uint64_t)0x5555555555555555ULL);
|
||||
v = (v & (uint64_t)0x3333333333333333ULL) +
|
||||
((v >> 2) & (uint64_t)0x3333333333333333ULL);
|
||||
v = ((v + (v >> 4)) & (uint64_t)0x0f0f0f0f0f0f0f0fULL) *
|
||||
(uint64_t)0x0101010101010101ULL;
|
||||
c = (unsigned int)(v >> 56);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: strchr.c,v 1.4 2009/07/17 19:37:57 dsl Exp $ */
|
||||
/* $NetBSD: strchr.c,v 1.5 2011/08/31 15:48:32 plunky Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)index.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: strchr.c,v 1.4 2009/07/17 19:37:57 dsl Exp $");
|
||||
__RCSID("$NetBSD: strchr.c,v 1.5 2011/08/31 15:48:32 plunky Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -59,7 +59,7 @@ strchr(const char *p, int ch)
|
|||
return(__UNCONST(p));
|
||||
}
|
||||
if (!*p)
|
||||
return((char *)NULL);
|
||||
return(NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: strcpy.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */
|
||||
/* $NetBSD: strcpy.c,v 1.3 2011/11/08 16:52:11 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: strcpy.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
|
||||
__RCSID("$NetBSD: strcpy.c,v 1.3 2011/11/08 16:52:11 joerg Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -45,9 +45,7 @@ __RCSID("$NetBSD: strcpy.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
|
|||
#include <lib/libkern/libkern.h>
|
||||
#endif
|
||||
|
||||
#ifdef _FORTIFY_SOURCE
|
||||
#undef strcpy
|
||||
#endif
|
||||
|
||||
char *
|
||||
strcpy(char *to, const char *from)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: strnlen.c,v 1.1 2009/05/01 17:27:01 perry Exp $ */
|
||||
/* $NetBSD: strnlen.c,v 1.1 2011/09/01 22:35:18 jym Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 David Schultz <das@FreeBSD.org>
|
||||
|
@ -28,11 +28,15 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: strnlen.c,v 1.1 2009/05/01 17:27:01 perry Exp $");
|
||||
__RCSID("$NetBSD: strnlen.c,v 1.1 2011/09/01 22:35:18 jym Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
/* FreeBSD: src/lib/libc/string/strnlen.c,v 1.1 2009/02/28 06:00:58 das Exp */
|
||||
|
||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
#endif
|
||||
|
||||
size_t
|
||||
strnlen(const char *s, size_t maxlen)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cpuset.c,v 1.16 2010/09/21 02:03:29 rmind Exp $ */
|
||||
/* $NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -32,7 +32,7 @@
|
|||
#ifndef _STANDALONE
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: cpuset.c,v 1.16 2010/09/21 02:03:29 rmind Exp $");
|
||||
__RCSID("$NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -64,24 +64,11 @@ struct _cpuset {
|
|||
uint32_t bits[0];
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
struct _kcpuset {
|
||||
unsigned int nused;
|
||||
struct _kcpuset *next;
|
||||
uint32_t bits[0];
|
||||
};
|
||||
#define KCPUSET_SIZE(n) (sizeof( \
|
||||
struct { \
|
||||
unsigned int nused; \
|
||||
struct _kcpuset *next; \
|
||||
uint32_t bits[0]; \
|
||||
}) + sizeof(uint32_t) * (n))
|
||||
#endif
|
||||
#ifndef _KERNEL
|
||||
|
||||
static size_t cpuset_size = 0;
|
||||
static size_t cpuset_nentries = 0;
|
||||
|
||||
#ifndef _KERNEL
|
||||
size_t
|
||||
/*ARGSUSED*/
|
||||
_cpuset_size(const cpuset_t *c)
|
||||
|
@ -106,7 +93,7 @@ _cpuset_isset(cpuid_t i, const cpuset_t *c)
|
|||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
return ((1 << (i & CPUSET_MASK)) & c->bits[j]) != 0;
|
||||
return ((1 << (unsigned int)(i & CPUSET_MASK)) & c->bits[j]) != 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -118,7 +105,7 @@ _cpuset_set(cpuid_t i, cpuset_t *c)
|
|||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
c->bits[j] |= 1 << (i & CPUSET_MASK);
|
||||
c->bits[j] |= 1 << (unsigned int)(i & CPUSET_MASK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -131,7 +118,7 @@ _cpuset_clr(cpuid_t i, cpuset_t *c)
|
|||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
c->bits[j] &= ~(1 << (i & CPUSET_MASK));
|
||||
c->bits[j] &= ~(1 << (unsigned int)(i & CPUSET_MASK));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -145,7 +132,8 @@ _cpuset_create(void)
|
|||
u_int nc;
|
||||
|
||||
len = sizeof(nc);
|
||||
if (sysctl(mib, __arraycount(mib), &nc, &len, NULL, 0) == -1)
|
||||
if (sysctl(mib, (unsigned int)__arraycount(mib), &nc, &len,
|
||||
NULL, 0) == -1)
|
||||
return NULL;
|
||||
|
||||
cpuset_nentries = CPUSET_NENTRIES(nc);
|
||||
|
@ -161,150 +149,5 @@ _cpuset_destroy(cpuset_t *c)
|
|||
free(c);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
kcpuset_t *
|
||||
kcpuset_create(void)
|
||||
{
|
||||
kcpuset_t *c;
|
||||
|
||||
if (cpuset_size == 0) {
|
||||
cpuset_nentries = CPUSET_NENTRIES(MAXCPUS);
|
||||
cpuset_size = KCPUSET_SIZE(cpuset_nentries);
|
||||
}
|
||||
c = kmem_zalloc(cpuset_size, KM_SLEEP);
|
||||
c->next = NULL;
|
||||
c->nused = 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_destroy(kcpuset_t *c)
|
||||
{
|
||||
kcpuset_t *nc;
|
||||
|
||||
while (c) {
|
||||
KASSERT(c->nused == 0);
|
||||
nc = c->next;
|
||||
kmem_free(c, cpuset_size);
|
||||
c = nc;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_copy(kcpuset_t *d, const kcpuset_t *s)
|
||||
{
|
||||
|
||||
KASSERT(d->nused == 1);
|
||||
memcpy(d->bits, s->bits, cpuset_nentries * sizeof(s->bits[0]));
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_use(kcpuset_t *c)
|
||||
{
|
||||
|
||||
atomic_inc_uint(&c->nused);
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_unuse(kcpuset_t *c, kcpuset_t **lst)
|
||||
{
|
||||
|
||||
if (atomic_dec_uint_nv(&c->nused) != 0)
|
||||
return;
|
||||
KASSERT(c->nused == 0);
|
||||
KASSERT(c->next == NULL);
|
||||
if (lst == NULL) {
|
||||
kcpuset_destroy(c);
|
||||
return;
|
||||
}
|
||||
c->next = *lst;
|
||||
*lst = c;
|
||||
}
|
||||
|
||||
int
|
||||
kcpuset_copyin(const cpuset_t *u, kcpuset_t *k, size_t len)
|
||||
{
|
||||
|
||||
KASSERT(k->nused > 0);
|
||||
KASSERT(k->next == NULL);
|
||||
if (len != CPUSET_SIZE(cpuset_nentries))
|
||||
return EINVAL;
|
||||
return copyin(u->bits, k->bits, cpuset_nentries * sizeof(k->bits[0]));
|
||||
}
|
||||
|
||||
int
|
||||
kcpuset_copyout(const kcpuset_t *k, cpuset_t *u, size_t len)
|
||||
{
|
||||
|
||||
KASSERT(k->nused > 0);
|
||||
KASSERT(k->next == NULL);
|
||||
if (len != CPUSET_SIZE(cpuset_nentries))
|
||||
return EINVAL;
|
||||
return copyout(k->bits, u->bits, cpuset_nentries * sizeof(u->bits[0]));
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_zero(kcpuset_t *c)
|
||||
{
|
||||
|
||||
KASSERT(c->nused > 0);
|
||||
KASSERT(c->next == NULL);
|
||||
memset(c->bits, 0, cpuset_nentries * sizeof(c->bits[0]));
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_fill(kcpuset_t *c)
|
||||
{
|
||||
|
||||
KASSERT(c->nused > 0);
|
||||
KASSERT(c->next == NULL);
|
||||
memset(c->bits, ~0, cpuset_nentries * sizeof(c->bits[0]));
|
||||
}
|
||||
|
||||
void
|
||||
kcpuset_set(cpuid_t i, kcpuset_t *c)
|
||||
{
|
||||
const unsigned long j = i >> CPUSET_SHIFT;
|
||||
|
||||
KASSERT(c->next == NULL);
|
||||
KASSERT(j < cpuset_nentries);
|
||||
c->bits[j] |= 1 << (i & CPUSET_MASK);
|
||||
}
|
||||
|
||||
int
|
||||
kcpuset_isset(cpuid_t i, const kcpuset_t *c)
|
||||
{
|
||||
const unsigned long j = i >> CPUSET_SHIFT;
|
||||
|
||||
KASSERT(c != NULL);
|
||||
KASSERT(c->nused > 0);
|
||||
KASSERT(c->next == NULL);
|
||||
KASSERT(j < cpuset_nentries);
|
||||
return ((1 << (i & CPUSET_MASK)) & c->bits[j]) != 0;
|
||||
}
|
||||
|
||||
bool
|
||||
kcpuset_iszero(const kcpuset_t *c)
|
||||
{
|
||||
unsigned long j;
|
||||
|
||||
for (j = 0; j < cpuset_nentries; j++)
|
||||
if (c->bits[j] != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
kcpuset_match(const kcpuset_t *c1, const kcpuset_t *c2)
|
||||
{
|
||||
unsigned long j;
|
||||
|
||||
for (j = 0; j < cpuset_nentries; j++)
|
||||
if ((c1->bits[j] & c2->bits[j]) != c2->bits[j])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue