repo_id
stringlengths 5
115
| size
int64 590
5.01M
| file_path
stringlengths 4
212
| content
stringlengths 590
5.01M
|
|---|---|---|---|
0xffea/MINIX3
| 2,134
|
lib/csu/arch/sh3/crtn.S
|
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
.section ".init", "ax", @progbits
mov r14, sp
lds.l @sp+, pr
rts
mov.l @sp+, r14
.section ".fini", "ax", @progbits
mov r14, sp
lds.l @sp+, pr
rts
mov.l @sp+, r14
|
0xffea/MINIX3
| 2,207
|
lib/csu/arch/sh3/crti.S
|
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.align 4
.globl _init
_init:
mov.l r14, @-sp
sts.l pr, @-sp
mov sp, r14
.section ".fini", "ax", @progbits
.align 4
.globl _fini
_fini:
mov.l r14, @-sp
sts.l pr, @-sp
mov sp, r14
|
0xffea/MINIX3
| 2,106
|
lib/csu/arch/sh3/crt0.S
|
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
* Copyright (c) 1995 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
* NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
mov.l r9,@-r15
bra ___start
mov.l r8,@-r15
|
0xffea/MINIX3
| 3,404
|
lib/csu/arch/sparc/crtn.S
|
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*
* Copyright (c) 2001 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
.section ".init", "ax", @progbits
.align 4
ret
restore
.section ".fini", "ax", @progbits
.align 4
ret
restore
|
0xffea/MINIX3
| 3,485
|
lib/csu/arch/sparc/crti.S
|
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*
* Copyright (c) 2001 Matthew R. Green
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.align 4
.globl _init
_init:
save %sp, -96, %sp
.section ".fini", "ax", @progbits
.align 4
.globl _fini
_fini:
save %sp, -96, %sp
|
0xffea/MINIX3
| 2,368
|
lib/csu/arch/sparc/crt0.S
|
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
* Copyright (c) 1995 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
* NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
mov 0, %fp
ld [%sp + 64], %o0 ! get argc
add %sp, 68, %o1 ! get argv
sll %o0, 2, %o2 !
add %o2, 4, %o2 ! envp = argv + (argc << 2) + 4
add %o1, %o2, %o2 !
andn %sp, 7, %sp ! align
sub %sp, 24, %sp ! expand to standard stack frame size
mov %g3, %o3
mov %g2, %o4
call ___start
mov %g1, %o5
|
0xffea/MINIX3
| 2,040
|
lib/csu/arch/vax/crtn.S
|
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
.section ".init", "ax", @progbits
ret
.section ".fini", "ax", @progbits
ret
|
0xffea/MINIX3
| 2,133
|
lib/csu/arch/vax/crti.S
|
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.align 1
.globl _init
_init:
.word 0
.section ".fini", "ax", @progbits
.align 1
.globl _fini
_fini:
.word 0
|
0xffea/MINIX3
| 2,292
|
lib/csu/arch/vax/crt0.S
|
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*
* Copyright (c) 1999 Matt Thomas
* Copyright (c) 1995 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
* NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
.word 0x0101
pushl %r9 /* ps_strings */
pushl %r8 /* obj */
pushl %r7 /* cleanup */
movl (%r6),%r0 /* argc */
pushal 8(%r6)[%r0] /* envp = &argv[argc + 1] */
pushal 4(%r6) /* argv */
pushl %r0 /* argc */
calls $6,___start
|
0xffea/MINIX3
| 2,078
|
lib/csu/arch/arm/crtn.S
|
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
.section ".init", "ax", @progbits
ldmea fp, {fp, sp, pc}
.section ".fini", "ax", @progbits
ldmea fp, {fp, sp, pc}
|
0xffea/MINIX3
| 2,229
|
lib/csu/arch/arm/crti.S
|
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.align 0
.globl _init
_init:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
.section ".fini", "ax", @progbits
.align 0
.globl _fini
_fini:
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
|
0xffea/MINIX3
| 2,294
|
lib/csu/arch/arm/crt0.S
|
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */
/*
* Copyright (C) 1997 Mark Brinicombe
* Copyright (C) 1995 Wolfgang Solfrank.
* Copyright (C) 1995 TooLs GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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: crt0.S,v 1.1 2010/08/07 18:01:33 joerg Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
mov r5, r2 /* cleanup */
mov r4, r1 /* obj_main */
mov r3, r0 /* ps_strings */
/* Get argc, argv, and envp from stack */
ldr r0, [sp, #0x0000]
add r1, sp, #0x0004
add r2, r1, r0, lsl #2
add r2, r2, #0x0004
/* Ensure the stack is properly aligned before calling C code. */
bic sp, sp, #7
sub sp, sp, #8
str r5, [sp, #4]
str r4, [sp, #0]
b ___start
|
0xffea/MINIX3
| 2,070
|
lib/csu/arch/x86_64/crtn.S
|
/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:35 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:35 joerg Exp $")
.section ".init", "ax", @progbits
addq $8, %rsp
ret
.section ".fini", "ax", @progbits
addq $8, %rsp
ret
|
0xffea/MINIX3
| 2,147
|
lib/csu/arch/x86_64/crti.S
|
/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:35 joerg Exp $ */
/*-
* Copyright (c) 2001 Ross Harvey
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:35 joerg Exp $")
#include "sysident.S"
.section ".init", "ax", @progbits
.align 16
.globl _init
_init:
subq $8, %rsp
.section ".fini", "ax", @progbits
.align 16
.globl _fini
_fini:
subq $8, %rsp
|
0xffea/MINIX3
| 1,857
|
lib/csu/arch/x86_64/crtend.S
|
/* $NetBSD: crtend.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*-
* Copyright (c) 2010 Joerg Sonnenberger <joerg@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDERS 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: crtend.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
.section .ctors, "aw", @progbits
.align 8
.global __CTOR_LIST_END__
.hidden __CTOR_LIST_END__
__CTOR_LIST_END__:
.quad 0
.section .dtors, "aw", @progbits
.align 8
.quad 0
.section .eh_frame, "a", @progbits
.align 8
.quad 0
.section .jcr, "aw", @progbits
.align 8
.quad 0
|
0xffea/MINIX3
| 2,171
|
lib/csu/arch/x86_64/crt0.S
|
/* $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */
/*
* Copyright (c) 1998 Christos Zoulas
* Copyright (c) 1995 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
* NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
RCSID("$NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $")
STRONG_ALIAS(_start,__start)
_ENTRY(__start)
movq %rbx,%r9
movq %rcx,%r8
movq %rdx,%rcx
movq (%rsp),%rdi
leaq 16(%rsp,%rdi,8),%rdx
leaq 8(%rsp),%rsi
subq $8,%rsp
andq $~15,%rsp
addq $8,%rsp
jmp ___start
|
0xffea/MINIX3
| 3,420
|
lib/csu/arch/x86_64/crtbegin.S
|
/* $NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $ */
/*-
* Copyright (c) 2010 Joerg Sonnenberger <joerg@NetBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDERS 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: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $")
.section .ctors, "aw", @progbits
.align 8
__CTOR_LIST__:
.quad -1
.section .dtors, "aw", @progbits
.align 8
__DTOR_LIST__:
.quad -1
.section .eh_frame, "a", @progbits
.align 8
__EH_FRAME_LIST__:
.section .jcr, "aw", @progbits
.align 8
__JCR_LIST__:
.section .data.rel, "aw", @progbits
.align 8
.type __dso_handle, @object
.size __dso_handle, 8
.globl __dso_handle
.hidden __dso_handle
__dso_handle:
#ifdef SHARED
.quad __dso_handle
#else
.quad 0
#endif
__dwarf_eh_object:
.zero 64
__initialized:
.zero 1
__finished:
.zero 1
.text
.weak __cxa_finalize
.weak __deregister_frame_info
.weak __register_frame_info
.weak _Jv_RegisterClasses
__do_global_dtors_aux:
cmpb $0, __finished(%rip)
je 1f
ret
1:
pushq %rbx
movb $1, __finished(%rip)
#ifdef SHARED
cmpq $0, __cxa_finalize@GOTPCREL(%rip)
je 2f
movq __dso_handle(%rip), %rdi
call __cxa_finalize@PLT
2:
#endif
leaq 8+__DTOR_LIST__(%rip), %rbx
3:
movq (%rbx), %rax
testq %rax, %rax
je 4f
call *%rax
addq $8, %rbx
jmp 3b
4:
cmpq $0, __deregister_frame_info@GOTPCREL(%rip)
je 5f
leaq __EH_FRAME_LIST__(%rip), %rdi
call __deregister_frame_info@PLT
5:
popq %rbx
ret
__do_global_ctors_aux:
cmpb $0, __initialized(%rip)
je 1f
ret
1:
pushq %rbx
movb $1, __initialized(%rip)
cmpq $0, __register_frame_info@GOTPCREL(%rip)
je 2f
leaq __dwarf_eh_object(%rip), %rsi
leaq __EH_FRAME_LIST__(%rip), %rdi
call __register_frame_info@PLT
2:
cmpq $0, _Jv_RegisterClasses@GOTPCREL(%rip)
je 3f
leaq __JCR_LIST__(%rip), %rdi
cmpq $0, (%rdi)
je 3f
call _Jv_RegisterClasses@PLT
3:
leaq -8+__CTOR_LIST_END__(%rip), %rbx
4:
movq (%rbx), %rax
cmpq $-1, %rax
je 5f
call *%rax
subq $8, %rbx
jmp 4b
5:
popq %rbx
ret
.section .init, "ax", @progbits
call __do_global_ctors_aux
.section .fini, "ax", @progbits
call __do_global_dtors_aux
|
0xffea/MINIX3
| 2,886
|
libexec/ld.elf_so/arch/m68k/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.9 2008/04/28 20:23:03 martin Exp $ */
/*-
* Copyright (c) 1999, 2002, 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein and by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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>
.text
.align 4
.globl .rtld_start
.type .rtld_start,@function
.rtld_start:
subql #8,%sp | storage for obj and cleanup
lea (%pc,_GLOBAL_OFFSET_TABLE_@GOTPC),%a0
lea (%pc,_DYNAMIC),%a1
movel %a1,%a5
subl (%a0),%a5
movel %a5,-(%sp) | relocbase
movel %a1,-(%sp) | &_DYNAMIC
jbsr _rtld_relocate_nonplt_self@PLTPC
addql #8,%sp | pop arguments
movel %a5,-(%sp) | relocbase
pea 4(%sp) | sp
jbsr _rtld@PLTPC | entry = _rtld(sp, relocbase)
addql #8,%sp | pop arguments
moveal (%sp)+,%a1 | cleanup
moveal (%sp)+,%a0 | obj
moveal %d0,%a3
jmp (%a3) | Go for it!
.size .rtld_start,.-.rtld_start
.align 4
.globl _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start:
moveml %d0-%d1/%a0-%a1,-(%sp) | preserve caller-saved registers
movel 20(%sp),-(%sp) | push reloff
movel (16+4)(%sp),-(%sp) | push obj
jbsr _rtld_bind@PLTPC | %a0 = _rtld_bind(obj, reloff)
addql #8,%sp | pop args
#ifdef __SVR4_ABI__
movel %a0,(16+4)(%sp) | write fake `return' address over obj
#else
movel %d0,(16+4)(%sp) | write fake `return' address over obj
#endif
moveml (%sp)+,%d0-%d1/%a0-%a1 | restore caller-saved registers
addql #4,%sp | skip reloff
rts | `return' right into function
.size _rtld_bind_start,.-_rtld_bind_start
|
0xffea/MINIX3
| 2,753
|
libexec/ld.elf_so/arch/i386/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.11 2010/12/05 00:56:07 joerg Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas and by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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>
.text
.align 4
.globl .rtld_start
.hidden .rtld_start
.type .rtld_start,@function
.rtld_start:
subl $8,%esp # make room of obj_main and exit proc
pushl %ebx # save ps_strings
call 1f
1:
popl %edx
leal _DYNAMIC-1b(%edx),%ecx # &_DYNAMIC
movl %ecx,%ebx
subl _GLOBAL_OFFSET_TABLE_-1b(%edx),%ebx
pushl %ebx # relocbase
pushl %ecx # &_DYNAMIC
call _rtld_relocate_nonplt_self
leal 12(%esp),%eax # &cleanup
pushl %ebx # relocbase
pushl %eax # sp
call _rtld # _rtld(sp, relocbase)
addl $16,%esp # pop args
popl %ebx # %ebx = ps_strings
popl %edx # %edx = cleanup
popl %ecx # %ecx = obj_main
jmp *%eax
.align 4
.globl _rtld_bind_start
.hidden _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start: # (obj, reloff)
pushf # save registers
pushl %eax
pushl %ecx
pushl %edx
pushl 20(%esp) # Copy of reloff
pushl 20(%esp) # Copy of obj
call _rtld_bind # Call the binder
addl $8,%esp # pop binder args
movl %eax,20(%esp) # Store function to be called in obj
popl %edx
popl %ecx
popl %eax
popf
leal 4(%esp),%esp # Discard reloff, do not change eflags
ret
|
0xffea/MINIX3
| 3,458
|
libexec/ld.elf_so/arch/sh3/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.7 2008/04/28 20:23:03 martin Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Marcus Comstedt.
*
* 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>
.text
.align 2
.globl .rtld_start
.type .rtld_start,@function
.rtld_start:
mova 2f,r0
mov.l @r0,r2
add r0,r2 /* GOT */
mov.l @(4,r0),r4 /* _DYNAMIC@GOTOFF */
add r2,r4 /* _DYNAMIC */
mov.l @(12,r0),r1 /* _rtld_relocate_nonplt_self offset */
mov.l @(8,r0),r0 /* _DYNAMIC@GOT */
mov r4,r5
mov.l @(r0,r2),r0 /* where linker thinks _DYNAMIC is */
sub r0,r5 /* compute relocation base */
bsrf r1 /* _rtld_relocate_nonplt_self(dynp, relocbase) */
mov.l r5,@-r15 /* save relocbase */
4:
mov.l @r15+,r5 /* restore relocbase */
add #-8,r15 /* room for values returned by _rtld */
mov r15,r4
mov.l 1f,r0
bsrf r0 /* _rtld(sp, relocbase) */
mov.l r9,@-r15 /* save ps_strings */
3:
mov.l @r15+,r9 /* restore ps_strings */
mov.l @r15+,r7 /* from _rtld: exit procedure */
mov.l @r15+,r8 /* from _rtld: main object */
mov.l @r15,r4 /* restore argc */
mov r15,r5 /* restore argv */
add #4,r5
mov r4,r6 /* restore envp */
shll2 r6
add r15,r6
jmp @r0 /* entry point returned by _rtld */
add #8,r6
.align 2
1: .long _rtld-3b
2: .long _GLOBAL_OFFSET_TABLE_
.long _DYNAMIC@GOTOFF
.long _DYNAMIC@GOT
.long _rtld_relocate_nonplt_self-4b
.size .rtld_start,.-.rtld_start
.align 2
.globl _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start: /* r0 = obj, r1 = reloff */
mov.l r2,@-r15 /* save registers */
mov.l r3,@-r15
mov.l r4,@-r15
mov.l r5,@-r15
mov.l r6,@-r15
mov.l r7,@-r15
sts.l mach,@-r15
sts.l macl,@-r15
sts.l pr,@-r15
mov r0,r4 /* copy of obj */
mov.l 2f,r0
bsrf r0 /* call the binder */
mov r1,r5 /* copy of reloff */
4:
lds.l @r15+,pr /* restore registers */
lds.l @r15+,macl
lds.l @r15+,mach
mov.l @r15+,r7
mov.l @r15+,r6
mov.l @r15+,r5
mov.l @r15+,r4
mov.l @r15+,r3
jmp @r0
mov.l @r15+,r2
.align 2
2: .long _rtld_bind-4b
.size _rtld_bind_start,.-_rtld_bind_start
.end
|
0xffea/MINIX3
| 7,157
|
libexec/ld.elf_so/arch/hppa/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.9 2010/09/30 19:32:40 skrll Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Fredette.
*
* 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>
#include <machine/frame.h>
.import _GLOBAL_OFFSET_TABLE_
ENTRY($rtld_start,HPPA_FRAME_SIZE)
/* Start stack calling convention. */
copy %r3, %r1
copy %sp, %r3
stw,ma %r1, HPPA_FRAME_SIZE(%sp)
/*
* Save our single argument, the ps_strings pointer. We'll need this
* twice later: once to call _rtld, and again to transfer to the
* program's entry point.
*/
stw %arg0, HPPA_FRAME_ARG(0)(%r3)
/*
* We can't move to C until we relocate at least the
* Global Offset Table. Even finding the GOT is tricky
* without inadvertently causing the linker to make
* relocations for this part of the text segment.
*/
bl L$lpc1, %r19
depi 0, 31, 2, %r19
L$lpc1: addil L'_DYNAMIC - ($PIC_pcrel$0 - 8), %r19
ldo R'_DYNAMIC - ($PIC_pcrel$0 - 12)(%r1),%arg0
/*
* Load the absolute address of the beginning of the GOT into %r19, the
* shared library linkage table register, leaving it ready-to-use by
* the dynamic linker C code.
*/
addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 16), %r19
ldo R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 20)(%r1),%r19
/*
* The linker sets the first entry in the GOT to the unrelocated
* address of _DYNAMIC. Subtract this from the absolute address of
* _DYNAMIC to get our relocbase.
*/
ldw 0(%r19), %arg1
sub %arg0, %arg1, %arg1 ; %arg1 = relocbase
bl _rtld_relocate_nonplt_self, %rp
copy %arg1, %r4 ; save for later
/*
* Recover the ps_strings pointer, and take out the
* ps_argvstr member.
*/
ldw HPPA_FRAME_ARG(0)(%r3), %arg0 ; ps_strings
ldw 0(%arg0), %arg0 ; ps_argvstr member first in struct
/*
* ps_argvstr - 4 would get us a pointer to argc, comparable to the
* initial stack pointer on architectures where the stack grows down.
* Subtracting an additional eight creates the storage for obj and
* cleanup that _rtld needs.
*/
ldo -12(%arg0), %arg0
stw %arg0, HPPA_FRAME_ARG(1)(%r3)
/* Call _rtld, copying relocbase into arg1. */
bl _rtld, %rp
copy %r4, %arg1 ; %arg1 = relocbase
/* Prepare the arguments for the entry point. */
ldw HPPA_FRAME_ARG(1)(%r3), %r1
ldw HPPA_FRAME_ARG(0)(%r3), %arg0 ; ps_strings
ldw 0(%r1), %arg1 ; cleanup
ldw 4(%r1), %arg2 ; obj
/* End stack calling convention. */
ldo HPPA_FRAME_SIZE(%r3), %sp
ldw,mb -HPPA_FRAME_SIZE(%sp), %r3
/* Go for it. */
bv %r0(%ret0)
copy %r0, %rp
EXIT($rtld_start)
/*
* This does our setup for an object's GOT. %arg0 is the Obj_Entry * for the
* object, and %arg1 is its GOT pointer.
*/
LEAF_ENTRY(__rtld_setup_hppa_pltgot)
/*
* The second entry of the GOT is reserved for the dynamic linker. We
* put the Obj_Entry * for the object in there.
*/
stw %arg0, 4(%arg1)
/*
* Fill the fixup_func and fixup_ltp members of the PLT stub. This
* stub is inserted by the linker immediately before the GOT. We use
* this stub to enter our binder.
*/
bl L$lpc2, %arg0
depi 0, 31, 2, %arg0
L$lpc2: addil L'_rtld_bind_start - ($PIC_pcrel$0 - 8), %arg0
ldo R'_rtld_bind_start - ($PIC_pcrel$0 - 12)(%r1),%arg0
stw %arg0, -8(%arg1)
bv %r0(%rp)
stw %r19, -4(%arg1)
EXIT(__rtld_hppa_setup_pltgot)
/*
* In order to support lazy binding, this implementation of _rtld_bind_start is
* very closely tied to the shared-library call stub and the PLT stub, both
* inserted by the linker.
*/
/*
* This is a magic branch instruction that is used by GCC's
* __canonicalize_funcptr_for_compare() function to fixup relocations
* in order to do function pointer comparisons.
*/
bl _rtld_bind, %rp
ENTRY(_rtld_bind_start,HPPA_FRAME_SIZE)
/* Start stack calling convention. */
copy %r3, %r1
copy %sp, %r3
stw,ma %r1, HPPA_FRAME_SIZE(%sp)
/*
* We have to save all calling convention registers that are set by the
* caller, because we have to restore them before transferring to the
* bound function. Note that this includes %ret0, %ret1, and %t1.
*
* %ret0 and %ret1 because they can have meaning on entry to a
* function.
*
* %t1 because it's used by libc to pass on errno values to cerror.
*/
stw %rp, HPPA_FRAME_CRP(%r3)
stw %arg0, HPPA_FRAME_ARG(0)(%r3)
stw %arg1, HPPA_FRAME_ARG(1)(%r3)
stw %arg2, HPPA_FRAME_ARG(2)(%r3)
stw %arg3, HPPA_FRAME_ARG(3)(%r3)
/* 0(%r3) is filled with the saved %r3 above */
stw %ret0, 4(%r3)
stw %ret1, 8(%r3)
/*
* The linker PLT stub loads %r20 with (GOT - 8) for the object that
* needs binding done. The second entry of the GOT is reserved for the
* dynamic linker's use, and we previously stashed the object's
* Obj_Entry * there.
*/
ldw 12(%r20), %arg0
/*
* The linker shared-library call stub loads %r19 from the shared
* linkage member of the PLT entry. We previously stashed the reloff
* of the relocation there.
*/
copy %r19, %arg1
/*
* The linker PLT stub loads %r21 with the fixup_ltp word in itself.
* We previously stashed our %r19 value there.
*/
bl _rtld_bind, %rp
copy %r21, %r19
/*
* Our hppa version of _rtld_bind returns to us the address of the PLT
* entry that it fixed up. Load the function address and shared
* linkage for the newly bound function.
*/
ldw 0(%ret0), %r21
ldw 4(%ret0), %r19
/* Restore registers saved above. */
ldw HPPA_FRAME_CRP(%r3), %rp
ldw HPPA_FRAME_ARG(0)(%r3), %arg0
ldw HPPA_FRAME_ARG(1)(%r3), %arg1
ldw HPPA_FRAME_ARG(2)(%r3), %arg2
ldw HPPA_FRAME_ARG(3)(%r3), %arg3
ldw 4(%r3), %ret0
ldw 8(%r3), %ret1
/* End stack calling convention. */
ldo HPPA_FRAME_SIZE(%r3), %sp
ldw,mb -HPPA_FRAME_SIZE(%sp), %r3
/* Transfer to the function. */
bv %r0(%r21)
nop
EXIT(_rtld_bind_start)
|
0xffea/MINIX3
| 3,002
|
libexec/ld.elf_so/arch/sparc/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.16 2008/04/28 20:23:03 martin Exp $ */
/*-
* Copyright (c) 1999, 2002, 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas, Paul Kranenburg, and by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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>
.section ".text"
.align 4
.global _rtld_start
.type _rtld_start,@function
_rtld_start:
mov 0, %fp /* Erect a fence post for ourselves */
mov %g1, %l1 /* save ps_strings */
sub %sp, 32+8, %sp /* room for return args and save area */
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7
call 0f
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
call _DYNAMIC+8
0: add %l7, %o7, %l7 /* real &_GLOBAL_OFFSET_TABLE_ */
ld [%o7+8], %o0 /* load stub call instruction */
ld [%l7], %l0 /* base-relative &_DYNAMIC */
sll %o0, 2, %o0 /* extract PC offset */
add %o0, %o7, %o0 /* real &_DYNAMIC */
sub %o0, %l0, %l0 /* relocbase */
call _rtld_relocate_nonplt_self
mov %l0, %o1 /* relocbase */
mov %l0, %o1 /* relocbase */
call _rtld
add %sp, 96, %o0 /* &argc - 8 */
ld [%sp + 96], %g3 /* arg: cleanup */
ld [%sp + 96 + 4], %g2 /* arg: obj */
add %sp, 32+8, %sp /* restore stack pointer */
jmp %o0
mov %l1, %g1 /* restore ps_strings */
.section ".text"
.align 4
.global _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start: # (obj, reloff)
ld [%o7 + 8], %o0 /* obj id is in second PLT slot */
srl %g1, 10, %o1 /* offset is in high 22 bits */
call _rtld_bind /* Call _rtld_bind(obj, offset) */
sub %o1, 12*4, %o1 /* first 4 `pltrel' entries missing! */
jmp %o0 /* return value == function address */
restore
|
0xffea/MINIX3
| 3,212
|
libexec/ld.elf_so/arch/vax/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.16 2003/03/02 22:03:40 mycroft Exp $ */
/*
* Copyright 1996 Matt Thomas <matt@3am-software.com>
* Portions copyright 2002, 2003 Charles M. Hannum <root@ihack.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
/* R9 contains the address of PS_STRINGS and since its caller saved,
* we can just use it. R6 has a backup copy of the stack pointer which
* we can use as well.
*/
ENTRY(_rtld_start, 0)
/* Allocate space on the stack for the cleanup and obj_main
* entries that _rtld() will provide for us.
*/
clrl %fp
subl2 $8,%sp
movab _DYNAMIC,%r0
subl3 _GLOBAL_OFFSET_TABLE_,%r0,%r10
pushl %r10 /* relocbase */
pushl %r0 /* &_DYNAMIC */
calls $2,_rtld_relocate_nonplt_self
pushl %r10 /* relocbase */
pushal 4(%sp) /* sp */
calls $2,_rtld /* entry = _rtld(sp, relocbase) */
movq (%sp)+,%r7 /* grab cleanup and obj_main into %r7/%r8 */
jmp 2(%r0) /* jump to entry point + 2 */
/*
* Lazy binding entry point, called via PLT.
*
* Note: Some functions rely on there not being an additional call frame;
* hence the `optimization' to avoid the callg opportunistically.
*/
ALTENTRY(_rtld_bind_start)
pushr $0x3f /* save R0-R5 */
movq 24(%sp),%r0 /* get addresses of plt.got & reloc index */
pushl (%r1) /* push relocation index */
pushl %r0 /* push address of obj entry */
calls $2,_rtld_bind
movl %r0,28(%sp) /* save return address onto stack */
bicw3 6(%fp),(%r0),%r0/* does the entry mask save any additional regs */
popr $0x3f /* restore R0-R5 (cond flags not modified) */
bneq 4f /* yes? do it the hard way */
addl2 $4,%sp /* no? skip past plt.got on stack */
addl2 $2,(%sp) /* skip past the mask */
rsb /* and jump to it */
4: addl2 $4,%sp
callg (%ap),*(%sp)+ /* return value from _rtld_bind() == actual */
ret
|
0xffea/MINIX3
| 5,684
|
libexec/ld.elf_so/arch/sparc64/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.17 2008/04/28 20:23:04 martin Exp $ */
/*-
* Copyright (c) 2000 Eduardo Horvath.
* Copyright (c) 1999, 2002, 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas, Paul Kranenburg and by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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>
#define _LOCORE
#include <machine/frame.h>
/*
* ELF:
* On startup the stack should contain 16 extended word register save area,
* followed by the arg count, etc.
*
* _rtld() expects the stack pointer to point to two longwords for argument
* return followed by argc, etc. We need to create a pointer to
* &argc + 16 and pass that in. The return args will be in those locations.
*
* NB: We are violating the ELF spec by passing a pointer to the ps strings in
* %g1 instead of a termination routine.
*/
.register %g2,#scratch
.register %g3,#scratch
/* Offset of ARGC from bottom of stack */
#define ARGC 176
.section ".text"
.align 4
.global _rtld_start
.type _rtld_start,@function
_rtld_start:
mov 0, %fp /* Erect a fence post for ourselves */
mov %g1, %l1 /* save ps_strings */
sub %sp, 48+16, %sp /* Make room for return args */
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7
call 0f
add %l7, %lo(_GLOBAL_OFFSET_TABLE_+4), %l7
call _DYNAMIC+8
0: add %l7, %o7, %l7 /* real &_GLOBAL_OFFSET_TABLE_ */
ld [%o7+8], %o0 /* load stub call instruction */
ldx [%l7], %l0 /* base-relative &_DYNAMIC */
sll %o0, 2, %o0 /* extract PC offset */
sra %o0, 0, %o0 /* sign-extend */
add %o0, %o7, %o0 /* real &_DYNAMIC */
sub %o0, %l0, %l0 /* relocbase */
call _rtld_relocate_nonplt_self
mov %l0, %o1 /* relocbase */
mov %l0, %o1 /* relocbase */
call _rtld
add %sp, BIAS + ARGC, %o0 /* &argc - 16 */
ldx [%sp + BIAS + ARGC], %g3 /* arg: cleanup */
ldx [%sp + BIAS + ARGC + 8], %g2 /* arg: obj */
add %sp, 48+16, %sp /* restore stack pointer */
jmp %o0
mov %l1, %g1 /* restore ps_strings */
/*
* We have two separate entry points to the runtime linker.
* I'm implementing this following the SPARC v9 ABI spec.
*
* _rtld_bind_start_0(y, x) is called from .PLT0, and is used for
* PLT entries above 32768.
*
* _rtld_bind_start_1(y, x) is called from .PLT1, and is used for
* PLT entries below 32768.
*
* The first two entries of PLT2 contain the xword object pointer.
*
* These routines are called with two longword arguments,
* x and y. To calculate the address of the entry,
* _rtld_bind_start_1(y, x) does:
*
* n = x >> 15;
*
* and _rtld_bind_start_0(y, x) does:
*
* i = x - y + 8 - 32768*32;
* n = 32768 + (i/5120)*160 + (i%5120)/24;
*
* Neither routine needs to issue a save since it's already been
* done in the PLT entry.
*/
.section ".text"
.align 4
.global _rtld_bind_start_0
.type _rtld_bind_start_0,@function
_rtld_bind_start_0: # (y, x)
/* %o0 = obj->pltgot[6] */
/* %o1 = plt[4] */
/* %o1 - %o0 + 8 == offset of plt[] from obj->pltgot[] */
/* -32768*32 to get offset from beginning of upper PLT section */
sethi %hi(32768*32-8), %l1
sub %o1, %o0, %l0 /* i = x - y */
or %l1, %lo(32768*32-8), %l1
sub %l0, %l1, %l0 /* i = x - y + 8 - 32768*32 */
ldx [%o0 + (10*4)], %o0 /* Load object pointer from PLT2 */
sethi %hi(5120), %l1
sdivx %l0, %l1, %l1 /* Calculate i/5120 */
sllx %l1, 2, %l2
add %l2, %l1, %l2
sllx %l2, 10, %l2
sub %l0, %l2, %l2 /* And i%5120 */
/* Let the division churn for a bit. */
sdivx %l2, 24, %l4 /* (i%5120)/24 */
/* 160 is (32 * 5) or (32 * (4 + 1)) */
sllx %l1, 2, %l3 /* 4 * (i/5120) */
add %l1, %l3, %l3 /* 5 * (i/5120) */
sllx %l3, 5, %l3 /* 32 * 5 * (i/5120) */
sethi %hi(32768), %l6
add %l3, %l4, %l5 /* %l5 = (i/5120)*160 + (i%5120)/24; */
call _rtld_bind /* Call _rtld_bind(obj, offset) */
add %l5, %l6, %o1 /* %o1 = 32768 + ... */
jmp %o0 /* return value == function address */
restore /* Dump our stack frame */
.section ".text"
.align 4
.global _rtld_bind_start_1
.type _rtld_bind_start_1,@function
_rtld_bind_start_1: # (y, x)
ldx [%o0 + (2*4)], %o0 /* Load object pointer from PLT2 */
call _rtld_bind /* Call _rtld_bind(obj, offset) */
srax %o1, 15, %o1 /* %o1 is the index to our PLT slot */
jmp %o0 /* return value == function address */
restore /* Dump our stack frame */
|
0xffea/MINIX3
| 3,217
|
libexec/ld.elf_so/arch/arm/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.10 2009/11/11 14:15:41 skrll Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas and by Charles M. Hannum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 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: rtld_start.S,v 1.10 2009/11/11 14:15:41 skrll Exp $")
.text
.align 0
.globl _rtld_start
.type _rtld_start,%function
_rtld_start:
sub sp, sp, #8 /* make room for obj_main & exit proc */
mov r4, r0 /* save ps_strings */
ldr sl, .L2
ldr r5, .L2+4
ldr r0, .L2+8
.L1:
add sl, pc, sl
ldr r5, [sl, r5]
ldr r0, [sl, r0]
sub r1, sl, r5 /* relocbase */
add r0, r1, r0 /* &_DYNAMIC */
bl _rtld_relocate_nonplt_self
sub r1, sl, r5 /* relocbase */
mov r0, sp /* sp */
bl _rtld /* call the shared loader */
mov r3, r0 /* save entry point */
ldr r2, [sp, #0] /* r2 = cleanup */
ldr r1, [sp, #4] /* r1 = obj_main */
add sp, sp, #8 /* restore stack */
mov r0, r4 /* restore ps_strings */
#ifdef _ARM_ARCH_4T
bx r3 /* jump to the entry point */
#else
mov pc, r3 /* jump to the entry point */
#endif
.L2:
.word _GLOBAL_OFFSET_TABLE_ - (.L1+8)
.word _GLOBAL_OFFSET_TABLE_(GOT)
.word _DYNAMIC(GOT)
.align 0
.globl _rtld_bind_start
.type _rtld_bind_start,%function
/*
* stack[0] = RA
* ip = &GOT[n+3]
* lr = &GOT[2]
*/
_rtld_bind_start:
stmdb sp!,{r0-r4,sl,fp}
sub r1, ip, lr /* r1 = 4 * (n + 1) */
sub r1, r1, #4 /* r1 = 4 * n */
add r1, r1, r1 /* r1 = 8 * n */
ldr r0, [lr, #-4] /* get obj ptr from GOT[1] */
mov r4, ip /* save GOT location */
bl _rtld_bind /* Call the binder */
str r0, [r4] /* save address in GOT */
mov ip, r0 /* save new address */
ldmia sp!,{r0-r4,sl,fp,lr} /* restore the stack */
#ifdef _ARM_ARCH_4T
bx ip /* jump to the new address */
#else
mov pc, ip /* jump to the new address */
#endif
|
0xffea/MINIX3
| 3,156
|
libexec/ld.elf_so/arch/x86_64/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.8 2010/12/05 00:56:07 joerg Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Frank van der Linden for Wasabi Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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>
.text
.align 16
.globl .rtld_start
.hidden .rtld_start
.type .rtld_start,@function
.rtld_start:
subq $16,%rsp # make room of obj_main and exit proc
movq %rsp,%r12 # stack pointer arg to _rtld
pushq %rbx # save ps_strings
leaq _GLOBAL_OFFSET_TABLE_(%rip),%rax
leaq _DYNAMIC(%rip),%rdi # &_DYNAMIC
movq %rdi,%rbx
subq (%rax),%rbx # relocbase
movq %rbx,%rsi
call _rtld_relocate_nonplt_self
movq %r12,%rdi
movq %rbx,%rsi
call _rtld # _rtld(sp, relocbase)
popq %rbx # %rbx = ps_strings
popq %rdx # %rdx = cleanup
popq %rcx # %rcx = obj_main
jmp *%rax
.align 4
.globl _rtld_bind_start
.hidden _rtld_bind_start
.type _rtld_bind_start,@function
_rtld_bind_start: # (obj, reloff)
# This function is called with a misaligned stack from the PLT
# due to the additional argument pushed.
# At this point %rsp % 16 == 8.
pushfq # save caller-saved registers
pushq %rax
pushq %rcx
pushq %rdx
pushq %rsi
pushq %rdi
pushq %r8
pushq %r9
pushq %r10
pushq %r11
movq 80(%rsp),%rdi
movq 88(%rsp),%rsi
call _rtld_bind # call the binder
movq %rax,88(%rsp) # store function in obj
popq %r11
popq %r10
popq %r9
popq %r8
popq %rdi
popq %rsi
popq %rdx
popq %rcx
popq %rax
popfq
leaq 8(%rsp),%rsp
ret
|
0xffea/MINIX3
| 5,398
|
libexec/ld.elf_so/arch/alpha/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.16 2004/02/18 23:04:49 enami Exp $ */
/*
* Copyright 1996 Matt Thomas <matt@3am-software.com>
* Portions copyright 2002 Charles M. Hannum <root@ihack.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
/*
* Note: we can call ourselves LEAF even though we use callee-saved
* registers because we're the root of the call graph.
*/
LEAF_NOPROFILE(_rtld_start, 0)
.set noreorder
br pv, 1f
1: LDGP(pv)
/*
* Relocate ourself.
*/
br s2, 2f /* get our PC */
2: ldiq s3, 2b /* get where the linker thought we were */
subq s2, s3, a1 /* relocbase */
lda t5, _DYNAMIC
addq a1, t5, a0 /* &_DYNAMIC */
/* Squirrel away ps_strings. */
mov a3, s0
bsr ra, _rtld_relocate_nonplt_self
LDGP(ra)
/*
* Allocate space on the stack for the cleanup and obj_main
* entries that _rtld() will provide for us.
*/
lda sp, -16(sp)
subq s2, s3, a1 /* relocbase */
mov sp, a0 /* sp */
CALL(_rtld) /* v0 = _rtld(sp, relocbase); */
ldq a1, 0(sp) /* cleanup */
ldq a2, 8(sp) /* obj_main */
lda sp, 16(sp) /* pop stack */
mov sp, a0 /* stack pointer */
mov s0, a3 /* ps_strings */
mov v0, pv /* set up PV for entry point */
jsr ra, (v0), 0 /* (*_start)(sp, cleanup, obj, ps_strings); */
ldgp gp, 0(ra)
CALL(exit)
halt
END(_rtld_start)
#define RTLD_BIND_START_PROLOGUE \
/* at_reg already used by PLT code. */ \
.set noat ; \
\
/* \
* Allocate stack frame and preserve all registers that the \
* caller would have normally saved themselves. \
*/ \
lda sp, -168(sp) ; \
stq ra, 0(sp) ; \
stq v0, 8(sp) ; \
stq t0, 16(sp) ; \
stq t1, 24(sp) ; \
stq t2, 32(sp) ; \
stq t3, 40(sp) ; \
stq t4, 48(sp) ; \
stq t5, 56(sp) ; \
stq t6, 64(sp) ; \
stq t7, 72(sp) ; \
stq a0, 80(sp) ; \
stq a1, 88(sp) ; \
stq a2, 96(sp) ; \
stq a3, 104(sp) ; \
stq a4, 112(sp) ; \
stq a5, 120(sp) ; \
stq t8, 128(sp) ; \
stq t9, 136(sp) ; \
stq t10, 144(sp) ; \
stq t11, 152(sp) ; \
stq gp, 160(sp) ; \
\
/* \
* Load our global pointer. Note, can't use pv, since it is \
* already used by the PLT code. \
*/ \
br t0, 1f ; \
1: LDGP(t0)
#define RTLD_BIND_START_EPILOGUE \
/* Move the destination address into position. */ \
mov v0, pv ; \
\
/* Restore program registers. */ \
ldq ra, 0(sp) ; \
ldq v0, 8(sp) ; \
ldq t0, 16(sp) ; \
ldq t1, 24(sp) ; \
ldq t2, 32(sp) ; \
ldq t3, 40(sp) ; \
ldq t4, 48(sp) ; \
ldq t5, 56(sp) ; \
ldq t6, 64(sp) ; \
ldq t7, 72(sp) ; \
ldq a0, 80(sp) ; \
ldq a1, 88(sp) ; \
ldq a2, 96(sp) ; \
ldq a3, 104(sp) ; \
ldq a4, 112(sp) ; \
ldq a5, 120(sp) ; \
ldq t8, 128(sp) ; \
ldq t9, 136(sp) ; \
ldq t10, 144(sp) ; \
ldq t11, 152(sp) ; \
ldq gp, 160(sp) ; \
/* XXX LDGP? */ \
\
/* \
* We've patched the PLT; sync the I-stream. \
*/ \
imb ; \
\
/* Pop the stack frame and turn control to the destination. */ \
lda sp, 168(sp) ; \
jmp zero, (pv)
/*
* Lazy binding entry point, called via PLT.
*/
NESTED_NOPROFILE(_rtld_bind_start, 0, 168, ra, 0, 0)
RTLD_BIND_START_PROLOGUE
/* Set up the arguments for _rtld_bind. */
subq at_reg, pv, a1 /* calculate offset of reloc entry */
ldq a0, 8(pv) /* object structure */
subq a1, 20, a1 /* = (at - pv - 20) / 12 * 24 */
addq a1, a1, a1
CALL(_rtld_bind)
RTLD_BIND_START_EPILOGUE
END(_rtld_bind_start)
/*
* Lazy binding entry point, called via PLT. This version is for the
* old PLT entry format.
*/
NESTED_NOPROFILE(_rtld_bind_start_old, 0, 168, ra, 0, 0)
RTLD_BIND_START_PROLOGUE
/* Set up the arguments for _rtld_bind. */
ldq a0, 8(pv) /* object structure */
mov at_reg, a1 /* offset of reloc entry */
CALL(_rtld_bind)
RTLD_BIND_START_EPILOGUE
END(_rtld_bind_start_old)
|
0xffea/MINIX3
| 4,566
|
libexec/ld.elf_so/arch/mips/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.10 2009/12/14 00:41:19 matt Exp $ */
/*
* Copyright 1997 Michael L. Hitch <mhitch@montana.edu>
* Portions copyright 2002 Charles M. Hannum <root@ihack.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <mips/asm.h>
.globl _C_LABEL(_rtld_relocate_nonplt_self)
.globl _C_LABEL(_rtld)
#define PTR_SIZE (1<<PTR_SCALESHIFT)
LEAF(rtld_start)
.frame sp, 4*PTR_SIZE, ra
.mask 0x10090000,-PTR_SIZE
.set noreorder
SETUP_GP
PTR_SUBU sp, 4*PTR_SIZE # adjust stack pointer
SETUP_GP64(s4, rtld_start)
SAVE_GP(0)
# -> 1*PTR_SIZE(sp) for atexit
# -> 2*PTR_SIZE(sp) for obj_main
move s0, a0 # save stack pointer from a0
move s3, a3 # save ps_strings pointer
PTR_LA a1, 1f
bal 1f
PTR_LA t0, _C_LABEL(_rtld_relocate_nonplt_self)
1: PTR_SUBU a1, ra, a1 # relocbase
move s2, a1 # save for _rtld
PTR_LA a0, _DYNAMIC
PTR_ADDU t9, a1, t0
jalr t9 # _rtld_relocate_nonplt_self(dynp, relocabase)
PTR_ADDU a0, a1, a0 # &_DYNAMIC
move a1, s2 # relocbase
PTR_ADDU a0, sp, 2*PTR_SIZE # sp
jal _C_LABEL(_rtld) # v0 = _rtld(sp, relocbase)
nop
PTR_L a1, 2*PTR_SIZE(sp) # our atexit function
PTR_L a2, 3*PTR_SIZE(sp) # obj_main entry
PTR_ADDU sp, 4*PTR_SIZE # readjust stack
move a0, s0 # stack pointer
move t9, v0
jr t9 # _start(sp, cleanup, obj);
move a3, s3 # restore ps_strings
END(rtld_start)
#define XCALLFRAME_SIZ (12*SZREG)
#define XCALLFRAME_RA (10*SZREG)
#define XCALLFRAME_GP (9*SZREG)
#define XCALLFRAME_S0 (8*SZREG)
#define XCALLFRAME_A3 (7*SZREG)
#define XCALLFRAME_A2 (6*SZREG)
#define XCALLFRAME_A1 (5*SZREG)
#define XCALLFRAME_A0 (4*SZREG)
#if defined(__mips_n32) || defined(__mips_n64)
#define XCALLFRAME_A7 (3*SZREG)
#define XCALLFRAME_A6 (2*SZREG)
#define XCALLFRAME_A5 (1*SZREG)
#define XCALLFRAME_A4 (0*SZREG)
#endif
.globl _rtld_bind_start
.ent _rtld_bind_start
_rtld_bind_start:
.frame sp, XCALLFRAME_SIZ, $15
move v1, gp # save old GP
#if defined(__mips_o32) || defined(__mips_o64)
PTR_ADDU t9, 8 # modify T9 to point at .cpload
#endif
SETUP_GP
PTR_SUBU sp, XCALLFRAME_SIZ # save arguments and sp value in stack
SETUP_GP64(XCALLFRAME_GP, _rtld_bind_start)
SAVE_GP(XCALLFRAME_GP)
#if defined(__mips_n32) || defined(__mips_n64)
REG_S a4, XCALLFRAME_A4(sp)
REG_S a5, XCALLFRAME_A5(sp)
REG_S a6, XCALLFRAME_A6(sp)
REG_S a7, XCALLFRAME_A7(sp)
#endif
REG_S a0, XCALLFRAME_A0(sp)
REG_S a1, XCALLFRAME_A1(sp)
REG_S a2, XCALLFRAME_A2(sp)
REG_S a3, XCALLFRAME_A3(sp)
REG_S $15, XCALLFRAME_RA(sp) # ra is in t7/t3
REG_S s0, XCALLFRAME_S0(sp)
move s0, sp
move a0, t8 # symbol index
move a1, $15 # old RA
move a2, v1 # old GP
move a3, ra # current RA
jal _C_LABEL(_rtld_bind)
nop
move sp, s0
REG_L ra, XCALLFRAME_RA(sp)
REG_L s0, XCALLFRAME_S0(sp)
REG_L a0, XCALLFRAME_A0(sp)
REG_L a1, XCALLFRAME_A1(sp)
REG_L a2, XCALLFRAME_A2(sp)
REG_L a3, XCALLFRAME_A3(sp)
#if defined(__mips_n32) || defined(__mips_n64)
REG_L a4, XCALLFRAME_A4(sp)
REG_L a5, XCALLFRAME_A5(sp)
REG_L a6, XCALLFRAME_A6(sp)
REG_L a7, XCALLFRAME_A7(sp)
#endif
RESTORE_GP64
PTR_ADDU sp, XCALLFRAME_SIZ
move t9, v0
jr t9
nop
END(_rtld_bind_start)
|
0xffea/MINIX3
| 3,963
|
libexec/ld.elf_so/arch/powerpc/rtld_start.S
|
/* $NetBSD: rtld_start.S,v 1.14 2011/01/16 01:22:29 matt Exp $ */
/*-
* Copyright (C) 1998 Tsubai Masanari
* Portions copyright 2002 Charles M. Hannum <root@ihack.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
.globl _rtld_start
.globl _rtld
.text
_rtld_start:
stwu %r1,-48(%r1)
stw %r3,12(%r1) # argc
stw %r4,16(%r1) # argv
stw %r5,20(%r1) # envp
/* stw %r6,24(%r1) # obj (always 0) */
/* stw %r7,28(%r1) # cleanup (always 0) */
stw %r8,32(%r1) # ps_strings
bcl 20,31,1f
1: mflr %r30
mr %r3,%r30 # save for _DYNAMIC
addis %r30,%r30,_GLOBAL_OFFSET_TABLE_-1b@ha
addi %r30,%r30,_GLOBAL_OFFSET_TABLE_-1b@l
addis %r3,%r3,_DYNAMIC-1b@ha # get _DYNAMIC actual address
addi %r3,%r3,_DYNAMIC-1b@l
lwz %r28,0(%r30) # get base-relative &_DYNAMIC
sub %r28,%r3,%r28 # r28 = relocbase
mr %r4,%r28 # r4 = relocbase
bl _rtld_relocate_nonplt_self
lwz %r3,16(%r1)
addi %r3,%r3,-12 # sp = &argv[-3] /* XXX */
mr %r4,%r28 # r4 = relocbase
bl _rtld # _start = _rtld(sp, relocbase)
mtlr %r3
lwz %r3,12(%r1) # argc
lwz %r4,16(%r1) # argv
lwz %r5,20(%r1) # envp
lwz %r6,-8(%r4) # obj = sp[1] (== argv[-2])
lwz %r7,-12(%r4) # cleanup = sp[0] (== argv[-3])
lwz %r8,32(%r1) # ps_strings
addi %r1,%r1,48
blrl # _start(argc, argv, envp, obj, cleanup, ps_strings)
li %r0,1 # _exit()
sc
END(_rtld_start)
.globl _rtld_bind
/*
* secure-plt expects %r11 to be the offset to the rela entry.
* bss-plt expects %r11 to be index of the rela entry.
* So for bss-plt, we multiply the index by 12 to get the offset.
*/
ENTRY_NOPROFILE(_rtld_bind_bssplt_start)
slwi %r11,%r11,2
add %r0,%r11,%r11
add %r11,%r11,%r0
ENTRY_NOPROFILE(_rtld_bind_secureplt_start)
stwu %r1,-160(%r1)
stw %r0,20(%r1)
mflr %r0
stw %r0,16(%r1) # save lr
mfcr %r0
stw %r0,12(%r1) # save cr
stmw %r3,24(%r1) # save r3-r31
mr %r3,%r12 # obj
mr %r4,%r11 # reloff
bl _rtld_bind # _rtld_bind(obj, reloff)
mtctr %r3
lmw %r3,24(%r1) # load r3-r31
lwz %r0,12(%r1) # restore cr
mtcr %r0
lwz %r0,16(%r1) # restore lr
mtlr %r0
lwz %r0,20(%r1)
addi %r1,%r1,160
bctr
END(_rtld_bind_start)
.globl _rtld_powerpc_pltcall
.globl _rtld_powerpc_pltresolve
_rtld_powerpc_pltcall:
slwi %r11,%r11,2
addis %r11,%r11,0 # addis 11,11,jmptab@ha
lwz %r11,0(%r11) # lwz 11,jmptab@l(11)
mtctr %r11
bctr
_rtld_powerpc_pltresolve:
lis %r12,0 # lis 12,_rtld_bind_bssplt_start@ha
addi %r12,%r12,0 # addi 12,12,_rtld_bind_bssplt_start@l
mtctr %r12
lis %r12,0 # lis 12,obj@ha
addi %r12,%r12,0 # addi 12,12,obj@l
bctr
|
0xffea/MINIX3
| 2,126
|
common/lib/libc/arch/m68k/net/htonl.S
|
/* $NetBSD: htonl.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)htonl.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: htonl.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* netorder = htonl(hostorder) */
ENTRY(htonl)
movl %sp@(4),%d0
rts
|
0xffea/MINIX3
| 2,126
|
common/lib/libc/arch/m68k/net/ntohl.S
|
/* $NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)ntohl.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* hostorder = ntohl(netorder) */
ENTRY(ntohl)
movl %sp@(4),%d0
rts
|
0xffea/MINIX3
| 2,136
|
common/lib/libc/arch/m68k/net/htons.S
|
/* $NetBSD: htons.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)htons.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: htons.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* hostorder = htons(netorder) */
ENTRY(htons)
clrl %d0
movw %sp@(6),%d0
rts
|
0xffea/MINIX3
| 2,136
|
common/lib/libc/arch/m68k/net/ntohs.S
|
/* $NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)ntohs.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* hostorder = ntohs(netorder) */
ENTRY(ntohs)
clrl %d0
movw %sp@(6),%d0
rts
|
0xffea/MINIX3
| 2,427
|
common/lib/libc/arch/m68k/gen/umodsi3.S
|
/* $NetBSD: umodsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)umodsi3.s 5.1 (Berkeley) 6/7/90")(
#else
RCSID("$NetBSD: umodsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* unsigned % unsigned */
ENTRY(__umodsi3)
#ifndef __mc68010__
movel %sp@(4),%d1
divull %sp@(8),%d0:%d1
rts
#else
| NB: this requires that __udivsi3 preserve the %a0
| register, and that it returns the modulus in %d1:
movel %sp@+, %a0 | pop the return address
jsr _C_LABEL(__udivsi3)
movel %d1, %d0 | move the modulus into %d0
jmp %a0@ | return
#endif /* __mc68010__ */
|
0xffea/MINIX3
| 1,821
|
common/lib/libc/arch/m68k/gen/bswap32.S
|
/* $NetBSD: bswap32.S,v 1.2 2007/09/19 20:31:34 he Exp $ */
/*
* Copyright (C) 1996 Scott Reynolds. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(_KERNEL) || defined(_STANDALONE)
_ENTRY(_C_LABEL(bswap32))
#else /* defined(_KERNEL) || defined(_STANDALONE) */
_ENTRY(_C_LABEL(__bswap32))
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
movl %sp@(4),%d0
rolw #8,%d0
swap %d0
rolw #8,%d0
rts
|
0xffea/MINIX3
| 4,478
|
common/lib/libc/arch/m68k/gen/udivsi3.S
|
/* $NetBSD: udivsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)udivsi3.s 5.1 (Berkeley) 6/7/90")
#else
RCSID("$NetBSD: udivsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* unsigned / unsigned */
ENTRY(__udivsi3)
#ifndef __mc68010__
movel %sp@(4),%d0
divul %sp@(8),%d0
rts
#else
movel %d2, %sp@- | save %d2
movel %sp@(12), %d0 | load divisor
movel %sp@(8), %d1 | load dividend
| first, we divide the divisor and dividend by two until
| the divisor fits into 16 bits:
1: cmpil #0x10000, %d0
bcs 2f
lsrl #1, %d0
lsrl #1, %d1
bra 1b
2:
| now we can do the divide. to avoid overflow, we have to
| do the divide in two parts, high and low, and add the
| results together:
movew %d1, %d2 | save low(dividend)
clrw %d1
swap %d1 | %d1 = dividend >> 16
divuw %d0, %d1 | do the high divide
moveal %d1, %a1 | save high divide result
movew %d2, %d1 | concat(remainder, low(dividend))
divuw %d0, %d1 | do the low divide
movel %a1, %d0 | recover high divide result
swap %d0
clrw %d0 | %d0 = finished high divide result
andil #0xffff, %d1 | %d1 = finished low divide result
addl %d1, %d0 | %d0 = quotient guess
| the quotient we have so far is only a guess. the divide we
| did above was really the divide of some dividendB by some
| divisorB, where the following hold:
|
| (dividend - divisor) <= dividendB <= dividend
| (divisor / 2) < divisorB <= divisor
|
| so our guess quotient cannot be less than our real desired
| quotient. however, it might be one too big.
|
| to adjust this quotient, we multiply it by the original
| divisor and subtract the result from the original dividend.
| if the result is nonnegative, our guessed quotient was
| correct, and the subtraction result is our remainder.
| if the result is negative, our guessed quotient was one
| too big, and the subtraction result plus the original
| divisor is our remainder.
|
| as in mulsi3, we have to do the multiply in stages to avoid
| overflow:
movel %sp@(12), %d2 | load divisor
swap %d2
movel %d0, %d1
muluw %d2, %d1 | high(divisor) * low(guess)
moveal %d1, %a1 | save high(divisor) * low(guess)
swap %d2
movel %d0, %d1
swap %d1
muluw %d2, %d1 | low(divisor) * high(guess)
addl %a1, %d1
swap %d1
clrw %d1 | %d1 = finished high multiply result
moveal %d2, %a1 | save original divisor
muluw %d0, %d2 | low(guess) * low(divisor)
addl %d1, %d2 | %d2 = guess * divisor
movel %sp@(8), %d1 | load original dividend
subl %d2, %d1 | subtract
bcc 3f
subql #1, %d0 | adjust quotient
addl %a1, %d1 | adjust remainder
3: movel %sp@+, %d2 | restore %d2
rts
#endif /* __mc68010__ */
|
0xffea/MINIX3
| 2,610
|
common/lib/libc/arch/m68k/gen/divsi3.S
|
/* $NetBSD: divsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)divsi3.s 5.1 (Berkeley) 6/7/90")
#else
RCSID("$NetBSD: divsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* int / int */
ENTRY(__divsi3)
#ifndef __mc68010__
movel %sp@(4),%d0
divsl %sp@(8),%d0
rts
#else
| NB: this requires that __udivsi3 preserve %a0:
movel %sp@(4), %d1 | load the dividend
bpl 1f
negl %sp@(4) | store abs(dividend)
1: movel %sp@(8), %d0 | load the divisor
bpl 2f
negl %sp@(8) | store abs(divisor)
2: eorl %d1, %d0
bpl 3f | branch if sgn(divisor) == sgn(dividend)
movel %sp@+, %a0 | pop return address
pea %pc@(Lret) | push our return address
3: jmp _C_LABEL(__udivsi3)
Lret: negl %d0 | negate quotient
jmp %a0@
#endif /* __mc68010__ */
|
0xffea/MINIX3
| 1,690
|
common/lib/libc/arch/m68k/gen/bswap64.S
|
/* $NetBSD: bswap64.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*
* Copyright (C) 1996 Scott Reynolds. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
ENTRY(bswap64)
movl %sp@(4),%d1
movl %sp@(8),%d0
rolw #8,%d1
rolw #8,%d0
swap %d1
swap %d0
rolw #8,%d0
rolw #8,%d1
rts
|
0xffea/MINIX3
| 1,798
|
common/lib/libc/arch/m68k/gen/bswap16.S
|
/* $NetBSD: bswap16.S,v 1.2 2007/09/19 20:31:34 he Exp $ */
/*
* Copyright (C) 1996 Scott Reynolds. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(_KERNEL) || defined(_STANDALONE)
_ENTRY(_C_LABEL(bswap16))
#else /* defined(_KERNEL) || defined(_STANDALONE) */
_ENTRY(_C_LABEL(__bswap16))
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
movl %sp@(4),%d0
rolw #8,%d0
rts
|
0xffea/MINIX3
| 2,666
|
common/lib/libc/arch/m68k/gen/modsi3.S
|
/* $NetBSD: modsi3.S,v 1.3 2006/01/13 16:07:59 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)modsi3.s 5.1 (Berkeley) 6/7/90")
#else
RCSID("$NetBSD: modsi3.S,v 1.3 2006/01/13 16:07:59 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* int % int */
ENTRY(__modsi3)
#ifndef __mc68010__
movel %sp@(4),%d1
divsll %sp@(8),%d0:%d1
rts
#else
| NB: this requires that __udivsi3 preserve %a0 and return
| the modulus in %d1:
movel %sp@+, %a0 | pop return address
movel %sp@(4), %d1 | load the divisor
bpl 1f
negl %sp@(4) | store abs(divisor)
1: movel %sp@, %d0 | load the dividend
pea %pc@(Lret) | push our return address
bpl 2f
negl %sp@(4) | store abs(dividend)
subql #2, %sp@ | adjust return address
2: jmp _C_LABEL(__udivsi3)
negl %d1 | negate modulus
Lret: movl %d1, %d0 | move modulus into %d0
jmp %a0@
#endif /* __mc68010__ */
|
0xffea/MINIX3
| 2,641
|
common/lib/libc/arch/m68k/gen/mulsi3.S
|
/* $NetBSD: mulsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)mulsi3.s 5.1 (Berkeley) 6/7/90")
#else
RCSID("$NetBSD: mulsi3.S,v 1.2 2006/01/05 22:33:34 he Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* int * int */
ENTRY(__mulsi3)
#ifndef __mc68010__
movel %sp@(4),%d0
mulsl %sp@(8),%d0
#else
| NB: this requires that __udivsi3 preserve %a0 and return
| the modulus in %d1:
movew %sp@(6), %d0
movel %d0, %a0 | save B
muluw %sp@(8), %d0 | %d0 holds B * C
movew %sp@(10), %d1
movel %d1, %a1 | save D
muluw %sp@(4), %d1 | %d1 holds A * D
addw %d1, %d0 | %d0 holds (B * C) + (A * D)
swap %d0
clrw %d0 | %d0 holds ((B * C) + (A * D)) << 16
exg %a0, %d0 | restore B
movel %a1, %d1 | restore D
muluw %d1, %d0 | %d0 holds B * D
addl %a0, %d0 | final result
#endif /* __mc68010__ */
rts
|
0xffea/MINIX3
| 2,142
|
common/lib/libc/arch/m68k/atomic/atomic_swap.S
|
/* $NetBSD: atomic_swap.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
ENTRY(_atomic_swap_32)
movl %sp@(4), %a0
1: movl %a0@, %d0
movl %sp@(8), %d1
casl %d0, %d1, %a0@
bne 1b
/* %d0 now contains the old value */
movl %d0, %a0 /* pointers return also in %a0 */
rts
ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
|
0xffea/MINIX3
| 2,509
|
common/lib/libc/arch/m68k/atomic/atomic_and.S
|
/* $NetBSD: atomic_and.S,v 1.6 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
ENTRY(_atomic_and_32)
movl %sp@(4), %a0
movl %sp@(8), %d0
andl %d0, %a0@
rts
ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32)
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32)
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
ATOMIC_OP_ALIAS(atomic_and_ptr,_atomic_and_32)
STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32)
ENTRY(_atomic_and_32_nv)
movl %sp@(4), %a0
1: movl %a0@, %d0
movl %d0, %d1
andl %sp@(8), %d0
casl %d1, %d0, %a0@
bne 1b
rts
ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
ATOMIC_OP_ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv)
|
0xffea/MINIX3
| 2,535
|
common/lib/libc/arch/m68k/atomic/atomic_inc.S
|
/* $NetBSD: atomic_inc.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
ENTRY(_atomic_inc_32)
movl %sp@(4), %a0
addql #1, %a0@
rts
ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32)
ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32)
ENTRY(_atomic_inc_32_nv)
movl %sp@(4), %a0
1: movl %a0@, %d0
movl %d0, %d1
addql #1, %d0
casl %d1, %d0, %a0@
bne 1b
movl %d0, %a0 /* pointers return also in %a0 */
rts
ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv)
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv)
|
0xffea/MINIX3
| 2,535
|
common/lib/libc/arch/m68k/atomic/atomic_dec.S
|
/* $NetBSD: atomic_dec.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
ENTRY(_atomic_dec_32)
movl %sp@(4), %a0
subql #1, %a0@
rts
ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32)
ENTRY(_atomic_dec_32_nv)
movl %sp@(4), %a0
1: movl %a0@, %d0
movl %d0, %d1
subql #1, %d0
casl %d1, %d0, %a0@
bne 1b
movl %d0, %a0 /* pointers return also in %a0 */
rts
ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv)
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv)
|
0xffea/MINIX3
| 2,560
|
common/lib/libc/arch/m68k/atomic/atomic_add.S
|
/* $NetBSD: atomic_add.S,v 1.4 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
.align 2
ENTRY(_atomic_add_32)
movl %sp@(4), %a0
movl %sp@(8), %d0
addl %d0, %a0@
rts
ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32)
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32)
STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32)
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
ENTRY(_atomic_add_32_nv)
movl %sp@(4), %a0
1: movl %a0@, %d0
movl %d0, %d1
addl %sp@(8), %d0
casl %d1, %d0, %a0@
bne 1b
movl %d0, %a0 /* pointers return also in %a0 */
rts
ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
|
0xffea/MINIX3
| 1,928
|
common/lib/libc/arch/m68k/atomic/atomic_cas_68000.S
|
/* $NetBSD: atomic_cas_68000.S,v 1.3 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Steve C. Woodford.
*
* 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/ras.h>
#include "atomic_op_asm.h"
.text
ENTRY(_atomic_cas_up)
.hidden _C_LABEL(_atomic_cas_up)
movl %sp@(4), %a0 /* Fetch ptr */
RAS_START_ASM_HIDDEN(_atomic_cas)
movl %a0@, %d0 /* d0 = *ptr */
cmpl %sp@(8), %d0 /* Same as old? */
jne 1f /* Nope */
movl %sp@(12), %a0@ /* *ptr = new */
RAS_END_ASM_HIDDEN(_atomic_cas)
1: rts
|
0xffea/MINIX3
| 2,524
|
common/lib/libc/arch/m68k/atomic/atomic_cas.S
|
/* $NetBSD: atomic_cas.S,v 1.5 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
ENTRY(_atomic_cas_32)
movl %sp@(4), %a0
movl %sp@(8), %d0
movl %sp@(12), %d1
casl %d0, %d1, %a0@
/* %d0 now contains the old value */
movl %d0, %a0 /* pointers return also in %a0 */
rts
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
|
0xffea/MINIX3
| 2,476
|
common/lib/libc/arch/m68k/atomic/atomic_or.S
|
/* $NetBSD: atomic_or.S,v 1.6 2008/05/25 15:56:11 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
.text
ENTRY(_atomic_or_32)
movl %sp@(4), %a0
movl %sp@(8), %d0
orl %d0, %a0@
rts
ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32)
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32)
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32)
ATOMIC_OP_ALIAS(atomic_or_ptr,_atomic_or_32)
STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32)
ENTRY(_atomic_or_32_nv)
movl %sp@(4), %a0
1: movl %a0@, %d0
movl %d0, %d1
orl %sp@(8), %d0
casl %d1, %d0, %a0@
bne 1b
rts
ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv)
ATOMIC_OP_ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv)
|
0xffea/MINIX3
| 5,386
|
common/lib/libc/arch/m68k/string/bcmp.S
|
/* $NetBSD: bcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by J.T. Conklin.
*
* 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.
*/
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: bcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(bcmp)
movl %sp@(4),%a0 | string 1
movl %sp@(8),%a1 | string 2
movl %sp@(12),%d1 | length
/*
* It isn't worth the overhead of aligning to {long}word boundries
* if the string is too short.
*/
cmpl #8,%d1
jlt Lbcbyte
#ifdef __mc68010__
/*
* The 68010 cannot access a word or long on an odd boundary,
* period. If the source and the destination addresses aren't
* of the same evenness, we're forced to do a bytewise compare.
*/
movl %a0,%d0
addl %a1,%d0
btst #0,%d0
jne Lbcbyte
#endif /* __mc68010__ */
/* word align */
movl %a0,%d0
btst #0,%d0
jeq Lbcalgndw
cmpmb %a0@+,%a1@+
jne Lbcnoteq
subql #1,%d1
Lbcalgndw:
/* long word align */
btst #1,%d0
jeq Lbcalgndl
cmpmw %a0@+,%a1@+
jne Lbcnoteq
subql #2,%d1
Lbcalgndl:
/* compare by 8 longwords */
movl %d1,%d0
lsrl #5,%d0 | cnt = len / 32
jeq Lbclong | if (cnt)
andl #31,%d1 | len %= 32
subql #1,%d0 | set up for dbf
Lbc32loop:
cmpml %a0@+,%a1@+ | compare 8 longwords
jne Lbcnoteq | not equal, return non-zero
cmpml %a0@+,%a1@+
jne Lbcnoteq
cmpml %a0@+,%a1@+
jne Lbcnoteq
cmpml %a0@+,%a1@+
jne Lbcnoteq
cmpml %a0@+,%a1@+
jne Lbcnoteq
cmpml %a0@+,%a1@+
jne Lbcnoteq
cmpml %a0@+,%a1@+
jne Lbcnoteq
cmpml %a0@+,%a1@+
jne Lbcnoteq
dbf %d0,Lbc32loop | till done
clrw %d0
subql #1,%d0
jcc Lbc32loop
Lbclong:
/* compare by longwords */
movl %d1,%d0
lsrl #2,%d0 | cnt = len / 4
jeq Lbcbyte | if (cnt)
subql #1,%d0 | set up for dbf
Lbclloop:
cmpml %a0@+,%a1@+ | compare a longword
jne Lbcnoteq | not equal, return non-zero
dbf %d0,Lbclloop | till done
andl #3,%d1 | len %= 4
jeq Lbcdone
subql #1,%d1 | set up for dbf
Lbcbloop:
cmpmb %a0@+,%a1@+ | compare a byte
jne Lbcnoteq | not equal, return non-zero
Lbcbyte:
dbf %d1,Lbcbloop
Lbcdone:
movql #0,%d0
rts
Lbcnoteq:
movql #1,%d0
rts
|
0xffea/MINIX3
| 2,316
|
common/lib/libc/arch/m68k/string/strcpy.S
|
/* $NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strcpy)
movl %sp@(8),%a0 | a0 = fromaddr
movl %sp@(4),%d0 | return value is toaddr
movl %d0,%a1 | a1 = toaddr
Lscloop:
movb %a0@+,%a1@+ | copy a byte
jne Lscloop | copied non-null, keep going
#ifdef __SVR4_ABI__
moveal %d0,%a0
#endif
rts
|
0xffea/MINIX3
| 2,391
|
common/lib/libc/arch/m68k/string/ffs.S
|
/* $NetBSD: ffs.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#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 $")
#endif
#endif /* LIBC_SCCS and not lint */
/* bit = ffs(value) */
#ifndef __mc68010__
ENTRY(ffs)
movl %sp@(4),%d0
movl %d0,%d1
negl %d0
andl %d0,%d1
movql #32,%d0
bfffo %d1{#0:#32},%d1
subl %d1,%d0
rts
#else /* __mc68010__ */
ENTRY(ffs)
movl %sp@(4),%d0
jeq L2
movql #31,%d1
L1:
lsrl #1,%d0
dbcs %d1,L1
movql #32,%d0
subl %d1,%d0
L2:
rts
#endif /* __mc68010__ */
|
0xffea/MINIX3
| 4,877
|
common/lib/libc/arch/m68k/string/bzero.S
|
/* $NetBSD: bzero.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by J.T. Conklin.
*
* 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.
*/
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)bzero.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: bzero.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(bzero)
movl %d2,%sp@-
movl %sp@(8),%a0 | destination
movl %sp@(12),%d1 | count
movql #0,%d2
/*
* It isn't worth the overhead of aligning to {long}word boundries
* if the string is too short.
*/
cmpl #8,%d1
jlt Lbzbyte
/* word align */
movl %a0,%d0
btst #0,%d0 | if (dst & 1)
jeq Lbzalgndw |
movb %d2,%a0@+ | *(char *)dst++ = 0
subql #1,%d1 | len--
Lbzalgndw:
/* long word align */
btst #1,%d0 | if (dst & 2)
jeq Lbzalgndl |
movw %d2,%a0@+ | *(short *)dst++ = 0
subql #2,%d1 | len -= 2
Lbzalgndl:
/* zero by 8 longwords */
movel %d1,%d0
lsrl #5,%d0 | cnt = len / 32
jeq Lbzlong | if (cnt)
andl #31,%d1 | len %= 32
subql #1,%d0 | set up for dbf
Lbz32loop:
movl %d2,%a0@+ | zero 8 long words
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
dbf %d0,Lbz32loop | till done
clrw %d0
subql #1,%d0
jcc Lbz32loop
Lbzlong:
/* copy by longwords */
movel %d1,%d0
lsrl #2,%d0 | cnt = len / 4
jeq Lbzbyte | if (cnt)
subql #1,%d0 | set up for dbf
Lbzlloop:
movl %d2,%a0@+ | clear longwords
dbf %d0,Lbzlloop | till done
andl #3,%d1 | len %= 4
jeq Lbzdone
subql #1,%d1 | set up for dbf
Lbzbloop:
movb %d2,%a0@+ | zero bytes
Lbzbyte:
dbf %d1,Lbzbloop | till done
Lbzdone:
movl %sp@+,%d2
rts
|
0xffea/MINIX3
| 2,274
|
common/lib/libc/arch/m68k/string/strncmp.S
|
/* $NetBSD: strncmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
* by J.T. Conklin <jtc@NetBSD.org>.
*
* 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>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: strncmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif /* LIBC_SCCS and not lint */
ENTRY(strncmp)
movl %sp@(12),%d0
jeq L4
movl %sp@(4),%a0
movl %sp@(8),%a1
L1: /* unroll by 4 for m680[23]0's */
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
subql #1,%d0
jeq L4
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
subql #1,%d0
jeq L4
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
subql #1,%d0
jeq L4
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
subql #1,%d0
jne L1
L4: rts
L2: subb %a1@,%d1
L3: scs %d0
EXTBL(%d0)
movb %d1,%d0
rts
|
0xffea/MINIX3
| 5,272
|
common/lib/libc/arch/m68k/string/memset.S
|
/* $NetBSD: memset.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by J.T. Conklin.
*
* 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.
*/
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)bzero.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: memset.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(memset)
movl %d2,%sp@-
movl %sp@(8),%a0 | destination
movl %sp@(16),%d1 | count
movb %sp@(15),%d2 | character
/*
* It isn't worth the overhead of aligning to {long}word boundries
* if the string is too short.
*/
cmpl #15,%d1
jlt Lbzbyte
clrl %d0 | replicate byte to fill longword
movb %d2,%d0
movl %d0,%d2
lsll #8,%d0
orl %d0,%d2
lsll #8,%d0
orl %d0,%d2
lsll #8,%d0
orl %d0,%d2
/* word align */
movl %a0,%d0
btst #0,%d0 | if (dst & 1)
jeq Lbzalgndw |
movb %d2,%a0@+ | *(char *)dst++ = X
subql #1,%d1 | len--
addql #1,%d0
Lbzalgndw:
#ifndef __mc68010__
/* long word align */
btst #1,%d0 | if (dst & 2)
jeq Lbzalgndl |
movw %d2,%a0@+ | *(short *)dst++ = X
subql #2,%d1 | len -= 2
Lbzalgndl:
/* set by 8 longwords */
movel %d1,%d0
lsrl #5,%d0 | cnt = len / 32
jeq Lbzlong | if (cnt)
andl #31,%d1 | len %= 32
subql #1,%d0 | set up for dbf
Lbz32loop:
movl %d2,%a0@+ | set 8 long words
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
movl %d2,%a0@+
dbf %d0,Lbz32loop | till done
clrw %d0
subql #1,%d0
jcc Lbz32loop
#endif /* !__mc68010__ */
Lbzlong:
/* set by longwords */
movel %d1,%d0
lsrl #2,%d0 | cnt = len / 4
jeq Lbzbyte | if (cnt)
subql #1,%d0 | set up for dbf
Lbzlloop:
movl %d2,%a0@+ | clear longwords
dbf %d0,Lbzlloop | till done
#ifdef __mc68010__
clrw %d0
subql #1,%d0
jcc Lbzlloop
#endif /* __mc68010__ */
andl #3,%d1 | len %= 4
jeq Lbzdone
subql #1,%d1 | set up for dbf
Lbzbloop:
movb %d2,%a0@+ | set bytes
Lbzbyte:
dbf %d1,Lbzbloop | till done
Lbzdone:
movl %sp@(8),%d0 | return destination
#ifdef __SVR4_ABI__
moveal %d0,%a0
#endif
movl %sp@+,%d2
rts
|
0xffea/MINIX3
| 2,420
|
common/lib/libc/arch/m68k/string/strrchr.S
|
/* $NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)rindex.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strrchr)
movl %sp@(4),%a1 | string
movb %sp@(11),%d0 | char to look for
subl %a0,%a0 | clear rindex pointer
rixloop:
cmpb %a1@,%d0 | found our char?
jne rixnope | no, check for null
movl %a1,%a0 | yes, remember location
rixnope:
tstb %a1@+ | null?
jne rixloop | no, keep going
movl %a0,%d0 | return value
rts
STRONG_ALIAS(rindex,strrchr)
|
0xffea/MINIX3
| 7,377
|
common/lib/libc/arch/m68k/string/bcopy.S
|
/* $NetBSD: bcopy.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by J.T. Conklin.
*
* 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.
*/
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)bcopy.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: bcopy.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
#ifdef MEMCOPY
ENTRY(memcpy)
#else
#ifdef MEMMOVE
ENTRY(memmove)
#else
ENTRY(bcopy)
#endif
#endif
#if defined(MEMCOPY) || defined(MEMMOVE)
movl %sp@(4),%a1 | dest address
movl %sp@(8),%a0 | src address
#else
movl %sp@(4),%a0 | src address
movl %sp@(8),%a1 | dest address
#endif
movl %sp@(12),%d1 | count
cmpl %a1,%a0 | src after dest?
jlt Lbcback | yes, must copy backwards
/*
* It isn't worth the overhead of aligning to {long}word boundries
* if the string is too short.
*/
cmpl #8,%d1
jlt Lbcfbyte
#ifdef __mc68010__
/*
* The 68010 cannot access a word or long on an odd boundary,
* period. If the source and the destination addresses aren't
* of the same evenness, we're forced to do a bytewise copy.
*/
movl %a0,%d0
addl %a1,%d0
btst #0,%d0
jne Lbcfbyte
#endif /* __mc68010__ */
/* word align */
movl %a1,%d0
btst #0,%d0 | if (dst & 1)
jeq Lbcfalgndw |
movb %a0@+,%a1@+ | *(char *)dst++ = *(char *) src++
subql #1,%d1 | len--
Lbcfalgndw:
/* long word align */
btst #1,%d0 | if (dst & 2)
jeq Lbcfalgndl
movw %a0@+,%a1@+ | *(short *)dst++ = *(short *) dst++
subql #2,%d1 | len -= 2
Lbcfalgndl:
/* copy by 8 longwords */
movel %d1,%d0
lsrl #5,%d0 | cnt = len / 32
jeq Lbcflong | if (cnt)
andl #31,%d1 | len %= 32
subql #1,%d0 | set up for dbf
Lbcf32loop:
movl %a0@+,%a1@+ | copy 8 long words
movl %a0@+,%a1@+
movl %a0@+,%a1@+
movl %a0@+,%a1@+
movl %a0@+,%a1@+
movl %a0@+,%a1@+
movl %a0@+,%a1@+
movl %a0@+,%a1@+
dbf %d0,Lbcf32loop | till done
clrw %d0
subql #1,%d0
jcc Lbcf32loop
Lbcflong:
/* copy by longwords */
movel %d1,%d0
lsrl #2,%d0 | cnt = len / 4
jeq Lbcfbyte | if (cnt)
subql #1,%d0 | set up for dbf
Lbcflloop:
movl %a0@+,%a1@+ | copy longwords
dbf %d0,Lbcflloop | til done
andl #3,%d1 | len %= 4
jeq Lbcdone
subql #1,%d1 | set up for dbf
Lbcfbloop:
movb %a0@+,%a1@+ | copy bytes
Lbcfbyte:
dbf %d1,Lbcfbloop | till done
Lbcdone:
#if defined(MEMCOPY) || defined(MEMMOVE)
movl %sp@(4),%d0 | dest address
#if defined(__SVR4_ABI__)
moveal %d0,%a0
#endif
#endif
rts
Lbcback:
addl %d1,%a0 | src pointer to end
addl %d1,%a1 | dest pointer to end
/*
* It isn't worth the overhead of aligning to {long}word boundries
* if the string is too short.
*/
cmpl #8,%d1
jlt Lbcbbyte
#ifdef __mc68010__
/*
* The 68010 cannot access a word or long on an odd boundary,
* period. If the source and the destination addresses aren't
* of the same evenness, we're forced to do a bytewise copy.
*/
movl %a0,%d0
addl %a1,%d0
btst #0,%d0
jne Lbcbbyte
#endif /* __mc68010__ */
/* word align */
movl %a1,%d0
btst #0,%d0 | if (dst & 1)
jeq Lbcbalgndw |
movb %a0@-,%a1@- | *(char *)dst-- = *(char *) src--
subql #1,%d1 | len--
Lbcbalgndw:
/* long word align */
btst #1,%d0 | if (dst & 2)
jeq Lbcbalgndl
movw %a0@-,%a1@- | *(short *)dst-- = *(short *) dst--
subql #2,%d1 | len -= 2
Lbcbalgndl:
/* copy by 8 longwords */
movel %d1,%d0
lsrl #5,%d0 | cnt = len / 32
jeq Lbcblong | if (cnt)
andl #31,%d1 | len %= 32
subql #1,%d0 | set up for dbf
Lbcb32loop:
movl %a0@-,%a1@- | copy 8 long words
movl %a0@-,%a1@-
movl %a0@-,%a1@-
movl %a0@-,%a1@-
movl %a0@-,%a1@-
movl %a0@-,%a1@-
movl %a0@-,%a1@-
movl %a0@-,%a1@-
dbf %d0,Lbcb32loop | till done
clrw %d0
subql #1,%d0
jcc Lbcb32loop
Lbcblong:
/* copy by longwords */
movel %d1,%d0
lsrl #2,%d0 | cnt = len / 4
jeq Lbcbbyte | if (cnt)
subql #1,%d0 | set up for dbf
Lbcblloop:
movl %a0@-,%a1@- | copy longwords
dbf %d0,Lbcblloop | til done
andl #3,%d1 | len %= 4
jeq Lbcdone
subql #1,%d1 | set up for dbf
Lbcbbloop:
movb %a0@-,%a1@- | copy bytes
Lbcbbyte:
dbf %d1,Lbcbbloop | till done
#if defined(MEMCOPY) || defined(MEMMOVE)
movl %sp@(4),%d0 | dest address
#if defined(__SVR4_ABI__)
moveal %d0,%a0
#endif
#endif
rts
|
0xffea/MINIX3
| 3,551
|
common/lib/libc/arch/m68k/string/memcmp.S
|
/* $NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)bcmp.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: memcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* memcmp(s1, s2, n) */
/*
* This is probably not the best we can do, but it is still 2-10 times
* faster than the C version in the portable gen directory.
*
* Things that might help:
* - longword align when possible (only on the 68020)
* - use nested DBcc instructions or use one and limit size to 64K
*/
ENTRY(memcmp)
movl %sp@(4),%a0 | string 1
movl %sp@(8),%a1 | string 2
movl %sp@(12),%d0 | length
jeq bcdone | if zero, nothing to do
movl %a0,%d1
btst #0,%d1 | string 1 address odd?
jeq bceven | no, skip alignment
cmpmb %a0@+,%a1@+ | yes, compare a byte
jne bcnoteq | not equal, return non-zero
subql #1,%d0 | adjust count
jeq bcdone | count 0, reutrn zero
bceven:
movl %a1,%d1
btst #0,%d1 | string 2 address odd?
jne bcbloop | yes, no hope for alignment, compare bytes
movl %d0,%d1 | no, both even
lsrl #2,%d1 | convert count to longword count
jeq bcbloop | count 0, skip longword loop
bclloop:
cmpml %a0@+,%a1@+ | compare a longword
jne bcnoteql | not equal, return non-zero
subql #1,%d1 | adjust count
jne bclloop | still more, keep comparing
andl #3,%d0 | what remains
jeq bcdone | nothing, all done
bcbloop:
cmpmb %a0@+,%a1@+ | compare a byte
jne bcnoteq | not equal, return non-zero
subql #1,%d0 | adjust count
jne bcbloop | still more, keep going
rts
bcnoteql:
subql #4,%a0
subql #4,%a1
movl #4,%d0
jra bcbloop
bcnoteq:
clrl %d0
clrl %d1
movb %a0@-,%d0
movb %a1@-,%d1
subl %d1,%d0
bcdone:
rts
|
0xffea/MINIX3
| 2,206
|
common/lib/libc/arch/m68k/string/strlen.S
|
/* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)strlen.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strlen)
movl %sp@(4),%a0 | string
movl %a0,%d0
notl %d0
Lslloop:
tstb %a0@+ | null?
jne Lslloop | no, keep going
addl %a0,%d0
rts
|
0xffea/MINIX3
| 2,393
|
common/lib/libc/arch/m68k/string/strcat.S
|
/* $NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)strcpy.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strcat)
movl %sp@(8),%a0 | a0 = fromaddr
movl %sp@(4),%d0 | return value is toaddr
movl %d0,%a1 | a1 = toaddr
Lslloop:
tstb %a1@+ | null?
jne Lslloop | no, keep going
subql #1,%a1
Lscloop:
movb %a0@+,%a1@+ | copy a byte
jne Lscloop | copied non-null, keep going
#ifdef __SVR4_ABI__
moveal %d0,%a0
#endif
rts
|
0xffea/MINIX3
| 2,426
|
common/lib/libc/arch/m68k/string/strchr.S
|
/* $NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)index.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strchr)
movl %sp@(4),%a0 | string
movb %sp@(11),%d0 | char to look for
ixloop:
cmpb %a0@,%d0 | found our char?
jeq ixfound | yes, break out
tstb %a0@+ | null?
jne ixloop | no, keep going
moveq #0,%d0 | not found, return null
#ifdef __SVR4_ABI__
moveal %d0,%a0
#endif
rts
ixfound:
movl %a0,%d0 | found, return pointer
rts
STRONG_ALIAS(index,strchr)
|
0xffea/MINIX3
| 2,178
|
common/lib/libc/arch/m68k/string/strcmp.S
|
/* $NetBSD: strcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Hiroshi Horimoto <horimoto@cs-aoi.cs.sist.ac.jp> and
* by J.T. Conklin <jtc@NetBSD.org>.
*
* 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>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: strcmp.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif /* LIBC_SCCS and not lint */
ENTRY(strcmp)
movl %sp@(4),%a0
movl %sp@(8),%a1
L1: /* unrolled by 4 for 680[23]0's */
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jne L3
movb %a0@+,%d1
jeq L2
subb %a1@+,%d1
jeq L1
L3: scs %d0
EXTBL(%d0)
movb %d1,%d0
rts
L2: movq #0,%d0
movb %a1@,%d0
negl %d0
rts
|
0xffea/MINIX3
| 2,716
|
common/lib/libc/arch/m68k/string/strncpy.S
|
/* $NetBSD: strncpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
RCSID("from: @(#)strncpy.s 5.1 (Berkeley) 5/12/90")
#else
RCSID("$NetBSD: strncpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strncpy)
movl %sp@(4),%d0 | return value is toaddr
movl %sp@(12),%d1 | count
jeq Lscdone | nothing to do
movl %sp@(8),%a0 | a0 = fromaddr
movl %d0,%a1 | a1 = toaddr
subql #1,%d1
Lscloop:
movb %a0@+,%a1@+ | copy a byte
dbeq %d1,Lscloop | loop through low word of d1
jeq Lscpadding | copied null, padding if necessary
clrw %d1 | clear low word of d1
subql #1,%d1 | adjust count for long copies
jcc Lscloop | more room, keep going
Lscdone:
#ifdef __SVR4_ABI__
moveal %d0,%a0
#endif
rts
Lscploop:
clrb %a1@+ | clear a byte
dbra %d1,Lscploop | keep going
clrw %d1
Lscpadding:
subql #1,%d1
jcc Lscploop
jra Lscdone
|
0xffea/MINIX3
| 2,224
|
common/lib/libc/arch/i386/gen/byte_swap_2.S
|
/* $NetBSD: byte_swap_2.S,v 1.3 2007/11/28 17:03:35 ad Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)htons.s 5.2 (Berkeley) 12/17/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: byte_swap_2.S,v 1.3 2007/11/28 17:03:35 ad Exp $")
#endif
#if defined(_KERNEL) || defined(_STANDALONE)
_ENTRY(_C_LABEL(bswap16))
#else /* defined(_KERNEL) || defined(_STANDALONE) */
_ENTRY(_C_LABEL(__bswap16))
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
_ENTRY(_C_LABEL(ntohs))
_ENTRY(_C_LABEL(htons))
_PROF_PROLOGUE
movzwl 4(%esp),%eax
xchgb %al, %ah
ret
|
0xffea/MINIX3
| 2,218
|
common/lib/libc/arch/i386/gen/byte_swap_4.S
|
/* $NetBSD: byte_swap_4.S,v 1.3 2007/11/28 17:03:35 ad Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)htonl.s 5.3 (Berkeley) 12/17/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: byte_swap_4.S,v 1.3 2007/11/28 17:03:35 ad Exp $")
#endif
#if defined(_KERNEL) || defined(_STANDALONE)
_ENTRY(_C_LABEL(bswap32))
#else /* defined(_KERNEL) || defined(_STANDALONE) */
_ENTRY(_C_LABEL(__bswap32))
#endif /* defined(_KERNEL) || defined(_STANDALONE) */
_ENTRY(_C_LABEL(ntohl))
_ENTRY(_C_LABEL(htonl))
_PROF_PROLOGUE
movl 4(%esp),%eax
bswap %eax
ret
|
0xffea/MINIX3
| 2,574
|
common/lib/libc/arch/i386/gen/_setjmp.S
|
/* $NetBSD: _setjmp.S,v 1.8 2005/10/05 20:18:12 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)_setjmp.s 5.1 (Berkeley) 4/23/90
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: _setjmp.S,v 1.8 2005/10/05 20:18:12 christos Exp $")
#endif
/*
* C library -- _setjmp, _longjmp
*
* _longjmp(a,v)
* will generate a "return(v)" from the last call to
* _setjmp(a)
* by restoring registers from the stack.
* The previous signal state is NOT restored.
*/
ENTRY(_setjmp)
movl 4(%esp),%eax
movl 0(%esp),%edx
movl %edx, 0(%eax) /* rta */
movl %ebx, 4(%eax)
movl %esp, 8(%eax)
movl %ebp,12(%eax)
movl %esi,16(%eax)
movl %edi,20(%eax)
xorl %eax,%eax
ret
ENTRY(_longjmp)
movl 4(%esp),%edx
movl 8(%esp),%eax
movl 0(%edx),%ecx
movl 4(%edx),%ebx
movl 8(%edx),%esp
movl 12(%edx),%ebp
movl 16(%edx),%esi
movl 20(%edx),%edi
testl %eax,%eax
jnz 1f
incl %eax
1: movl %ecx,0(%esp)
ret
|
0xffea/MINIX3
| 9,321
|
common/lib/libc/arch/i386/atomic/atomic.S
|
/* $NetBSD: atomic.S,v 1.19 2011/01/12 23:12:10 joerg Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe, and by Andrew Doran.
*
* 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/param.h>
#include <machine/asm.h>
#ifdef _KERNEL
#define ALIAS(f, t) STRONG_ALIAS(f,t)
#else
#define ALIAS(f, t) WEAK_ALIAS(f,t)
#endif
#ifdef _HARDKERNEL
#define LOCK(n) .Lpatch ## n: lock
#define ENDLABEL(a) _ALIGN_TEXT; LABEL(a)
#else
#define LOCK(n) lock
#define ENDLABEL(a) /* nothing */
#endif
.text
ENTRY(_atomic_add_32)
movl 4(%esp), %edx
movl 8(%esp), %eax
LOCK(1)
addl %eax, (%edx)
ret
ENTRY(_atomic_add_32_nv)
movl 4(%esp), %edx
movl 8(%esp), %eax
movl %eax, %ecx
LOCK(2)
xaddl %eax, (%edx)
addl %ecx, %eax
ret
ENTRY(_atomic_and_32)
movl 4(%esp), %edx
movl 8(%esp), %eax
LOCK(3)
andl %eax, (%edx)
ret
ENTRY(_atomic_and_32_nv)
movl 4(%esp), %edx
movl (%edx), %eax
0:
movl %eax, %ecx
andl 8(%esp), %ecx
LOCK(4)
cmpxchgl %ecx, (%edx)
jnz 1f
movl %ecx, %eax
ret
1:
jmp 0b
ENTRY(_atomic_dec_32)
movl 4(%esp), %edx
LOCK(5)
decl (%edx)
ret
ENTRY(_atomic_dec_32_nv)
movl 4(%esp), %edx
movl $-1, %eax
LOCK(6)
xaddl %eax, (%edx)
decl %eax
ret
ENTRY(_atomic_inc_32)
movl 4(%esp), %edx
LOCK(7)
incl (%edx)
ret
ENTRY(_atomic_inc_32_nv)
movl 4(%esp), %edx
movl $1, %eax
LOCK(8)
xaddl %eax, (%edx)
incl %eax
ret
ENTRY(_atomic_or_32)
movl 4(%esp), %edx
movl 8(%esp), %eax
LOCK(9)
orl %eax, (%edx)
ret
ENTRY(_atomic_or_32_nv)
movl 4(%esp), %edx
movl (%edx), %eax
0:
movl %eax, %ecx
orl 8(%esp), %ecx
LOCK(10)
cmpxchgl %ecx, (%edx)
jnz 1f
movl %ecx, %eax
ret
1:
jmp 0b
ENTRY(_atomic_swap_32)
movl 4(%esp), %edx
movl 8(%esp), %eax
xchgl %eax, (%edx)
ret
ENTRY(_atomic_cas_32)
movl 4(%esp), %edx
movl 8(%esp), %eax
movl 12(%esp), %ecx
LOCK(12)
cmpxchgl %ecx, (%edx)
/* %eax now contains the old value */
ret
ENTRY(_atomic_cas_32_ni)
movl 4(%esp), %edx
movl 8(%esp), %eax
movl 12(%esp), %ecx
cmpxchgl %ecx, (%edx)
/* %eax now contains the old value */
ret
ENTRY(_membar_consumer)
LOCK(13)
addl $0, -4(%esp)
ret
ENDLABEL(membar_consumer_end)
ENTRY(_membar_producer)
/* A store is enough */
movl $0, -4(%esp)
ret
ENDLABEL(membar_producer_end)
ENTRY(_membar_sync)
LOCK(14)
addl $0, -4(%esp)
ret
ENDLABEL(membar_sync_end)
#ifdef _HARDKERNEL
ENTRY(_atomic_cas_64)
pushf
cli
pushl %edi
pushl %ebx
movl 12(%esp), %edi
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 24(%esp), %ebx
movl 28(%esp), %ecx
cmpl 0(%edi), %eax
jne 2f
cmpl 4(%edi), %edx
jne 2f
movl %ebx, 0(%edi)
movl %ecx, 4(%edi)
1:
popl %ebx
popl %edi
popf
ret
2:
movl 0(%edi), %eax
movl 4(%edi), %edx
jmp 1b
ENDLABEL(_atomic_cas_64_end)
ENTRY(_atomic_cas_cx8)
pushl %edi
pushl %ebx
movl 12(%esp), %edi
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 24(%esp), %ebx
movl 28(%esp), %ecx
LOCK(15)
cmpxchg8b (%edi)
popl %ebx
popl %edi
ret
#ifdef GPROF
.space 16, 0x90
#else
.space 32, 0x90
#endif
ENDLABEL(_atomic_cas_cx8_end)
ENTRY(sse2_lfence)
lfence
ret
ENDLABEL(sse2_lfence_end)
ENTRY(sse2_mfence)
mfence
ret
ENDLABEL(sse2_mfence_end)
atomic_lockpatch:
.globl atomic_lockpatch
.long .Lpatch1, .Lpatch2, .Lpatch3, .Lpatch4, .Lpatch5
.long .Lpatch6, .Lpatch7, .Lpatch8, .Lpatch9, .Lpatch10
.long .Lpatch12, .Lpatch13, .Lpatch14, .Lpatch15, 0
#else
ENTRY(_atomic_cas_64)
pushl %edi
pushl %ebx
movl 12(%esp), %edi
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 24(%esp), %ebx
movl 28(%esp), %ecx
lock
cmpxchg8b (%edi)
popl %ebx
popl %edi
ret
#endif /* _HARDKERNEL */
ALIAS(atomic_add_32,_atomic_add_32)
ALIAS(atomic_add_int,_atomic_add_32)
ALIAS(atomic_add_long,_atomic_add_32)
ALIAS(atomic_add_ptr,_atomic_add_32)
ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
ALIAS(atomic_and_32,_atomic_and_32)
ALIAS(atomic_and_uint,_atomic_and_32)
ALIAS(atomic_and_ulong,_atomic_and_32)
ALIAS(atomic_and_ptr,_atomic_and_32)
ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv)
ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv)
ALIAS(atomic_dec_32,_atomic_dec_32)
ALIAS(atomic_dec_uint,_atomic_dec_32)
ALIAS(atomic_dec_ulong,_atomic_dec_32)
ALIAS(atomic_dec_ptr,_atomic_dec_32)
ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv)
ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv)
ALIAS(atomic_inc_32,_atomic_inc_32)
ALIAS(atomic_inc_uint,_atomic_inc_32)
ALIAS(atomic_inc_ulong,_atomic_inc_32)
ALIAS(atomic_inc_ptr,_atomic_inc_32)
ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv)
ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv)
ALIAS(atomic_or_32,_atomic_or_32)
ALIAS(atomic_or_uint,_atomic_or_32)
ALIAS(atomic_or_ulong,_atomic_or_32)
ALIAS(atomic_or_ptr,_atomic_or_32)
ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv)
ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv)
ALIAS(atomic_swap_32,_atomic_swap_32)
ALIAS(atomic_swap_uint,_atomic_swap_32)
ALIAS(atomic_swap_ulong,_atomic_swap_32)
ALIAS(atomic_swap_ptr,_atomic_swap_32)
ALIAS(atomic_cas_32,_atomic_cas_32)
ALIAS(atomic_cas_uint,_atomic_cas_32)
ALIAS(atomic_cas_ulong,_atomic_cas_32)
ALIAS(atomic_cas_ptr,_atomic_cas_32)
ALIAS(atomic_cas_32_ni,_atomic_cas_32_ni)
ALIAS(atomic_cas_uint_ni,_atomic_cas_32_ni)
ALIAS(atomic_cas_ulong_ni,_atomic_cas_32_ni)
ALIAS(atomic_cas_ptr_ni,_atomic_cas_32_ni)
ALIAS(atomic_cas_64,_atomic_cas_64)
ALIAS(atomic_cas_64_ni,_atomic_cas_64)
ALIAS(membar_consumer,_membar_consumer)
ALIAS(membar_producer,_membar_producer)
ALIAS(membar_enter,_membar_consumer)
ALIAS(membar_exit,_membar_producer)
ALIAS(membar_sync,_membar_sync)
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
STRONG_ALIAS(_atomic_add_long,_atomic_add_32)
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32)
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32)
STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32)
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32)
STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32)
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32)
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32_ni)
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32_ni)
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32_ni)
STRONG_ALIAS(_membar_enter,_membar_consumer)
STRONG_ALIAS(_membar_exit,_membar_producer)
|
0xffea/MINIX3
| 3,287
|
common/lib/libc/arch/i386/string/memcpy.S
|
/* $NetBSD: memcpy.S,v 1.3 2007/11/12 18:41:59 ad Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from locore.s.
* Optimised by David Laight 2003
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: memcpy.S,v 1.3 2007/11/12 18:41:59 ad Exp $")
#endif
/*
* (ov)bcopy (src,dst,cnt)
* ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
*/
#ifdef BCOPY
ENTRY(bcopy)
#else
#ifdef MEMMOVE
ENTRY(memmove)
#else
#define MEMCPY
#define NO_OVERLAP
ENTRY(memcpy)
#endif
#endif
push %esi
mov %edi,%edx
#if defined(MEMCPY) || defined(MEMMOVE)
movl 8(%esp),%edi
movl 12(%esp),%esi
#else
movl 8(%esp),%esi
movl 12(%esp),%edi
#endif
movl 16(%esp),%ecx
#if defined(NO_OVERLAP)
movl %ecx,%eax
#else
movl %edi,%eax
subl %esi,%eax
cmpl %ecx,%eax /* overlapping? */
movl %ecx,%eax
jb .Lbackwards
#endif
/* nope, copy forwards. */
shrl $2,%ecx /* copy by words */
rep
movsl
and $3,%eax /* any bytes left? */
jnz .Ltrailing
.Ldone:
#if defined(MEMCPY) || defined(MEMMOVE)
movl 8(%esp),%eax
#endif
mov %edx,%edi
pop %esi
ret
.Ltrailing:
cmp $2,%eax
jb 1f
movw (%esi),%ax
movw %ax,(%edi)
je .Ldone
movb 2(%esi),%al
movb %al,2(%edi)
jmp .Ldone
1: movb (%esi),%al
movb %al,(%edi)
jmp .Ldone
#if !defined(NO_OVERLAP)
.Lbackwards:
addl %ecx,%edi /* copy backwards. */
addl %ecx,%esi
and $3,%eax /* any fractional bytes? */
jnz .Lback_align
.Lback_aligned:
shrl $2,%ecx
subl $4,%esi
subl $4,%edi
std
rep
movsl
cld
jmp .Ldone
.Lback_align:
sub %eax,%esi
sub %eax,%edi
cmp $2,%eax
jb 1f
je 2f
movb 2(%esi),%al
movb %al,2(%edi)
2: movw (%esi),%ax
movw %ax,(%edi)
jmp .Lback_aligned
1: movb (%esi),%al
movb %al,(%edi)
jmp .Lback_aligned
#endif
|
0xffea/MINIX3
| 1,636
|
common/lib/libc/arch/i386/string/strcpy.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strcpy.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
/*
* This strcpy implementation copies a byte at a time until the
* source pointer is aligned to a word boundary, it then copies by
* words until it finds a word containing a zero byte, and finally
* copies by bytes until the end of the string is reached.
*
* While this may result in unaligned stores if the source and
* destination pointers are unaligned with respect to each other,
* it is still faster than either byte copies or the overhead of
* an implementation suitable for machines with strict alignment
* requirements.
*/
ENTRY(strcpy)
pushl %ebx
movl 8(%esp),%ecx
movl 12(%esp),%eax
/*
* Align source to a word boundary.
* Consider unrolling loop?
*/
_ALIGN_TEXT
.Lalign:
testl $3,%eax
je .Lword_aligned
movb (%eax),%bl
incl %eax
movb %bl,(%ecx)
incl %ecx
testb %bl,%bl
jne .Lalign
jmp .Ldone
_ALIGN_TEXT
.Lloop:
movl %ebx,(%ecx)
addl $4,%ecx
.Lword_aligned:
movl (%eax),%ebx
addl $4,%eax
leal -0x01010101(%ebx),%edx
testl $0x80808080,%edx
je .Lloop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word equal 0.
*/
movb %bl,(%ecx)
incl %ecx
testb %bl,%bl
je .Ldone
movb %bh,(%ecx)
incl %ecx
testb %bh,%bh
je .Ldone
shrl $16,%ebx
movb %bl,(%ecx)
incl %ecx
testb %bl,%bl
je .Ldone
movb %bh,(%ecx)
incl %ecx
testb %bh,%bh
jne .Lword_aligned
.Ldone:
movl 8(%esp),%eax
popl %ebx
ret
|
0xffea/MINIX3
| 3,046
|
common/lib/libc/arch/i386/string/memset.S
|
/* $NetBSD: memset.S,v 1.4 2008/04/29 06:53:01 martin Exp $ */
/*-
* Copyright (c) 2003 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>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: memset.S,v 1.4 2008/04/29 06:53:01 martin Exp $")
#endif
#ifdef BZERO
ENTRY(bzero)
#else
ENTRY(memset)
#endif
#ifdef BZERO
movl 8(%esp),%ecx
xor %eax,%eax
#else
movl 12(%esp),%ecx
movzbl 8(%esp),%eax /* unsigned char, zero extend */
#endif
cmpl $0x0f,%ecx /* avoid mispredicted branch... */
pushl %edi
movl 8(%esp),%edi
/*
* if the string is too short, it's really not worth the overhead
* of aligning to word boundries, etc. So we jump to a plain
* unaligned set.
*
* NB aligning the transfer is actually pointless on my athlon 700,
* It does make a difference to a PII though.
*
* The PII, PIII and PIV all seem to have a massive performance
* drop when the initial target address is an odd multiple of 4.
*/
jbe .Lby_bytes
#ifndef BZERO
movb %al,%ah /* copy char to all bytes in word */
movl %eax,%edx
sall $16,%eax
orl %edx,%eax
#endif
movl %edi,%edx /* detect misalignment */
neg %edx
andl $7,%edx
jnz .Lalign
.Laligned:
movl %eax,-4(%edi,%ecx) /* zap last 4 bytes */
shrl $2,%ecx /* zero by words */
rep
stosl
.Ldone:
#ifndef BZERO
movl 8(%esp),%eax /* return address of buffer */
#endif
pop %edi
ret
.Lalign:
movl %eax,(%edi) /* zap first 8 bytes */
movl %eax,4(%edi)
subl %edx,%ecx /* remove from main count */
add %edx,%edi
jmp .Laligned
.Lby_bytes:
rep
stosb
#ifndef BZERO
movl 8(%esp),%eax /* return address of buffer */
#endif
popl %edi
ret
|
0xffea/MINIX3
| 1,727
|
common/lib/libc/arch/i386/string/strrchr.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
#endif
ENTRY(strrchr)
pushl %esi
pushl %edi
pushl %ebx
movl 16(%esp),%edx
movzbl 20(%esp),%ecx
/* zero return value */
xorl %eax,%eax
/*
* Align to word boundary.
* Consider unrolling loop?
*/
.Lalign:
testb $3,%dl
je .Lword_aligned
movb (%edx),%bl
cmpb %cl,%bl
jne 1f
movl %edx,%eax
1: testb %bl,%bl
je .Ldone
incl %edx
jmp .Lalign
.Lword_aligned:
/* copy char to all bytes in word */
movb %cl,%ch
movl %ecx,%edi
sall $16,%ecx
orl %edi,%ecx
/* Check whether any byte in the word is equal to ch or 0. */
_ALIGN_TEXT
.Lloop:
movl (%edx),%ebx
addl $4,%edx
movl %ebx,%esi
leal -0x01010101(%ebx),%edi
xorl %ecx,%esi
subl $0x01010101,%esi
orl %esi,%edi
testl $0x80808080,%edi
je .Lloop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word match
* ch or are equal to 0.
*/
_ALIGN_TEXT
cmpb %cl,%bl /* 1st byte == ch? */
jne 1f
leal -4(%edx),%eax
1: testb %bl,%bl /* 1st byte == 0? */
je .Ldone
cmpb %cl,%bh /* 2nd byte == ch? */
jne 1f
leal -3(%edx),%eax
1: testb %bh,%bh /* 2nd byte == 0? */
je .Ldone
shrl $16,%ebx
cmpb %cl,%bl /* 3rd byte == ch? */
jne 1f
leal -2(%edx),%eax
1: testb %bl,%bl /* 3rd byte == 0? */
je .Ldone
cmpb %cl,%bh /* 4th byte == ch? */
jne 1f
leal -1(%edx),%eax
1: testb %bh,%bh /* 4th byte == 0? */
jne .Lloop
.Ldone:
popl %ebx
popl %edi
popl %esi
ret
#ifdef __minix
STRONG_ALIAS(_C_LABEL(rindex),_C_LABEL(strrchr))
#else
STRONG_ALIAS(rindex,strrchr)
#endif
|
0xffea/MINIX3
| 1,812
|
common/lib/libc/arch/i386/string/memchr.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: memchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
ENTRY(memchr)
pushl %esi
movl 8(%esp),%eax
movzbl 12(%esp),%ecx
movl 16(%esp),%esi
/*
* Align to word boundary.
* Consider unrolling loop?
*/
testl %esi,%esi /* nbytes == 0? */
je .Lzero
.Lalign:
testb $3,%al
je .Lword_aligned
cmpb (%eax),%cl
je .Ldone
incl %eax
decl %esi
jnz .Lalign
jmp .Lzero
.Lword_aligned:
/* copy char to all bytes in word */
movb %cl,%ch
movl %ecx,%edx
sall $16,%ecx
orl %edx,%ecx
_ALIGN_TEXT
.Lloop:
cmpl $3,%esi /* nbytes > 4 */
jbe .Lbyte
movl (%eax),%edx
addl $4,%eax
xorl %ecx,%edx
subl $4,%esi
subl $0x01010101,%edx
testl $0x80808080,%edx
je .Lloop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word are
* equal to ch.
*/
/*
* High load-use latency on the Athlon leads to significant
* stalls, so we preload the next char as soon as possible
* instead of using cmp mem8, reg8.
*
* Alignment here avoids a stall on the Athlon, even though
* it's not a branch target.
*/
_ALIGN_TEXT
cmpb -4(%eax),%cl /* 1st byte == ch? */
movb -3(%eax),%dl
jne 1f
subl $4,%eax
jmp .Ldone
_ALIGN_TEXT
1: cmpb %dl,%cl /* 2nd byte == ch? */
movb -2(%eax),%dl
jne 1f
subl $3,%eax
jmp .Ldone
_ALIGN_TEXT
1: cmpb %dl,%cl /* 3rd byte == ch? */
movb -1(%eax),%dl
jne 1f
subl $2,%eax
jmp .Ldone
_ALIGN_TEXT
1: cmpb %dl,%cl /* 4th byte == ch? */
jne .Lloop
decl %eax
jmp .Ldone
.Lbyte:
testl %esi,%esi
je .Lzero
.Lbyte_loop:
cmpb (%eax),%cl
je .Ldone
incl %eax
decl %esi
jnz .Lbyte_loop
.Lzero:
xorl %eax,%eax
.Ldone:
popl %esi
ret
|
0xffea/MINIX3
| 4,062
|
common/lib/libc/arch/i386/string/strlen.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
ENTRY(strlen)
movl 4(%esp),%eax
.Lalign:
/* Consider unrolling loop? */
testb $3,%al
je .Lword_aligned
cmpb $0,(%eax)
je .Ldone
incl %eax
jmp .Lalign
/*
* There are many well known branch-free sequences which are used
* for determining whether a zero-byte is contained within a word.
* These sequences are generally much more efficent than loading
* and comparing each byte individually.
*
* The expression [1,2]:
*
* (1) ~(((x & 0x7f7f7f7f) + 0x7f7f7f7f) | (x | 0x7f7f7f7f))
*
* evaluates to a non-zero value if any of the bytes in the
* original word is zero.
*
* It also has the useful property that bytes in the result word
* that correspond to non-zero bytes in the original word have
* the value 0x00, while bytes corresponding to zero bytes have
* the value 0x80. This allows calculation of the first (and
* last) occurrence of a zero byte within the word (useful for C's
* str* primitives) by counting the number of leading (or
* trailing) zeros and dividing the result by 8. On machines
* without (or with slow) clz() / ctz() instructions, testing
* each byte in the result word for zero is necessary.
*
* This typically takes 4 instructions (5 on machines without
* "not-or") not including those needed to load the constant.
*
*
* The expression:
*
* (2) ((x - 0x01010101) & ~x & 0x80808080)
*
* evaluates to a non-zero value if any of the bytes in the
* original word is zero.
*
* On little endian machines, the first byte in the result word
* that corresponds to a zero byte in the original byte is 0x80,
* so clz() can be used as above. On big endian machines, and
* little endian machines without (or with a slow) clz() insn,
* testing each byte in the original for zero is necessary.
*
* This typically takes 3 instructions (4 on machines without
* "and with complement") not including those needed to load
* constants.
*
*
* The expression:
*
* (3) ((x - 0x01010101) & 0x80808080)
*
* always evaluates to a non-zero value if any of the bytes in
* the original word is zero. However, in rare cases, it also
* evaluates to a non-zero value when none of the bytes in the
* original word is zero.
*
* To account for possible false positives, each byte of the
* original word must be checked when the expression evaluates to
* a non-zero value. However, because it is simpler than those
* presented above, code that uses it will be faster as long as
* the rate of false positives is low.
*
* This is likely, because the the false positive can only occur
* if the most siginificant bit of a byte within the word is set.
* The expression will never fail for typical 7-bit ASCII strings.
*
* This typically takes 2 instructions not including those needed
* to load constants.
*
*
* [1] Henry S. Warren Jr., "Hacker's Delight", Addison-Westley 2003
*
* [2] International Business Machines, "The PowerPC Compiler Writer's
* Guide", Warthman Associates, 1996
*/
_ALIGN_TEXT
.Lword_aligned:
.Lloop:
movl (%eax),%ecx
addl $4,%eax
leal -0x01010101(%ecx),%edx
testl $0x80808080,%edx
je .Lloop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word equal 0.
*/
/*
* The optimal code for determining whether each byte is zero
* differs by processor. This space-optimized code should be
* acceptable on all, especially since we don't expect it to
* be run frequently,
*/
testb %cl,%cl /* 1st byte == 0? */
jne 1f
subl $4,%eax
jmp .Ldone
1: testb %ch,%ch /* 2nd byte == 0? */
jne 1f
subl $3,%eax
jmp .Ldone
1: shrl $16,%ecx
testb %cl,%cl /* 3rd byte == 0? */
jne 1f
subl $2,%eax
jmp .Ldone
1: testb %ch,%ch /* 4th byte == 0? */
jne .Lloop
decl %eax
.Ldone:
subl 4(%esp),%eax
ret
|
0xffea/MINIX3
| 2,105
|
common/lib/libc/arch/i386/string/strcat.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strcat.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
ENTRY(strcat)
pushl %ebx
movl 8(%esp),%ecx
movl 12(%esp),%eax
/*
* Align destination to word boundary.
* Consider unrolling loop?
*/
.Lscan:
.Lscan_align:
testb $3,%cl
je .Lscan_aligned
cmpb $0,(%ecx)
je .Lcopy
incl %ecx
jmp .Lscan_align
_ALIGN_TEXT
.Lscan_aligned:
.Lscan_loop:
movl (%ecx),%ebx
addl $4,%ecx
leal -0x01010101(%ebx),%edx
testl $0x80808080,%edx
je .Lscan_loop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word equal 0.
*/
/*
* The optimal code for determining whether each byte is zero
* differs by processor. This space-optimized code should be
* acceptable on all, especially since we don't expect it to
* be run frequently,
*/
testb %bl,%bl /* 1st byte == 0? */
jne 1f
subl $4,%ecx
jmp .Lcopy
1: testb %bh,%bh /* 2nd byte == 0? */
jne 1f
subl $3,%ecx
jmp .Lcopy
1: shrl $16,%ebx
testb %bl,%bl /* 3rd byte == 0? */
jne 1f
subl $2,%ecx
jmp .Lcopy
1: testb %bh,%bh /* 4th byte == 0? */
jne .Lscan_loop
subl $1,%ecx
/*
* Align source to a word boundary.
* Consider unrolling loop?
*/
.Lcopy:
.Lcopy_align:
testl $3,%eax
je .Lcopy_aligned
movb (%eax),%bl
incl %eax
movb %bl,(%ecx)
incl %ecx
testb %bl,%bl
jne .Lcopy_align
jmp .Ldone
_ALIGN_TEXT
.Lcopy_loop:
movl %ebx,(%ecx)
addl $4,%ecx
.Lcopy_aligned:
movl (%eax),%ebx
addl $4,%eax
leal -0x01010101(%ebx),%edx
testl $0x80808080,%edx
je .Lcopy_loop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word equal 0.
*/
movb %bl,(%ecx)
incl %ecx
testb %bl,%bl
je .Ldone
movb %bh,(%ecx)
incl %ecx
testb %bh,%bh
je .Ldone
shrl $16,%ebx
movb %bl,(%ecx)
incl %ecx
testb %bl,%bl
je .Ldone
movb %bh,(%ecx)
incl %ecx
testb %bh,%bh
jne .Lcopy_aligned
.Ldone:
movl 8(%esp),%eax
popl %ebx
ret
|
0xffea/MINIX3
| 1,826
|
common/lib/libc/arch/i386/string/strchr.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
#endif
ENTRY(strchr)
pushl %esi
pushl %ebx
movl 12(%esp),%eax
movzbl 16(%esp),%ecx
/*
* Align to word boundary.
* Consider unrolling loop?
*/
.Lalign:
testb $3,%al
je .Lword_aligned
movb (%eax),%bl
cmpb %cl,%bl
je .Ldone
testb %bl,%bl
je .Lzero
incl %eax
jmp .Lalign
.Lword_aligned:
/* copy char to all bytes in word */
movb %cl,%ch
movl %ecx,%edx
sall $16,%ecx
orl %edx,%ecx
/* Check whether any byte in the word is equal to ch or 0. */
_ALIGN_TEXT
.Lloop:
movl (%eax),%ebx
addl $4,%eax
movl %ebx,%esi
leal -0x01010101(%ebx),%edx
xorl %ecx,%esi
subl $0x01010101,%esi
orl %esi,%edx
testl $0x80808080,%edx
je .Lloop
/*
* In rare cases, the above loop may exit prematurely. We must
* return to the loop if none of the bytes in the word match
* ch or are equal to 0.
*/
/*
* Alignment here avoids a stall on the Athlon, even though
* it's not a branch target.
*/
_ALIGN_TEXT
cmpb %cl,%bl /* 1st byte == ch? */
jne 1f
subl $4,%eax
jmp .Ldone
1: testb %bl,%bl /* 1st byte == 0? */
je .Lzero
cmpb %cl,%bh /* 2nd byte == ch? */
jne 1f
subl $3,%eax
jmp .Ldone
1: testb %bh,%bh /* 2nd byte == 0? */
je .Lzero
shrl $16,%ebx
cmpb %cl,%bl /* 3rd byte == ch? */
jne 1f
subl $2,%eax
jmp .Ldone
1: testb %bl,%bl /* 3rd byte == 0? */
je .Lzero
cmpb %cl,%bh /* 4th byte == ch? */
jne 1f
decl %eax
jmp .Ldone
1: testb %bh,%bh /* 4th byte == 0? */
jne .Lloop
.Lzero:
/* If a ch wasn't found, return 0. */
xorl %eax,%eax
.Ldone:
popl %ebx
popl %esi
ret
#ifdef __minix
STRONG_ALIAS(_C_LABEL(index),_C_LABEL(strchr))
#else
STRONG_ALIAS(index,strchr)
#endif
|
0xffea/MINIX3
| 1,172
|
common/lib/libc/arch/i386/string/strcmp.S
|
/*
* Written by J.T. Conklin <jtc@acorntoolworks.com>
* Public domain.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS)
RCSID("$NetBSD: strcmp.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
#endif
ENTRY(strcmp)
pushl %esi
pushl %ebx
movl 12(%esp),%ebx
movl 16(%esp),%esi
/*
* Align s1 to word boundary.
* Consider unrolling loop?
*/
.Ls1align:
testb $3,%bl
je .Ls1aligned
movb (%ebx),%al
incl %ebx
movb (%esi),%dl
incl %esi
testb %al,%al
je .Ldone
cmpb %al,%dl
je .Ls1align
jmp .Ldone
/*
* Check whether s2 is aligned to a word boundary. If it is, we
* can compare by words. Otherwise we have to compare by bytes.
*/
.Ls1aligned:
testl $3,%esi
jne .Lbyte_loop
subl $4,%ebx
subl $4,%esi
_ALIGN_TEXT
.Lword_loop:
movl 4(%ebx),%eax
addl $4,%ebx
movl 4(%esi),%edx
addl $4,%esi
cmpl %eax,%edx
jne .Lbyte_loop
subl $0x01010101,%edx
notl %eax
andl %eax,%edx
testl $0x80808080,%edx
je .Lword_loop
_ALIGN_TEXT
.Lbyte_loop:
movb (%ebx),%al
incl %ebx
movb (%esi),%dl
incl %esi
testb %al,%al
je .Ldone
cmpb %al,%dl
je .Lbyte_loop
.Ldone:
movzbl %al,%eax
movzbl %dl,%edx
subl %edx,%eax
popl %ebx
popl %esi
ret
|
0xffea/MINIX3
| 6,689
|
common/lib/libc/arch/sh3/string/memcpy.S
|
/* $NetBSD: memcpy.S,v 1.2 2006/04/22 23:53:47 uwe Exp $ */
/*
* Copyright (c) 2000 SHIMIZU Ryo <ryo@misakimix.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: memcpy.S,v 1.2 2006/04/22 23:53:47 uwe Exp $")
#endif
#if !defined(MEMCOPY) && !defined(MEMMOVE) && !defined(BCOPY)
#define MEMCOPY
#endif
#if defined(MEMCOPY) || defined(MEMMOVE)
#define REG_DST0 r3
#define REG_SRC r5
#define REG_DST r4
#else
#define REG_SRC r4
#define REG_DST r5
#endif
#define REG_LEN r6
#if defined(MEMCOPY)
ENTRY(memcpy)
#elif defined(MEMMOVE)
ENTRY(memmove)
#elif defined(BCOPY)
ENTRY(bcopy)
#endif
#ifdef REG_DST0
mov REG_DST,REG_DST0
#endif
cmp/eq REG_DST,REG_SRC /* if ( src == dst ) return; */
bt/s bcopy_return
cmp/hi REG_DST,REG_SRC
bf/s bcopy_overlap
mov REG_SRC,r0
xor REG_DST,r0
and #3,r0
mov r0,r1
tst r0,r0 /* (src ^ dst) & 3 */
bf/s word_align
longword_align:
tst REG_LEN,REG_LEN /* if ( len==0 ) return; */
bt/s bcopy_return
mov REG_SRC,r0
tst #1,r0 /* if ( src & 1 ) */
bt 1f
mov.b @REG_SRC+,r0 /* *dst++ = *src++; */
add #-1,REG_LEN
mov.b r0,@REG_DST
add #1,REG_DST
1:
mov #1,r0
cmp/hi r0,REG_LEN /* if ( (len > 1) && */
bf/s 1f
mov REG_SRC,r0
tst #2,r0 /* (src & 2) { */
bt 1f
mov.w @REG_SRC+,r0 /* *((unsigned short*)dst)++ = *((unsigned short*)src)++; */
add #-2,REG_LEN /* len -= 2; */
mov.w r0,@REG_DST
add #2,REG_DST /* } */
1:
mov #3,r1
cmp/hi r1,REG_LEN /* while ( len > 3 ) { */
bf/s no_align_delay
tst REG_LEN,REG_LEN
2:
mov.l @REG_SRC+,r0 /* *((unsigned long*)dst)++ = *((unsigned long*)src)++; */
add #-4,REG_LEN /* len -= 4; */
mov.l r0,@REG_DST
cmp/hi r1,REG_LEN
bt/s 2b
add #4,REG_DST /* } */
bra no_align_delay
tst REG_LEN,REG_LEN
word_align:
mov r1,r0
tst #1,r0
bf/s no_align_delay
tst REG_LEN,REG_LEN /* if ( len == 0 ) return; */
bt bcopy_return
mov REG_SRC,r0 /* if ( src & 1 ) */
tst #1,r0
bt 1f
mov.b @REG_SRC+,r0 /* *dst++ = *src++; */
add #-1,REG_LEN
mov.b r0,@REG_DST
add #1,REG_DST
1:
mov #1,r1
cmp/hi r1,REG_LEN /* while ( len > 1 ) { */
bf/s no_align_delay
tst REG_LEN,REG_LEN
2:
mov.w @REG_SRC+,r0 /* *((unsigned short*)dst)++ = *((unsigned short*)src)++; */
add #-2,REG_LEN /* len -= 2; */
mov.w r0,@REG_DST
cmp/hi r1,REG_LEN
bt/s 2b
add #2,REG_DST /* } */
no_align:
tst REG_LEN,REG_LEN /* while ( len!= ) { */
no_align_delay:
bt bcopy_return
1:
mov.b @REG_SRC+,r0 /* *dst++ = *src++; */
add #-1,REG_LEN /* len--; */
mov.b r0,@REG_DST
tst REG_LEN,REG_LEN
bf/s 1b
add #1,REG_DST /* } */
bcopy_return:
rts
#ifdef REG_DST0
mov REG_DST0,r0
#else
nop
#endif
bcopy_overlap:
add REG_LEN,REG_SRC
add REG_LEN,REG_DST
mov REG_SRC,r0
xor REG_DST,r0
and #3,r0
mov r0,r1
tst r0,r0 /* (src ^ dst) & 3 */
bf/s ov_word_align
ov_longword_align:
tst REG_LEN,REG_LEN /* if ( len==0 ) return; */
bt/s bcopy_return
mov REG_SRC,r0
tst #1,r0 /* if ( src & 1 ) */
bt 1f
add #-1,REG_SRC /* *--dst = *--src; */
mov.b @REG_SRC,r0
mov.b r0,@-REG_DST
add #-1,REG_LEN
1:
mov #1,r0
cmp/hi r0,REG_LEN /* if ( (len > 1) && */
bf/s 1f
mov REG_SRC,r0
tst #2,r0 /* (src & 2) { */
bt 1f
add #-2,REG_SRC /* *--((unsigned short*)dst) = *--((unsigned short*)src); */
mov.w @REG_SRC,r0
add #-2,REG_LEN /* len -= 2; */
mov.w r0,@-REG_DST /* } */
1:
mov #3,r1
cmp/hi r1,REG_LEN /* while ( len > 3 ) { */
bf/s ov_no_align_delay
tst REG_LEN,REG_LEN
2:
add #-4,REG_SRC
mov.l @REG_SRC,r0 /* *((unsigned long*)dst)++ = *((unsigned long*)src)++; */
add #-4,REG_LEN /* len -= 4; */
cmp/hi r1,REG_LEN
bt/s 2b
mov.l r0,@-REG_DST /* } */
bra ov_no_align_delay
tst REG_LEN,REG_LEN
ov_word_align:
mov r1,r0
tst #1,r0
bf/s ov_no_align_delay
tst REG_LEN,REG_LEN /* if ( len == 0 ) return; */
bt bcopy_return
mov REG_SRC,r0 /* if ( src & 1 ) */
tst #1,r0
bt 1f
add #-1,REG_SRC
mov.b @REG_SRC,r0 /* *--dst = *--src; */
add #-1,REG_LEN
mov.b r0,@-REG_DST
1:
mov #1,r1
cmp/hi r1,REG_LEN /* while ( len > 1 ) { */
bf/s ov_no_align_delay
tst REG_LEN,REG_LEN
2:
add #-2,REG_SRC
mov.w @REG_SRC,r0 /* *--((unsigned short*)dst) = *--((unsigned short*)src); */
add #-2,REG_LEN /* len -= 2; */
cmp/hi r1,REG_LEN
bt/s 2b
mov.w r0,@-REG_DST /* } */
ov_no_align:
tst REG_LEN,REG_LEN /* while ( len!= ) { */
ov_no_align_delay:
bt 9f
1:
add #-1,REG_SRC
mov.b @REG_SRC,r0 /* *--dst = *--src; */
add #-1,REG_LEN /* len--; */
tst REG_LEN,REG_LEN
bf/s 1b
mov.b r0,@-REG_DST /* } */
9:
rts
#ifdef REG_DST0
mov REG_DST0,r0
#else
nop
#endif
|
0xffea/MINIX3
| 2,519
|
common/lib/libc/arch/sh3/string/ffs.S
|
/* $NetBSD: ffs.S,v 1.2 2008/04/28 20:22:52 martin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by ITOH Yasufumi.
*
* 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>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: ffs.S,v 1.2 2008/04/28 20:22:52 martin Exp $")
#endif
/*
* ffs - find first bit set
*
* This code makes use of ``test 8bit'' and ``shift 8bit'' instructions.
* The remaining 8bit is tested in every 2bit.
*/
ENTRY(ffs)
mov r4,r0 ! using r0 specific instructions
tst #0xff,r0
bf/s L8bit
mov #0+1,r1 ! ret = 1..8
tst r0,r0 ! ffs(0) is 0
bt Lzero ! testing here to accelerate ret=1..8 cases
shlr8 r0
tst #0xff,r0
bf/s L8bit
mov #8+1,r1 ! ret = 9..16
shlr8 r0
tst #0xff,r0
bf/s L8bit
mov #16+1,r1 ! ret = 17..24
shlr8 r0
mov #24+1,r1 ! ret = 25..32
L8bit:
tst #0x0f,r0
bt 4f
tst #0x03,r0
bt 2f
tst #0x01,r0 ! not bit 0 -> T
mov #0,r0
rts
addc r1,r0 ! 0 + r1 + T -> r0
2: tst #0x04,r0
mov #2,r0
rts
addc r1,r0
4: tst #0x30,r0
bt 6f
tst #0x10,r0
mov #4,r0
rts
addc r1,r0
6: tst #0x40,r0
mov #6,r0
rts
addc r1,r0
Lzero: rts
nop
|
0xffea/MINIX3
| 6,961
|
common/lib/libc/arch/sh3/string/memset.S
|
/* $NetBSD: memset.S,v 1.2 2008/02/16 17:37:13 apb Exp $ */
/*-
* Copyright (c) 2002 SHIMIZU Ryo. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: memset.S,v 1.2 2008/02/16 17:37:13 apb Exp $")
#endif
#define REG_PTR r0
#define REG_TMP1 r1
#ifdef BZERO
# define REG_C r2
# define REG_DST r4
# define REG_LEN r5
#else
# define REG_DST0 r3
# define REG_DST r4
# define REG_C r5
# define REG_LEN r6
#endif
#ifdef BZERO
ENTRY(bzero)
#else
ENTRY(memset)
mov REG_DST,REG_DST0 /* for return value */
#endif
/* small amount to fill ? */
mov #28,REG_TMP1
cmp/hs REG_TMP1,REG_LEN /* if (len >= 28) goto large; */
bt/s large
mov #12,REG_TMP1 /* if (len >= 12) goto small; */
cmp/hs REG_TMP1,REG_LEN
bt/s small
#ifdef BZERO
mov #0,REG_C
#endif
/* very little fill (0 ~ 11 bytes) */
tst REG_LEN,REG_LEN
add REG_DST,REG_LEN
bt/s done
add #1,REG_DST
/* unroll 4 loops */
cmp/eq REG_DST,REG_LEN
1: mov.b REG_C,@-REG_LEN
bt/s done
cmp/eq REG_DST,REG_LEN
mov.b REG_C,@-REG_LEN
bt/s done
cmp/eq REG_DST,REG_LEN
mov.b REG_C,@-REG_LEN
bt/s done
cmp/eq REG_DST,REG_LEN
mov.b REG_C,@-REG_LEN
bf/s 1b
cmp/eq REG_DST,REG_LEN
done:
#ifdef BZERO
rts
nop
#else
rts
mov REG_DST0,r0
#endif
small:
mov REG_DST,r0
tst #1,r0
bt/s small_aligned
mov REG_DST,REG_TMP1
shll REG_LEN
mova 1f,r0 /* 1f must be 4bytes aligned! */
add #16,REG_TMP1 /* REG_TMP1 = dst+16; */
sub REG_LEN,r0
jmp @r0
mov REG_C,r0
.align 2
mov.b r0,@(15,REG_TMP1)
mov.b r0,@(14,REG_TMP1)
mov.b r0,@(13,REG_TMP1)
mov.b r0,@(12,REG_TMP1)
mov.b r0,@(11,REG_TMP1)
mov.b r0,@(10,REG_TMP1)
mov.b r0,@(9,REG_TMP1)
mov.b r0,@(8,REG_TMP1)
mov.b r0,@(7,REG_TMP1)
mov.b r0,@(6,REG_TMP1)
mov.b r0,@(5,REG_TMP1)
mov.b r0,@(4,REG_TMP1)
mov.b r0,@(3,REG_TMP1)
mov.b r0,@(2,REG_TMP1)
mov.b r0,@(1,REG_TMP1)
mov.b r0,@REG_TMP1
mov.b r0,@(15,REG_DST)
mov.b r0,@(14,REG_DST)
mov.b r0,@(13,REG_DST)
mov.b r0,@(12,REG_DST)
mov.b r0,@(11,REG_DST)
mov.b r0,@(10,REG_DST)
mov.b r0,@(9,REG_DST)
mov.b r0,@(8,REG_DST)
mov.b r0,@(7,REG_DST)
mov.b r0,@(6,REG_DST)
mov.b r0,@(5,REG_DST)
mov.b r0,@(4,REG_DST)
mov.b r0,@(3,REG_DST)
mov.b r0,@(2,REG_DST)
mov.b r0,@(1,REG_DST)
#ifdef BZERO
rts
1: mov.b r0,@REG_DST
#else
mov.b r0,@REG_DST
1: rts
mov REG_DST0,r0
#endif
/* 2 bytes aligned small fill */
small_aligned:
#ifndef BZERO
extu.b REG_C,REG_TMP1 /* REG_C = ??????xx, REG_TMP1 = ????00xx */
shll8 REG_C /* REG_C = ????xx00, REG_TMP1 = ????00xx */
or REG_TMP1,REG_C /* REG_C = ????xxxx */
#endif
mov REG_LEN,r0
tst #1,r0 /* len is aligned? */
bt/s 1f
add #-1,r0
mov.b REG_C,@(r0,REG_DST) /* fill last a byte */
mov r0,REG_LEN
1:
mova 1f,r0 /* 1f must be 4bytes aligned! */
sub REG_LEN,r0
jmp @r0
mov REG_C,r0
.align 2
mov.w r0,@(30,REG_DST)
mov.w r0,@(28,REG_DST)
mov.w r0,@(26,REG_DST)
mov.w r0,@(24,REG_DST)
mov.w r0,@(22,REG_DST)
mov.w r0,@(20,REG_DST)
mov.w r0,@(18,REG_DST)
mov.w r0,@(16,REG_DST)
mov.w r0,@(14,REG_DST)
mov.w r0,@(12,REG_DST)
mov.w r0,@(10,REG_DST)
mov.w r0,@(8,REG_DST)
mov.w r0,@(6,REG_DST)
mov.w r0,@(4,REG_DST)
mov.w r0,@(2,REG_DST)
#ifdef BZERO
rts
1: mov.w r0,@REG_DST
#else
mov.w r0,@REG_DST
1: rts
mov REG_DST0,r0
#endif
.align 2
large:
#ifdef BZERO
mov #0,REG_C
#else
extu.b REG_C,REG_TMP1 /* REG_C = ??????xx, REG_TMP1 = ????00xx */
shll8 REG_C /* REG_C = ????xx00, REG_TMP1 = ????00xx */
or REG_C,REG_TMP1 /* REG_C = ????xx00, REG_TMP1 = ????xxxx */
swap.w REG_TMP1,REG_C /* REG_C = xxxx????, REG_TMP1 = ????xxxx */
xtrct REG_TMP1,REG_C /* REG_C = xxxxxxxx */
#endif
mov #3,REG_TMP1
tst REG_TMP1,REG_DST
mov REG_DST,REG_PTR
bf/s unaligned_dst
add REG_LEN,REG_PTR /* REG_PTR = dst + len; */
tst REG_TMP1,REG_LEN
bf/s unaligned_len
aligned:
/* fill 32*n bytes */
mov #32,REG_TMP1
cmp/hi REG_LEN,REG_TMP1
bt 9f
.align 2
1: sub REG_TMP1,REG_PTR
mov.l REG_C,@REG_PTR
sub REG_TMP1,REG_LEN
mov.l REG_C,@(4,REG_PTR)
cmp/hi REG_LEN,REG_TMP1
mov.l REG_C,@(8,REG_PTR)
mov.l REG_C,@(12,REG_PTR)
mov.l REG_C,@(16,REG_PTR)
mov.l REG_C,@(20,REG_PTR)
mov.l REG_C,@(24,REG_PTR)
bf/s 1b
mov.l REG_C,@(28,REG_PTR)
9:
/* fill left 4*n bytes */
cmp/eq REG_DST,REG_PTR
bt 9f
add #4,REG_DST
cmp/eq REG_DST,REG_PTR
1: mov.l REG_C,@-REG_PTR
bt/s 9f
cmp/eq REG_DST,REG_PTR
mov.l REG_C,@-REG_PTR
bt/s 9f
cmp/eq REG_DST,REG_PTR
mov.l REG_C,@-REG_PTR
bt/s 9f
cmp/eq REG_DST,REG_PTR
mov.l REG_C,@-REG_PTR
bf/s 1b
cmp/eq REG_DST,REG_PTR
9:
#ifdef BZERO
rts
nop
#else
rts
mov REG_DST0,r0
#endif
unaligned_dst:
mov #1,REG_TMP1
tst REG_TMP1,REG_DST /* if (dst & 1) { */
add #1,REG_TMP1
bt/s 2f
tst REG_TMP1,REG_DST
mov.b REG_C,@REG_DST /* *dst++ = c; */
add #1,REG_DST
tst REG_TMP1,REG_DST
2: /* } */
/* if (dst & 2) { */
bt 4f
mov.w REG_C,@REG_DST /* *(uint16_t*)dst++ = c; */
add #2,REG_DST
4: /* } */
tst #3,REG_PTR /* if (ptr & 3) { */
bt/s 4f /* */
unaligned_len:
tst #1,REG_PTR /* if (ptr & 1) { */
bt/s 2f
tst #2,REG_PTR
mov.b REG_C,@-REG_PTR /* --ptr = c; */
2: /* } */
/* if (ptr & 2) { */
bt 4f
mov.w REG_C,@-REG_PTR /* *--(uint16_t*)ptr = c; */
4: /* } */
/* } */
mov REG_PTR,REG_LEN
bra aligned
sub REG_DST,REG_LEN
|
0xffea/MINIX3
| 1,852
|
common/lib/libc/arch/hppa/atomic/atomic_cas_up.S
|
/* $NetBSD: atomic_cas_up.S,v 1.2 2011/01/16 12:07:26 skrll Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Nick Hudson
*
* 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/ras.h>
#include <machine/asm.h>
LEAF_ENTRY_NOPROFILE(_atomic_cas_up)
.hidden _C_LABEL(_atomic_cas_up)
RAS_START_ASM_HIDDEN(_atomic_cas)
ldw 0(%arg0), %ret0
comb,<>,n %arg1, %ret0, 1f
stw %arg2, 0(%arg0)
RAS_END_ASM_HIDDEN(_atomic_cas)
1:
bv,n %r0(%rp)
EXIT(_atomic_cas_up)
|
0xffea/MINIX3
| 2,270
|
common/lib/libc/arch/hppa/atomic/membar_ops.S
|
/* $NetBSD: membar_ops.S,v 1.1 2011/01/17 07:40:21 skrll Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe, and by Andrew Doran.
*
* 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"
RCSID("$NetBSD: membar_ops.S,v 1.1 2011/01/17 07:40:21 skrll Exp $")
.text
LEAF_ENTRY(_membar_consumer)
sync
nop
nop
nop
nop
nop
bv %r0(%rp)
nop
EXIT(_membar_consumer)
LEAF_ENTRY(_membar_producer)
sync
nop
nop
nop
nop
nop
bv %r0(%rp)
nop
EXIT(_membar_producer)
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer)
ATOMIC_OP_ALIAS(membar_enter,_membar_consumer)
STRONG_ALIAS(_membar_enter,_membar_consumer)
ATOMIC_OP_ALIAS(membar_exit,_membar_producer)
STRONG_ALIAS(_membar_exit,_membar_producer)
ATOMIC_OP_ALIAS(membar_sync,_membar_producer)
STRONG_ALIAS(_membar_sync,_membar_producer)
|
0xffea/MINIX3
| 1,978
|
common/lib/libc/arch/powerpc64/atomic/atomic_swap.S
|
/* $NetBSD: atomic_swap.S,v 1.5 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_swap.S"
.text
ENTRY(_atomic_swap_64)
1: ldarx %r10,0,%r3
stdcx. %r4,0,%r3
bne- 1b
mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64)
ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64)
|
0xffea/MINIX3
| 2,151
|
common/lib/libc/arch/powerpc64/atomic/atomic_and.S
|
/* $NetBSD: atomic_and.S,v 1.5 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_and.S"
.text
ENTRY(_atomic_and_64)
1: ldarx %r10,0,%r3
and %r10,%r10,%r4
stdcx. %r10,0,%r3
bne- 1b
blr
ATOMIC_OP_ALIAS(atomic_and_64,_atomic_and_64)
ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_64)
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64)
ENTRY(_atomic_and_64_nv)
1: ldarx %r10,0,%r3
and %r10,%r10,%r4
stdcx. %r10,0,%r3
bne- 1b
mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_64_nv)
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_64_nv)
|
0xffea/MINIX3
| 2,345
|
common/lib/libc/arch/powerpc64/atomic/atomic_inc.S
|
/* $NetBSD: atomic_inc.S,v 1.5 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_inc.S"
.text
ENTRY(_atomic_inc_64)
1: ldarx %r10,0,%r3
addi %r10,%r10,1
stdcx. %r10,0,%r3
bne- 1b
blr
ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)
ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_64)
ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_64)
ENTRY(_atomic_inc_64_nv)
1: ldarx %r10,0,%r3
addi %r10,%r10,1
stdcx. %r10,0,%r3
bne- 1b
mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_64_nv)
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_64_nv)
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_64_nv)
|
0xffea/MINIX3
| 2,347
|
common/lib/libc/arch/powerpc64/atomic/atomic_dec.S
|
/* $NetBSD: atomic_dec.S,v 1.5 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_dec.S"
.text
ENTRY(_atomic_dec_64)
1: ldarx %r10,0,%r3
addi %r10,%r10,-1
stdcx. %r10,0,%r3
bne- 1b
blr
ATOMIC_OP_ALIAS(atomic_dec_64,_atomic_dec_64)
ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_64)
ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_64)
ENTRY(_atomic_dec_64_nv)
1: ldarx %r10,0,%r3
addi %r10,%r10,-1
stdcx. %r10,0,%r3
bne- 1b
mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_64_nv)
|
0xffea/MINIX3
| 2,343
|
common/lib/libc/arch/powerpc64/atomic/atomic_add.S
|
/* $NetBSD: atomic_add.S,v 1.5 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_add.S"
.text
ENTRY(_atomic_add_64)
1: ldarx %r10,0,%r3
add %r10,%r10,%r4
stdcx. %r10,0,%r3
bne- 1b
blr
ATOMIC_OP_ALIAS(atomic_add_64,_atomic_add_64)
ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_64)
STRONG_ALIAS(_atomic_add_long,_atomic_add_64)
ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_64)
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64)
ENTRY(_atomic_add_64_nv)
1: ldarx %r10,0,%r3
add %r10,%r10,%r4
stdcx. %r10,0,%r3
bne- 1b
mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_64_nv)
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv)
ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_64_nv)
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv)
|
0xffea/MINIX3
| 2,295
|
common/lib/libc/arch/powerpc64/atomic/atomic_cas.S
|
/* $NetBSD: atomic_cas.S,v 1.6 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_cas.S"
.text
ENTRY(_atomic_cas_64)
1: ldarx %r10,0,%r3
cmpd %r10,%r4
bne- 2f
stdcx. %r5,0,%r3
bne- 1b
2: mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64)
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64)
|
0xffea/MINIX3
| 2,133
|
common/lib/libc/arch/powerpc64/atomic/atomic_or.S
|
/* $NetBSD: atomic_or.S,v 1.5 2009/03/08 12:08:19 he Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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"
#include "../../powerpc/atomic/atomic_or.S"
.text
ENTRY(_atomic_or_64)
1: ldarx %r10,0,%r3
or %r10,%r10,%r4
stdcx. %r10,0,%r3
bne- 1b
blr
ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64)
ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_64)
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_64)
ENTRY(_atomic_or_64_nv)
1: ldarx %r10,0,%r3
or %r10,%r10,%r4
stdcx. %r10,0,%r3
bne- 1b
mr %r3,%r10
blr
ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_64_nv)
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_64_nv)
|
0xffea/MINIX3
| 2,190
|
common/lib/libc/arch/sparc/net/htonl.S
|
/* $NetBSD: htonl.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: htonl.s,v 1.1 92/06/25 12:47:05 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)htonl.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: htonl.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* netorder = htonl(hostorder) */
ENTRY(htonl)
retl
nop
|
0xffea/MINIX3
| 2,187
|
common/lib/libc/arch/sparc/net/ntohl.S
|
/* $NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: ntohl.s,v 1.1 92/06/25 12:47:06 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)ntohl.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: ntohl.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* hostorder = ntohl(netorder) */
ENTRY(ntohl)
retl
nop
|
0xffea/MINIX3
| 2,231
|
common/lib/libc/arch/sparc/net/htons.S
|
/* $NetBSD: htons.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: htons.s,v 1.1 92/06/25 12:47:05 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)htons.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: htons.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* netorder = htons(hostorder) */
ENTRY(htons)
sethi %hi(0xffff0000), %o1
retl
andn %o0, %o1, %o0
|
0xffea/MINIX3
| 2,232
|
common/lib/libc/arch/sparc/net/ntohs.S
|
/* $NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: ntohs.s,v 1.1 92/06/25 12:47:07 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)ntohs.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: ntohs.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/* hostorder = ntohs(netorder) */
ENTRY(ntohs)
sethi %hi(0xffff0000), %o1
retl
andn %o0, %o1, %o0
|
0xffea/MINIX3
| 5,066
|
common/lib/libc/arch/sparc/gen/mul.S
|
/* $NetBSD: mul.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: mul.s,v 1.5 92/06/25 13:24:03 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)mul.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: mul.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/*
* Signed multiply, from Appendix E of the Sparc Version 8
* Architecture Manual.
*
* Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the upper 32 bits of
* the 64-bit product).
*
* This code optimizes short (less than 13-bit) multiplies.
*/
FUNC(.mul)
mov %o0, %y ! multiplier -> Y
andncc %o0, 0xfff, %g0 ! test bits 12..31
be Lmul_shortway ! if zero, can do it the short way
andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
/*
* Long multiply. 32 steps, followed by a final shift step.
*/
mulscc %o4, %o1, %o4 ! 1
mulscc %o4, %o1, %o4 ! 2
mulscc %o4, %o1, %o4 ! 3
mulscc %o4, %o1, %o4 ! 4
mulscc %o4, %o1, %o4 ! 5
mulscc %o4, %o1, %o4 ! 6
mulscc %o4, %o1, %o4 ! 7
mulscc %o4, %o1, %o4 ! 8
mulscc %o4, %o1, %o4 ! 9
mulscc %o4, %o1, %o4 ! 10
mulscc %o4, %o1, %o4 ! 11
mulscc %o4, %o1, %o4 ! 12
mulscc %o4, %o1, %o4 ! 13
mulscc %o4, %o1, %o4 ! 14
mulscc %o4, %o1, %o4 ! 15
mulscc %o4, %o1, %o4 ! 16
mulscc %o4, %o1, %o4 ! 17
mulscc %o4, %o1, %o4 ! 18
mulscc %o4, %o1, %o4 ! 19
mulscc %o4, %o1, %o4 ! 20
mulscc %o4, %o1, %o4 ! 21
mulscc %o4, %o1, %o4 ! 22
mulscc %o4, %o1, %o4 ! 23
mulscc %o4, %o1, %o4 ! 24
mulscc %o4, %o1, %o4 ! 25
mulscc %o4, %o1, %o4 ! 26
mulscc %o4, %o1, %o4 ! 27
mulscc %o4, %o1, %o4 ! 28
mulscc %o4, %o1, %o4 ! 29
mulscc %o4, %o1, %o4 ! 30
mulscc %o4, %o1, %o4 ! 31
mulscc %o4, %o1, %o4 ! 32
mulscc %o4, %g0, %o4 ! final shift
! If %o0 was negative, the result is
! (%o0 * %o1) + (%o1 << 32))
! We fix that here.
tst %o0
bge 1f
rd %y, %o0
! %o0 was indeed negative; fix upper 32 bits of result by subtracting
! %o1 (i.e., return %o4 - %o1 in %o1).
retl
sub %o4, %o1, %o1
1:
retl
mov %o4, %o1
Lmul_shortway:
/*
* Short multiply. 12 steps, followed by a final shift step.
* The resulting bits are off by 12 and (32-12) = 20 bit positions,
* but there is no problem with %o0 being negative (unlike above).
*/
mulscc %o4, %o1, %o4 ! 1
mulscc %o4, %o1, %o4 ! 2
mulscc %o4, %o1, %o4 ! 3
mulscc %o4, %o1, %o4 ! 4
mulscc %o4, %o1, %o4 ! 5
mulscc %o4, %o1, %o4 ! 6
mulscc %o4, %o1, %o4 ! 7
mulscc %o4, %o1, %o4 ! 8
mulscc %o4, %o1, %o4 ! 9
mulscc %o4, %o1, %o4 ! 10
mulscc %o4, %o1, %o4 ! 11
mulscc %o4, %o1, %o4 ! 12
mulscc %o4, %g0, %o4 ! final shift
/*
* %o4 has 20 of the bits that should be in the low part of the
* result; %y has the bottom 12 (as %y's top 12). That is:
*
* %o4 %y
* +----------------+----------------+
* | -12- | -20- | -12- | -20- |
* +------(---------+------)---------+
* --hi-- ----low-part----
*
* The upper 12 bits of %o4 should be sign-extended to form the
* high part of the product (i.e., highpart = %o4 >> 20).
*/
rd %y, %o5
sll %o4, 12, %o0 ! shift middle bits left 12
srl %o5, 20, %o5 ! shift low bits right 20, zero fill at left
or %o5, %o0, %o0 ! construct low part of result
retl
sra %o4, 20, %o1 ! ... and extract high part of result
|
0xffea/MINIX3
| 2,702
|
common/lib/libc/arch/sparc/gen/saveregs.S
|
/* $NetBSD: saveregs.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: saveregs.s,v 1.1 91/07/06 17:22:33 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
RCSID("$NetBSD: saveregs.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif /* LIBC_SCCS and not lint */
/*
* Save register arguments in caller's `arg dump' area, so that
* stdarg functions work.
*
* This really should be done with a pointer to the arg dump area;
* our caller should allocate that area, not our caller's caller.
* But then, they did not let me invent the calling sequence....
*
* We assume the caller has executed a `save' instruction.
*/
ENTRY(__builtin_saveregs)
st %i0, [%fp + 0x44] ! fr->fr_argd[0]
st %i1, [%fp + 0x48] ! fr->fr_argd[1]
st %i2, [%fp + 0x4c] ! fr->fr_argd[2]
st %i3, [%fp + 0x50] ! fr->fr_argd[3]
st %i4, [%fp + 0x54] ! fr->fr_argd[4]
retl
st %i5, [%fp + 0x58] ! fr->fr_argd[5]
|
0xffea/MINIX3
| 6,414
|
common/lib/libc/arch/sparc/gen/umul.S
|
/* $NetBSD: umul.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: umul.s,v 1.4 92/06/25 13:24:05 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)umul.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: umul.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/*
* Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the
* upper 32 bits of the 64-bit product).
*
* This code optimizes short (less than 13-bit) multiplies. Short
* multiplies require 25 instruction cycles, and long ones require
* 45 instruction cycles.
*
* On return, overflow has occurred (%o1 is not zero) if and only if
* the Z condition code is clear, allowing, e.g., the following:
*
* call .umul
* nop
* bnz overflow (or tnz)
*/
FUNC(.umul)
or %o0, %o1, %o4
mov %o0, %y ! multiplier -> Y
andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args
be Lmul_shortway ! if zero, can do it the short way
andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
/*
* Long multiply. 32 steps, followed by a final shift step.
*/
mulscc %o4, %o1, %o4 ! 1
mulscc %o4, %o1, %o4 ! 2
mulscc %o4, %o1, %o4 ! 3
mulscc %o4, %o1, %o4 ! 4
mulscc %o4, %o1, %o4 ! 5
mulscc %o4, %o1, %o4 ! 6
mulscc %o4, %o1, %o4 ! 7
mulscc %o4, %o1, %o4 ! 8
mulscc %o4, %o1, %o4 ! 9
mulscc %o4, %o1, %o4 ! 10
mulscc %o4, %o1, %o4 ! 11
mulscc %o4, %o1, %o4 ! 12
mulscc %o4, %o1, %o4 ! 13
mulscc %o4, %o1, %o4 ! 14
mulscc %o4, %o1, %o4 ! 15
mulscc %o4, %o1, %o4 ! 16
mulscc %o4, %o1, %o4 ! 17
mulscc %o4, %o1, %o4 ! 18
mulscc %o4, %o1, %o4 ! 19
mulscc %o4, %o1, %o4 ! 20
mulscc %o4, %o1, %o4 ! 21
mulscc %o4, %o1, %o4 ! 22
mulscc %o4, %o1, %o4 ! 23
mulscc %o4, %o1, %o4 ! 24
mulscc %o4, %o1, %o4 ! 25
mulscc %o4, %o1, %o4 ! 26
mulscc %o4, %o1, %o4 ! 27
mulscc %o4, %o1, %o4 ! 28
mulscc %o4, %o1, %o4 ! 29
mulscc %o4, %o1, %o4 ! 30
mulscc %o4, %o1, %o4 ! 31
mulscc %o4, %o1, %o4 ! 32
mulscc %o4, %g0, %o4 ! final shift
/*
* Normally, with the shift-and-add approach, if both numbers are
* positive you get the correct result. WIth 32-bit two's-complement
* numbers, -x is represented as
*
* x 32
* ( 2 - ------ ) mod 2 * 2
* 32
* 2
*
* (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s,
* we can treat this as if the radix point were just to the left
* of the sign bit (multiply by 2^32), and get
*
* -x = (2 - x) mod 2
*
* Then, ignoring the `mod 2's for convenience:
*
* x * y = xy
* -x * y = 2y - xy
* x * -y = 2x - xy
* -x * -y = 4 - 2x - 2y + xy
*
* For signed multiplies, we subtract (x << 32) from the partial
* product to fix this problem for negative multipliers (see mul.s).
* Because of the way the shift into the partial product is calculated
* (N xor V), this term is automatically removed for the multiplicand,
* so we don't have to adjust.
*
* But for unsigned multiplies, the high order bit wasn't a sign bit,
* and the correction is wrong. So for unsigned multiplies where the
* high order bit is one, we end up with xy - (y << 32). To fix it
* we add y << 32.
*/
tst %o1
bl,a 1f ! if %o1 < 0 (high order bit = 1),
add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half)
1: rd %y, %o0 ! get lower half of product
retl
addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0
Lmul_shortway:
/*
* Short multiply. 12 steps, followed by a final shift step.
* The resulting bits are off by 12 and (32-12) = 20 bit positions,
* but there is no problem with %o0 being negative (unlike above),
* and overflow is impossible (the answer is at most 24 bits long).
*/
mulscc %o4, %o1, %o4 ! 1
mulscc %o4, %o1, %o4 ! 2
mulscc %o4, %o1, %o4 ! 3
mulscc %o4, %o1, %o4 ! 4
mulscc %o4, %o1, %o4 ! 5
mulscc %o4, %o1, %o4 ! 6
mulscc %o4, %o1, %o4 ! 7
mulscc %o4, %o1, %o4 ! 8
mulscc %o4, %o1, %o4 ! 9
mulscc %o4, %o1, %o4 ! 10
mulscc %o4, %o1, %o4 ! 11
mulscc %o4, %o1, %o4 ! 12
mulscc %o4, %g0, %o4 ! final shift
/*
* %o4 has 20 of the bits that should be in the result; %y has
* the bottom 12 (as %y's top 12). That is:
*
* %o4 %y
* +----------------+----------------+
* | -12- | -20- | -12- | -20- |
* +------(---------+------)---------+
* -----result-----
*
* The 12 bits of %o4 left of the `result' area are all zero;
* in fact, all top 20 bits of %o4 are zero.
*/
rd %y, %o5
sll %o4, 12, %o0 ! shift middle bits left 12
srl %o5, 20, %o5 ! shift low bits right 20
or %o5, %o0, %o0
retl
addcc %g0, %g0, %o1 ! %o1 = zero, and set Z
|
0xffea/MINIX3
| 2,164
|
common/lib/libc/arch/sparc/atomic/membar_ops.S
|
/* $NetBSD: membar_ops.S,v 1.4 2008/05/25 15:56:12 chs Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe, and by Andrew Doran.
*
* 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"
.text
/* These assume Total Store Order (TSO) */
ENTRY(_membar_producer)
retl
nop
ENTRY(_membar_consumer)
add %sp, -112, %sp
st %g0, [%sp+100]
retl
sub %sp, -112, %sp
ATOMIC_OP_ALIAS(membar_producer,_membar_producer)
ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer)
ATOMIC_OP_ALIAS(membar_enter,_membar_consumer)
STRONG_ALIAS(_membar_enter,_membar_consumer)
ATOMIC_OP_ALIAS(membar_exit,_membar_consumer)
STRONG_ALIAS(_membar_exit,_membar_consumer)
ATOMIC_OP_ALIAS(membar_sync,_membar_consumer)
STRONG_ALIAS(_membar_sync,_membar_consumer)
|
0xffea/MINIX3
| 4,439
|
common/lib/libc/arch/sparc/atomic/atomic_cas.S
|
/* $NetBSD: atomic_cas.S,v 1.10 2009/03/13 16:40:22 nakayama Exp $ */
/*-
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran and Jason R. Thorpe.
*
* 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/param.h>
#include "atomic_op_asm.h"
#if defined(_HARDKERNEL)
#include <machine/psl.h>
#include "opt_multiprocessor.h"
#define DISABLE_INTERRUPTS \
rd %psr, %o4 /* disable interrupts */;\
or %o4, PSR_PIL, %o5 ;\
wr %o5, 0, %psr ;\
nop ;\
nop ;\
nop
#define RESTORE_INTERRUPTS \
wr %o4, 0, %psr /* enable interrupts */ ;\
nop ;\
nop ;\
nop
#else /* _HARDKERNEL */
#define MULTIPROCESSOR 1
#define DISABLE_INTERRUPTS /* nothing */
#define RESTORE_INTERRUPTS /* nothing */
#endif /* _HARDKERNEL */
#if defined(MULTIPROCESSOR)
.section .bss
.align 1024
OTYPE(_C_LABEL(_atomic_cas_locktab))
_C_LABEL(_atomic_cas_locktab):
.space 1024
#define ACQUIRE_INTERLOCK \
DISABLE_INTERRUPTS ;\
srl %o0, 3, %o5 /* get lock address */ ;\
and %o5, 1023, %o5 ;\
sethi %hi(_C_LABEL(_atomic_cas_locktab)), %o3 ;\
add %o5, %o3, %o5 ;\
;\
/* %o5 has interlock address */ ;\
;\
1: ldstub [%o5], %o3 /* acquire lock */ ;\
tst %o3 ;\
bz,a 2f ;\
nop ;\
nop ;\
nop ;\
b,a 1b /* spin */ ;\
nop ;\
/* We now hold the interlock */ ;\
2:
#define RELEASE_INTERLOCK \
stb %g0, [%o5] /* release interlock */ ;\
RESTORE_INTERRUPTS
#else /* ! MULTIPROCESSOR */
#define ACQUIRE_INTERLOCK DISABLE_INTERRUPTS
#define RELEASE_INTERLOCK RESTORE_INTERRUPTS
#endif /* MULTIPROCESSOR */
.text
/*
* The v7 and v8 SPARC doesn't have compare-and-swap, so we block interrupts
* and use an interlock.
*
* XXX On single CPU systems, this should use a restartable sequence:
* XXX there we don't need the overhead of interlocking.
*
* XXX NOTE! The interlock trick only works if EVERYTHING writes to
* XXX the memory cell through this code path!
*/
ENTRY(_atomic_cas_32)
ACQUIRE_INTERLOCK
! %o4 has saved PSR value
! %o5 has interlock address
ld [%o0], %o3 ! get old value
cmp %o1, %o3 ! old == new?
beq,a 3f ! yes, do the store
st %o2, [%o0] ! (in the delay slot)
3: RELEASE_INTERLOCK
retl
mov %o3, %o0 ! return old value
ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32)
ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32)
|
0xffea/MINIX3
| 4,211
|
common/lib/libc/arch/sparc/string/ffs.S
|
/* $NetBSD: ffs.S,v 1.2 2009/12/19 19:09:48 pooka Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: ffs.s,v 1.3 92/07/07 00:23:57 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#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 $")
#endif
#endif /* LIBC_SCCS and not lint */
/*
* ffs returns the number of the rightmost bit set in its argument,
* i.e., the lowest value such that (x & (ffs(x) - 1)) is nonzero.
* If no bits are set, ffs returns 0.
*
* We use a table lookup on each byte.
*
* In each section below, %o1 is the current byte (0, 1, 2, or 3).
* The last byte is handled specially: for the first three,
* if that byte is nonzero, we return the table value
* (plus 0, 8, or 16 for the byte number), but for the last
* one, we just return the table value plus 24. This means
* that ffstab[0] must be -24 so that ffs(0) will return 0.
*/
ENTRY(ffs)
#ifdef PIC
PICCY_SET(ffstab, %o2, %o3)
#else
set ffstab, %o2
#endif
andcc %o0, 0xff, %o1 ! get low byte
be,a 1f ! try again if 0
srl %o0, 8, %o0 ! delay slot, get ready for next byte
retl ! return ffstab[%o1]
ldsb [%o2 + %o1], %o0
1:
andcc %o0, 0xff, %o1 ! byte 1 like byte 0...
be,a 2f
srl %o0, 8, %o0 ! (use delay to prepare for byte 2)
ldsb [%o2 + %o1], %o0
retl ! return ffstab[%o1] + 8
add %o0, 8, %o0
2:
andcc %o0, 0xff, %o1
be,a 3f
srl %o0, 8, %o0 ! (prepare for byte 3)
ldsb [%o2 + %o1], %o0
retl ! return ffstab[%o1] + 16
add %o0, 16, %o0
3: ! just return ffstab[%o0] + 24
ldsb [%o2 + %o0], %o0
retl
add %o0, 24, %o0
ffstab:
.byte -24,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 00-0f */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 10-1f */
.byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 20-2f */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 30-3f */
.byte 7,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 40-4f */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 50-5f */
.byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 60-6f */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 70-7f */
.byte 8,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 80-8f */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* 10-9f */
.byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* a0-af */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* b0-bf */
.byte 7,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* c0-cf */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* d0-df */
.byte 6,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* e0-ef */
.byte 5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1 /* f0-ff */
|
0xffea/MINIX3
| 5,199
|
common/lib/libc/arch/sparc/string/bzero.S
|
/* $NetBSD: bzero.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: bzero.s,v 1.1 92/06/25 12:52:46 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)bzero.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: bzero.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
/*
* We should unroll the loop, but at the moment this would
* gain nothing since the `std' instructions are what limits us.
*/
#ifdef MEMSET
/*
* void *
* memset(void *addr, int pattern, size_t len)
*/
ENTRY(memset)
! %o0 = addr, %o1 = pattern, %o2 = len
/*
* Expand the byte pattern to fill 64 bits in an even-aligned
* register pair; shuffle arguments to match those of bzero.
*/
and %o1, 0xff, %o3
mov %o2, %o1 ! shuffle argument
sll %o3, 8, %o2
or %o2, %o3, %o2
mov %o0, %g1 ! save original pointer
sll %o2, 16, %o3
or %o2, %o3, %o2
! Optimize a common case: addr and len are both multiples of 8.
or %o0, %o1, %o5
btst 7, %o5 ! ((addr | len) & 7) != 0?
bnz 1f ! if so, cannot optimize
mov %o2, %o3 ! in any case, complete pat expansion
#else
/*
* void
* bzero(void *addr, size_t len)
*/
ENTRY(bzero)
! %o0 = addr, %o1 = len
clr %o2
! Optimize a common case: addr and len are both multiples of 8.
or %o0, %o1, %o5
btst 7, %o5 ! ((addr | len) & 7) != 0?
bnz 1f ! if so, cannot optimize
clr %o3 ! in any case, we want o3=0
#endif
/* `Good' operands, can just store doubles. */
0:
deccc 8, %o1 ! while ((len -= 8) >= 0)
bge,a 0b
std %o2, [%o0 + %o1] ! *(quad *)(addr + len) = 0;
retl
nop
/*
* Either the address is unaligned, or the count is not a
* multiple of 8, or both. We will have to align the address
* in order to use anything `better' than stb.
*/
1:
cmp %o1, 15 ! len >= 15?
bge,a Lstd ! yes, use std
btst 1, %o0 ! (but first check alignment)
! not enough to bother: do byte-at-a-time loop.
2:
deccc %o1 ! while (--len >= 0)
bge,a 2b
stb %o2, [%o0 + %o1] ! addr[len] = 0;
retl
nop
Lstd:
/*
* There are at least 15 bytes to zero.
* We may have to zero some initial stuff to align
* the address.
*/
bz,a 1f ! if (addr & 1) {
btst 2, %o0
stb %o2, [%o0] ! *addr = 0;
inc %o0 ! addr++;
dec %o1 ! len--;
btst 2, %o0 ! }
1:
bz,a 1f ! if (addr & 2) {
btst 4, %o0
sth %o2, [%o0] ! *(short *)addr = 0;
inc 2, %o0 ! addr += 2;
dec 2, %o1 ! len -= 2;
btst 4, %o0 ! }
1:
bz 1f ! if (addr & 4) {
dec 8, %o1
st %o2, [%o0] ! *(int *)addr = 0;
inc 4, %o0 ! addr += 4;
dec 4, %o1 ! len -= 4;
! }
/*
* Address is double word aligned; len is 8 less than
* the number of bytes remaining (i.e., len is 0 if
* the remaining count is 8, 1 if it is 9, etc.).
*/
1:
std %o2, [%o0] ! do {
2: ! *(quad *)addr = 0;
inc 8, %o0 ! addr += 8;
deccc 8, %o1 ! } while ((len -= 8) >= 0);
bge,a 2b
std %o2, [%o0]
/*
* Len is in [-8..-1] where -8 => done, -7 => 1 byte to zero,
* -6 => two bytes, etc. Mop up this remainder, if any.
*/
btst 4, %o1
bz 1f ! if (len & 4) {
btst 2, %o1
st %o2, [%o0] ! *(int *)addr = 0;
inc 4, %o0 ! addr += 4;
1:
bz 1f ! if (len & 2) {
btst 1, %o1
sth %o2, [%o0] ! *(short *)addr = 0;
inc 2, %o0 ! addr += 2;
1:
bnz,a 1f ! if (len & 1)
stb %o2, [%o0] ! *addr = 0;
1:
retl
#ifdef MEMSET
mov %g1, %o0 ! restore original pointer
#else
nop
#endif
|
0xffea/MINIX3
| 2,365
|
common/lib/libc/arch/sparc/string/strlen.S
|
/* $NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Header: strlen.s,v 1.1 92/06/25 12:52:47 torek Exp
*/
#include <machine/asm.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
.asciz "@(#)strlen.s 8.1 (Berkeley) 6/4/93"
#else
RCSID("$NetBSD: strlen.S,v 1.1 2005/12/20 19:28:50 christos Exp $")
#endif
#endif /* LIBC_SCCS and not lint */
ENTRY(strlen)
add %o0, 1, %o1 ! save starting point + 1
1:
ldsb [%o0], %o2 ! fetch byte
tst %o2 ! null?
bne 1b ! no, keep going
inc %o0 ! always increment pointer
retl
sub %o0, %o1, %o0 ! return length (ptr - (origptr+1))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.