sync with HEADdiff -r1.6.16.1 -r1.6.16.2 src/common/lib/libc/Makefile.inc
(matt)
--- src/common/lib/libc/Makefile.inc 2008/01/09 01:20:46 1.6.16.1
+++ src/common/lib/libc/Makefile.inc 2008/03/23 00:12:40 1.6.16.2
@@ -1,34 +1,34 @@ | @@ -1,34 +1,34 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.6.16.1 2008/01/09 01:20:46 matt Exp $ | 1 | # Makefile.inc,v 1.6.16.1 2008/01/09 01:20:46 matt Exp | |
2 | 2 | |||
3 | COMMON_DIR:=${.PARSEDIR} | 3 | COMMON_DIR:=${.PARSEDIR} | |
4 | COMMON_CODEDIRS=atomic gen gmon inet md net quad stdlib string | 4 | COMMON_CODEDIRS=atomic gen gmon inet md net quad stdlib string | |
5 | COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 | 5 | COMMON_CODEDIRS+=hash/sha1 hash/sha2 hash/rmd160 | |
6 | 6 | |||
7 | .if defined(LIBKERN_ARCH) && !empty(LIBKERN_ARCH) && \ | 7 | .if defined(LIBKERN_ARCH) && !empty(LIBKERN_ARCH) && \ | |
8 | exists(${KERNDIR}/arch/${LIBKERN_ARCH}) | 8 | exists(${KERNDIR}/arch/${LIBKERN_ARCH}) | |
9 | COMMON_ARCHSUBDIR= ${LIBKERN_ARCH} | 9 | COMMON_ARCHSUBDIR= ${LIBKERN_ARCH} | |
10 | .elif exists(${COMMON_DIR}/arch/${MACHINE_ARCH}) | 10 | .elif exists(${COMMON_DIR}/arch/${MACHINE_ARCH}) | |
11 | COMMON_ARCHSUBDIR= ${MACHINE_ARCH} | 11 | COMMON_ARCHSUBDIR= ${MACHINE_ARCH} | |
12 | .elif exists(${COMMON_DIR}/arch/${MACHINE_CPU}) | 12 | .elif exists(${COMMON_DIR}/arch/${MACHINE_CPU}) | |
13 | COMMON_ARCHSUBDIR= ${MACHINE_CPU} | 13 | COMMON_ARCHSUBDIR= ${MACHINE_CPU} | |
14 | .endif | 14 | .endif | |
15 | 15 | |||
16 | COMMON_ARCHDIR=${COMMON_DIR}/arch/${COMMON_ARCHSUBDIR} | 16 | COMMON_ARCHDIR=${COMMON_DIR}/arch/${COMMON_ARCHSUBDIR} | |
17 | 17 | |||
18 | .for i in ${COMMON_CODEDIRS} | 18 | .for i in ${COMMON_CODEDIRS} | |
19 | .if exists(${COMMON_DIR}/$i) | 19 | .if exists(${COMMON_DIR}/$i) | |
20 | .PATH.c: ${COMMON_DIR}/$i | 20 | .PATH.c: ${COMMON_DIR}/$i | |
21 | .endif | 21 | .endif | |
22 | .if exists(${COMMON_ARCHDIR}/${i}/Makefile.inc) | |||
23 | .include "${COMMON_ARCHDIR}/${i}/Makefile.inc" | |||
24 | .endif | |||
22 | .if exists(${COMMON_ARCHDIR}/$i) | 25 | .if exists(${COMMON_ARCHDIR}/$i) | |
23 | .PATH.c: ${COMMON_ARCHDIR}/$i | 26 | .PATH.c: ${COMMON_ARCHDIR}/$i | |
24 | .PATH.S: ${COMMON_ARCHDIR}/$i | 27 | .PATH.S: ${COMMON_ARCHDIR}/$i | |
25 | .endif | 28 | .endif | |
26 | .if exists(${COMMON_ARCHDIR}/${i}/Makefile.inc) | |||
27 | .include "${COMMON_ARCHDIR}/${i}/Makefile.inc" | |||
28 | .endif | |||
29 | .endfor | 29 | .endfor | |
30 | 30 | |||
31 | CPPFLAGS+=-I${COMMON_DIR}/quad -I${COMMON_DIR}/string | 31 | CPPFLAGS+=-I${COMMON_DIR}/quad -I${COMMON_DIR}/string | |
32 | .if defined(COMMON_ARCHSUBDIR) | 32 | .if defined(COMMON_ARCHSUBDIR) | |
33 | CPPFLAGS+=-I${COMMON_ARCHDIR}/string | 33 | CPPFLAGS+=-I${COMMON_ARCHDIR}/string | |
34 | .endif | 34 | .endif |
--- src/common/lib/libc/arch/alpha/atomic/Makefile.inc 2008/01/09 01:20:47 1.2.4.2
+++ src/common/lib/libc/arch/alpha/atomic/Makefile.inc 2008/03/23 00:12:40 1.2.4.3
@@ -1,8 +1,14 @@ | @@ -1,8 +1,14 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.2.4.2 2008/01/09 01:20:47 matt Exp $ | 1 | # Makefile.inc,v 1.2.4.2 2008/01/09 01:20:47 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | 5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | |
6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | 6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | |
7 | 7 | |||
8 | .endif | 8 | .endif | |
9 | ||||
10 | .if defined(LIB) && (${LIB} == "c") | |||
11 | ||||
12 | SRCS+= atomic_init_cas.c | |||
13 | ||||
14 | .endif |
--- src/common/lib/libc/arch/alpha/atomic/atomic_cas.S 2008/01/09 01:20:48 1.2.4.2
+++ src/common/lib/libc/arch/alpha/atomic/atomic_cas.S 2008/03/23 00:12:40 1.2.4.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: atomic_cas.S,v 1.2.4.2 2008/01/09 01:20:48 matt Exp $ */ | 1 | /* atomic_cas.S,v 1.2.4.2 2008/01/09 01:20:48 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -40,32 +40,46 @@ | @@ -40,32 +40,46 @@ | |||
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | LEAF_NOPROFILE(_atomic_cas_32, 3) | 43 | LEAF_NOPROFILE(_atomic_cas_32, 3) | |
44 | 1: mov a2, t2 | 44 | 1: mov a2, t2 | |
45 | ldl_l v0, 0(a0) | 45 | ldl_l v0, 0(a0) | |
46 | cmpeq v0, a1, t1 | 46 | cmpeq v0, a1, t1 | |
47 | beq t1, 2f | 47 | beq t1, 2f | |
48 | stl_c t2, 0(a0) | 48 | stl_c t2, 0(a0) | |
49 | beq t2, 3f | 49 | beq t2, 3f | |
50 | 2: RET | 50 | 2: RET | |
51 | 3: br 1b | 51 | 3: br 1b | |
52 | END(_atomic_cas_32) | 52 | END(_atomic_cas_32) | |
53 | ||||
53 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | 54 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | |
54 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | 55 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | |
55 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 56 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
56 | 57 | |||
58 | ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) | |||
59 | STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) | |||
60 | ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) | |||
61 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) | |||
62 | ||||
57 | LEAF_NOPROFILE(_atomic_cas_64, 3) | 63 | LEAF_NOPROFILE(_atomic_cas_64, 3) | |
58 | 1: mov a2, t2 | 64 | 1: mov a2, t2 | |
59 | ldq_l v0, 0(a0) | 65 | ldq_l v0, 0(a0) | |
60 | cmpeq v0, a1, t1 | 66 | cmpeq v0, a1, t1 | |
61 | beq t1, 2f | 67 | beq t1, 2f | |
62 | stq_c t2, 0(a0) | 68 | stq_c t2, 0(a0) | |
63 | beq t2, 3f | 69 | beq t2, 3f | |
64 | 2: RET | 70 | 2: RET | |
65 | 3: br 1b | 71 | 3: br 1b | |
66 | END(_atomic_cas_64) | 72 | END(_atomic_cas_64) | |
73 | ||||
67 | ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) | 74 | ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) | |
68 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64) | 75 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64) | |
69 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) | 76 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) | |
70 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64) | 77 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64) | |
71 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) | 78 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) | |
79 | ||||
80 | ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64) | |||
81 | STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64) | |||
82 | ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64) | |||
83 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64) | |||
84 | ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64) | |||
85 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64) |
--- src/common/lib/libc/arch/alpha/atomic/membar_ops.S 2008/01/09 01:20:51 1.2.4.2
+++ src/common/lib/libc/arch/alpha/atomic/membar_ops.S 2008/03/23 00:12:40 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: membar_ops.S,v 1.2.4.2 2008/01/09 01:20:51 matt Exp $ */ | 1 | /* membar_ops.S,v 1.2.4.2 2008/01/09 01:20:51 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -28,56 +28,69 @@ | @@ -28,56 +28,69 @@ | |||
28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 28 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | #if defined(_KERNEL) | |||
42 | ||||
43 | .text | 41 | .text | |
44 | 42 | |||
43 | #ifdef _KERNEL | |||
44 | ||||
45 | /* | 45 | /* | |
46 | * We start out with no-op versions that do nothing. We hot-patch when | 46 | * We start out with no-op versions that do nothing. We hot-patch when | |
47 | * we detect a MP system. | 47 | * we detect a MP system. | |
48 | */ | 48 | */ | |
49 | LEAF_NOPROFILE(_membar_producer, 0) | 49 | LEAF_NOPROFILE(_membar_producer, 0) | |
50 | RET | 50 | RET | |
51 | nop | 51 | nop | |
52 | END(_membar_producer) | 52 | END(_membar_producer) | |
53 | EXPORT(_membar_producer_end) | 53 | EXPORT(_membar_producer_end) | |
54 | ATOMIC_OP_ALIAS(membar_producer,_membar_producer) | |||
55 | 54 | |||
56 | LEAF_NOPROFILE(_membar_sync, 0) | 55 | LEAF_NOPROFILE(_membar_sync, 0) | |
57 | RET | 56 | RET | |
58 | nop | 57 | nop | |
59 | END(_membar_sync) | 58 | END(_membar_sync) | |
60 | EXPORT(_membar_sync_end) | 59 | EXPORT(_membar_sync_end) | |
61 | ATOMIC_OP_ALIAS(membar_sync,_membar_sync) | |||
62 | ATOMIC_OP_ALIAS(membar_enter,_membar_sync) | |||
63 | STRONG_ALIAS(_membar_enter,_membar_sync) | |||
64 | ATOMIC_OP_ALIAS(membar_exit,_membar_sync) | |||
65 | STRONG_ALIAS(_membar_exit,_membar_sync) | |||
66 | ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) | |||
67 | STRONG_ALIAS(_membar_consumer,_membar_sync) | |||
68 | 60 | |||
69 | LEAF_NOPROFILE(_membar_producer_mp, 0) | 61 | LEAF_NOPROFILE(_membar_producer_mp, 0) | |
70 | wmb | 62 | wmb | |
71 | RET | 63 | RET | |
72 | END(_membar_producer_mp) | 64 | END(_membar_producer_mp) | |
73 | EXPORT(_membar_producer_mp_end) | 65 | EXPORT(_membar_producer_mp_end) | |
74 | 66 | |||
75 | LEAF_NOPROFILE(_membar_sync_mp, 0) | 67 | LEAF_NOPROFILE(_membar_sync_mp, 0) | |
76 | mb | 68 | mb | |
77 | RET | 69 | RET | |
78 | END(_membar_sync_mp) | 70 | END(_membar_sync_mp) | |
79 | EXPORT(_membar_sync_mp_end) | 71 | EXPORT(_membar_sync_mp_end) | |
80 | 72 | |||
81 | #else /* _KERNEL */ | 73 | #else /* _KERNEL */ | |
74 | ||||
75 | LEAF_NOPROFILE(_membar_producer, 0) | |||
76 | mb | |||
77 | RET | |||
78 | END(_membar_producer) | |||
79 | EXPORT(_membar_producer_end) | |||
82 | 80 | |||
83 | #endif /* _KERNEL */ | 81 | LEAF_NOPROFILE(_membar_sync, 0) | |
82 | mb | |||
83 | RET | |||
84 | END(_membar_sync) | |||
85 | EXPORT(_membar_sync_end) | |||
86 | ||||
87 | #endif /* _KERNEL */ | |||
88 | ||||
89 | ATOMIC_OP_ALIAS(membar_producer,_membar_producer) | |||
90 | ATOMIC_OP_ALIAS(membar_sync,_membar_sync) | |||
91 | ATOMIC_OP_ALIAS(membar_enter,_membar_sync) | |||
92 | STRONG_ALIAS(_membar_enter,_membar_sync) | |||
93 | ATOMIC_OP_ALIAS(membar_exit,_membar_sync) | |||
94 | STRONG_ALIAS(_membar_exit,_membar_sync) | |||
95 | ATOMIC_OP_ALIAS(membar_consumer,_membar_sync) | |||
96 | STRONG_ALIAS(_membar_consumer,_membar_sync) |
--- src/common/lib/libc/arch/alpha/gen/byte_swap_2.S 2005/12/27 09:22:08 1.2
+++ src/common/lib/libc/arch/alpha/gen/byte_swap_2.S 2008/03/23 00:12:40 1.2.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: byte_swap_2.S,v 1.2 2005/12/27 09:22:08 yamt Exp $ */ | 1 | /* byte_swap_2.S,v 1.2 2005/12/27 09:22:08 yamt Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Carnegie-Mellon University. | 4 | * Copyright (c) 1996 Carnegie-Mellon University. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Author: Chris G. Demetriou | 7 | * Author: Chris G. Demetriou | |
8 | * | 8 | * | |
9 | * Permission to use, copy, modify and distribute this software and | 9 | * Permission to use, copy, modify and distribute this software and | |
10 | * its documentation is hereby granted, provided that both the copyright | 10 | * its documentation is hereby granted, provided that both the copyright | |
11 | * notice and this permission notice appear in all copies of the | 11 | * notice and this permission notice appear in all copies of the | |
12 | * software, derivative works or modified versions, and any portions | 12 | * software, derivative works or modified versions, and any portions | |
13 | * thereof, and that both notices appear in supporting documentation. | 13 | * thereof, and that both notices appear in supporting documentation. | |
14 | * | 14 | * | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * School of Computer Science | 22 | * School of Computer Science | |
23 | * Carnegie Mellon University | 23 | * Carnegie Mellon University | |
24 | * Pittsburgh PA 15213-3890 | 24 | * Pittsburgh PA 15213-3890 | |
25 | * | 25 | * | |
26 | * any improvements or extensions that they make and grant Carnegie the | 26 | * any improvements or extensions that they make and grant Carnegie the | |
27 | * rights to redistribute these changes. | 27 | * rights to redistribute these changes. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <machine/asm.h> | 30 | #include <machine/asm.h> | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.) | 33 | * Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.) | |
34 | * | 34 | * | |
35 | * Argument is an unsigned 2-byte integer (u_int16_t). | 35 | * Argument is an unsigned 2-byte integer (uint16_t). | |
36 | */ | 36 | */ | |
37 | #if defined(_KERNEL) || defined(_STANDALONE) | 37 | #if defined(_KERNEL) || defined(_STANDALONE) | |
38 | #define BSWAP16 bswap16 | 38 | #define BSWAP16 bswap16 | |
39 | #else /* defined(_KERNEL) || defined(_STANDALONE) */ | 39 | #else /* defined(_KERNEL) || defined(_STANDALONE) */ | |
40 | #define BSWAP16 __bswap16 | 40 | #define BSWAP16 __bswap16 | |
41 | #endif /* defined(_KERNEL) || defined(_STANDALONE) */ | 41 | #endif /* defined(_KERNEL) || defined(_STANDALONE) */ | |
42 | LEAF(BSWAP16, 1) /* a0 contains 0x0123 */ | 42 | LEAF(BSWAP16, 1) /* a0 contains 0x0123 */ | |
43 | XLEAF(htons, 1) | 43 | XLEAF(htons, 1) | |
44 | XLEAF(ntohs, 1) | 44 | XLEAF(ntohs, 1) | |
45 | insbl a0, 1, t0 /* t0 = 0x23 */ | 45 | insbl a0, 1, t0 /* t0 = 0x23 */ | |
46 | extbl a0, 1, t1 /* t1 = 0x 01 */ | 46 | extbl a0, 1, t1 /* t1 = 0x 01 */ | |
47 | or t0, t1, v0 /* v0 = 0x2301 */ | 47 | or t0, t1, v0 /* v0 = 0x2301 */ | |
48 | RET | 48 | RET |
--- src/common/lib/libc/arch/alpha/gen/byte_swap_4.S 2005/12/27 09:22:08 1.2
+++ src/common/lib/libc/arch/alpha/gen/byte_swap_4.S 2008/03/23 00:12:40 1.2.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: byte_swap_4.S,v 1.2 2005/12/27 09:22:08 yamt Exp $ */ | 1 | /* byte_swap_4.S,v 1.2 2005/12/27 09:22:08 yamt Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Carnegie-Mellon University. | 4 | * Copyright (c) 1996 Carnegie-Mellon University. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Author: Chris G. Demetriou | 7 | * Author: Chris G. Demetriou | |
8 | * | 8 | * | |
9 | * Permission to use, copy, modify and distribute this software and | 9 | * Permission to use, copy, modify and distribute this software and | |
10 | * its documentation is hereby granted, provided that both the copyright | 10 | * its documentation is hereby granted, provided that both the copyright | |
11 | * notice and this permission notice appear in all copies of the | 11 | * notice and this permission notice appear in all copies of the | |
12 | * software, derivative works or modified versions, and any portions | 12 | * software, derivative works or modified versions, and any portions | |
13 | * thereof, and that both notices appear in supporting documentation. | 13 | * thereof, and that both notices appear in supporting documentation. | |
14 | * | 14 | * | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * School of Computer Science | 22 | * School of Computer Science | |
23 | * Carnegie Mellon University | 23 | * Carnegie Mellon University | |
24 | * Pittsburgh PA 15213-3890 | 24 | * Pittsburgh PA 15213-3890 | |
25 | * | 25 | * | |
26 | * any improvements or extensions that they make and grant Carnegie the | 26 | * any improvements or extensions that they make and grant Carnegie the | |
27 | * rights to redistribute these changes. | 27 | * rights to redistribute these changes. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <machine/asm.h> | 30 | #include <machine/asm.h> | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.) | 33 | * Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.) | |
34 | * | 34 | * | |
35 | * Argument is an unsigned 4-byte integer (u_int32_t). | 35 | * Argument is an unsigned 4-byte integer (uint32_t). | |
36 | */ | 36 | */ | |
37 | #if defined(_KERNEL) || defined(_STANDALONE) | 37 | #if defined(_KERNEL) || defined(_STANDALONE) | |
38 | #define BSWAP32 bswap32 | 38 | #define BSWAP32 bswap32 | |
39 | #else /* defined(_KERNEL) || defined(_STANDALONE) */ | 39 | #else /* defined(_KERNEL) || defined(_STANDALONE) */ | |
40 | #define BSWAP32 __bswap32 | 40 | #define BSWAP32 __bswap32 | |
41 | #endif /* defined(_KERNEL) || defined(_STANDALONE) */ | 41 | #endif /* defined(_KERNEL) || defined(_STANDALONE) */ | |
42 | LEAF(BSWAP32, 1) /* a0 contains 0x01234567 */ | 42 | LEAF(BSWAP32, 1) /* a0 contains 0x01234567 */ | |
43 | XLEAF(htonl, 1) | 43 | XLEAF(htonl, 1) | |
44 | XLEAF(ntohl, 1) | 44 | XLEAF(ntohl, 1) | |
45 | insbl a0, 3, t0 /* t0 = 0x67 */ | 45 | insbl a0, 3, t0 /* t0 = 0x67 */ | |
46 | extbl a0, 1, t1 /* t1 = 0x 45 */ | 46 | extbl a0, 1, t1 /* t1 = 0x 45 */ | |
47 | extbl a0, 2, t2 /* t2 = 0x 23 */ | 47 | extbl a0, 2, t2 /* t2 = 0x 23 */ | |
48 | extbl a0, 3, t3 /* t3 = 0x 01 */ | 48 | extbl a0, 3, t3 /* t3 = 0x 01 */ |
--- src/common/lib/libc/arch/arm/atomic/Makefile.inc 2008/01/09 01:20:51 1.3.4.2
+++ src/common/lib/libc/arch/arm/atomic/Makefile.inc 2008/03/23 00:12:40 1.3.4.3
@@ -1,10 +1,16 @@ | @@ -1,10 +1,16 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.3.4.2 2008/01/09 01:20:51 matt Exp $ | 1 | # Makefile.inc,v 1.3.4.2 2008/01/09 01:20:51 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | 5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | |
6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | 6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | |
7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | 7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | |
8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c | 8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c | |
9 | 9 | |||
10 | .endif | 10 | .endif | |
11 | ||||
12 | .if defined(LIB) && (${LIB} == "c") | |||
13 | ||||
14 | SRCS+= atomic_init_testset.c | |||
15 | ||||
16 | .endif |
--- src/common/lib/libc/arch/hppa/atomic/Makefile.inc 2008/01/09 01:20:52 1.1.4.2
+++ src/common/lib/libc/arch/hppa/atomic/Makefile.inc 2008/03/23 00:12:41 1.1.4.3
@@ -1,10 +1,16 @@ | @@ -1,10 +1,16 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.1.4.2 2008/01/09 01:20:52 matt Exp $ | 1 | # Makefile.inc,v 1.1.4.2 2008/01/09 01:20:52 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | 5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | |
6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | 6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | |
7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | 7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | |
8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c | 8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c | |
9 | 9 | |||
10 | .endif | 10 | .endif | |
11 | ||||
12 | .if defined(LIB) && (${LIB} == "c") | |||
13 | ||||
14 | SRCS+= atomic_init_testset.c | |||
15 | ||||
16 | .endif |
--- src/common/lib/libc/arch/i386/atomic/Makefile.inc 2008/01/09 01:20:52 1.3.2.2
+++ src/common/lib/libc/arch/i386/atomic/Makefile.inc 2008/03/23 00:12:41 1.3.2.3
@@ -1,9 +1,16 @@ | @@ -1,9 +1,16 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.3.2.2 2008/01/09 01:20:52 matt Exp $ | 1 | # Makefile.inc,v 1.3.2.2 2008/01/09 01:20:52 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_and_64_cas.c \ | 5 | SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_and_64_cas.c \ | |
6 | atomic_and_64_nv_cas.c atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \ | 6 | atomic_and_64_nv_cas.c atomic_dec_64_cas.c atomic_dec_64_nv_cas.c \ | |
7 | atomic_inc_64_cas.c atomic_inc_64_nv_cas.c atomic_or_64_cas.c \ | 7 | atomic_inc_64_cas.c atomic_inc_64_nv_cas.c atomic_or_64_cas.c \ | |
8 | atomic_or_64_nv_cas.c atomic_swap_64_cas.c atomic.S | 8 | atomic_or_64_nv_cas.c atomic_swap_64_cas.c atomic.S | |
9 | ||||
10 | .endif | |||
11 | ||||
12 | .if defined(LIB) && (${LIB} == "c") | |||
13 | ||||
14 | SRCS+= atomic_init_cas.c | |||
15 | ||||
9 | .endif | 16 | .endif |
--- src/common/lib/libc/arch/i386/atomic/atomic.S 2008/01/09 01:20:53 1.7.2.2
+++ src/common/lib/libc/arch/i386/atomic/atomic.S 2008/03/23 00:12:41 1.7.2.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic.S,v 1.7.2.2 2008/01/09 01:20:53 matt Exp $ */ | 1 | /* atomic.S,v 1.7.2.2 2008/01/09 01:20:53 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe, and by Andrew Doran. | 8 | * by Jason R. Thorpe, and by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -137,50 +137,46 @@ NENTRY(_atomic_swap_32) | @@ -137,50 +137,46 @@ NENTRY(_atomic_swap_32) | |||
137 | movl 8(%esp), %eax | 137 | movl 8(%esp), %eax | |
138 | xchgl %eax, (%edx) | 138 | xchgl %eax, (%edx) | |
139 | ret | 139 | ret | |
140 | 140 | |||
141 | NENTRY(_atomic_cas_32) | 141 | NENTRY(_atomic_cas_32) | |
142 | movl 4(%esp), %edx | 142 | movl 4(%esp), %edx | |
143 | movl 8(%esp), %eax | 143 | movl 8(%esp), %eax | |
144 | movl 12(%esp), %ecx | 144 | movl 12(%esp), %ecx | |
145 | LOCK(12) | 145 | LOCK(12) | |
146 | cmpxchgl %ecx, (%edx) | 146 | cmpxchgl %ecx, (%edx) | |
147 | /* %eax now contains the old value */ | 147 | /* %eax now contains the old value */ | |
148 | ret | 148 | ret | |
149 | 149 | |||
150 | NENTRY(_atomic_cas_32_ni) | |||
151 | movl 4(%esp), %edx | |||
152 | movl 8(%esp), %eax | |||
153 | movl 12(%esp), %ecx | |||
154 | cmpxchgl %ecx, (%edx) | |||
155 | /* %eax now contains the old value */ | |||
156 | ret | |||
157 | ||||
150 | NENTRY(_membar_consumer) | 158 | NENTRY(_membar_consumer) | |
151 | LOCK(13) | 159 | LOCK(13) | |
152 | addl $0, -4(%esp) | 160 | addl $0, -4(%esp) | |
153 | ret | 161 | ret | |
154 | END(membar_consumer_end) | 162 | END(membar_consumer_end) | |
155 | 163 | |||
156 | NENTRY(_membar_producer) | 164 | NENTRY(_membar_producer) | |
157 | /* A store is enough */ | 165 | /* A store is enough */ | |
158 | movl $0, -4(%esp) | 166 | movl $0, -4(%esp) | |
159 | ret | 167 | ret | |
160 | END(membar_producer_end) | 168 | END(membar_producer_end) | |
161 | 169 | |||
162 | NENTRY(_membar_enter) | |||
163 | /* A store is enough */ | |||
164 | movl $0, -4(%esp) | |||
165 | ret | |||
166 | END(membar_enter_end) | |||
167 | ||||
168 | NENTRY(_membar_exit) | |||
169 | /* A store is enough */ | |||
170 | movl $0, -4(%esp) | |||
171 | ret | |||
172 | END(membar_exit_end) | |||
173 | ||||
174 | NENTRY(_membar_sync) | 170 | NENTRY(_membar_sync) | |
175 | LOCK(14) | 171 | LOCK(14) | |
176 | addl $0, -4(%esp) | 172 | addl $0, -4(%esp) | |
177 | ret | 173 | ret | |
178 | END(membar_sync_end) | 174 | END(membar_sync_end) | |
179 | 175 | |||
180 | #ifdef _KERNEL | 176 | #ifdef _KERNEL | |
181 | NENTRY(_atomic_cas_64) | 177 | NENTRY(_atomic_cas_64) | |
182 | cli | 178 | cli | |
183 | pushl %edi | 179 | pushl %edi | |
184 | pushl %ebx | 180 | pushl %ebx | |
185 | movl 12(%esp), %edi | 181 | movl 12(%esp), %edi | |
186 | movl 16(%esp), %eax | 182 | movl 16(%esp), %eax | |
@@ -301,32 +297,38 @@ ALIAS(atomic_or_uint_nv,_atomic_or_32_nv | @@ -301,32 +297,38 @@ ALIAS(atomic_or_uint_nv,_atomic_or_32_nv | |||
301 | ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) | 297 | ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) | |
302 | ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv) | 298 | ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv) | |
303 | 299 | |||
304 | ALIAS(atomic_swap_32,_atomic_swap_32) | 300 | ALIAS(atomic_swap_32,_atomic_swap_32) | |
305 | ALIAS(atomic_swap_uint,_atomic_swap_32) | 301 | ALIAS(atomic_swap_uint,_atomic_swap_32) | |
306 | ALIAS(atomic_swap_ulong,_atomic_swap_32) | 302 | ALIAS(atomic_swap_ulong,_atomic_swap_32) | |
307 | ALIAS(atomic_swap_ptr,_atomic_swap_32) | 303 | ALIAS(atomic_swap_ptr,_atomic_swap_32) | |
308 | 304 | |||
309 | ALIAS(atomic_cas_32,_atomic_cas_32) | 305 | ALIAS(atomic_cas_32,_atomic_cas_32) | |
310 | ALIAS(atomic_cas_uint,_atomic_cas_32) | 306 | ALIAS(atomic_cas_uint,_atomic_cas_32) | |
311 | ALIAS(atomic_cas_ulong,_atomic_cas_32) | 307 | ALIAS(atomic_cas_ulong,_atomic_cas_32) | |
312 | ALIAS(atomic_cas_ptr,_atomic_cas_32) | 308 | ALIAS(atomic_cas_ptr,_atomic_cas_32) | |
313 | 309 | |||
310 | ALIAS(atomic_cas_32_ni,_atomic_cas_32_ni) | |||
311 | ALIAS(atomic_cas_uint_ni,_atomic_cas_32_ni) | |||
312 | ALIAS(atomic_cas_ulong_ni,_atomic_cas_32_ni) | |||
313 | ALIAS(atomic_cas_ptr_ni,_atomic_cas_32_ni) | |||
314 | ||||
314 | ALIAS(atomic_cas_64,_atomic_cas_64) | 315 | ALIAS(atomic_cas_64,_atomic_cas_64) | |
316 | ALIAS(atomic_cas_64_ni,_atomic_cas_64) | |||
315 | 317 | |||
316 | ALIAS(membar_consumer,_membar_consumer) | 318 | ALIAS(membar_consumer,_membar_consumer) | |
317 | ALIAS(membar_producer,_membar_producer) | 319 | ALIAS(membar_producer,_membar_producer) | |
318 | ALIAS(membar_enter,_membar_enter) | 320 | ALIAS(membar_enter,_membar_consumer) | |
319 | ALIAS(membar_exit,_membar_exit) | 321 | ALIAS(membar_exit,_membar_producer) | |
320 | ALIAS(membar_sync,_membar_sync) | 322 | ALIAS(membar_sync,_membar_sync) | |
321 | 323 | |||
322 | STRONG_ALIAS(_atomic_add_int,_atomic_add_32) | 324 | STRONG_ALIAS(_atomic_add_int,_atomic_add_32) | |
323 | STRONG_ALIAS(_atomic_add_long,_atomic_add_32) | 325 | STRONG_ALIAS(_atomic_add_long,_atomic_add_32) | |
324 | STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32) | 326 | STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32) | |
325 | 327 | |||
326 | STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) | 328 | STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) | |
327 | STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv) | 329 | STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv) | |
328 | STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv) | 330 | STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv) | |
329 | 331 | |||
330 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | 332 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | |
331 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) | 333 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) | |
332 | STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32) | 334 | STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32) | |
@@ -356,13 +358,20 @@ STRONG_ALIAS(_atomic_or_ulong,_atomic_or | @@ -356,13 +358,20 @@ STRONG_ALIAS(_atomic_or_ulong,_atomic_or | |||
356 | STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32) | 358 | STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32) | |
357 | 359 | |||
358 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | 360 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | |
359 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) | 361 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) | |
360 | STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv) | 362 | STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv) | |
361 | 363 | |||
362 | STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) | 364 | STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) | |
363 | STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32) | 365 | STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32) | |
364 | STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32) | 366 | STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32) | |
365 | 367 | |||
366 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 368 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
367 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | 369 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | |
368 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | 370 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | |
371 | ||||
372 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32_ni) | |||
373 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32_ni) | |||
374 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32_ni) | |||
375 | ||||
376 | STRONG_ALIAS(_membar_enter,_membar_consumer) | |||
377 | STRONG_ALIAS(_membar_exit,_membar_producer) |
# $NetBSD: Makefile.inc,v 1.1.2.2 2008/03/23 00:12:41 matt Exp $
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c")
SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c \
atomic_add_64_cas.c atomic_add_64_nv_cas.c \
atomic_and_32_cas.c atomic_and_32_nv_cas.c \
atomic_and_64_cas.c atomic_and_64_nv_cas.c \
atomic_or_32_cas.c atomic_or_32_nv_cas.c \
atomic_or_64_cas.c atomic_or_64_nv_cas.c
SRCS+= atomic.S
.endif
.if defined(LIB) && (${LIB} == "c")
SRCS += atomic_init_cas.c
.endif
/* $NetBSD: atomic.S,v 1.1.2.2 2008/03/23 00:12:41 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Takayoshi Kochi.
*
* 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>
#ifdef _KERNEL
#define ALIAS(f, t) STRONG_ALIAS(f,t)
#else
#define ALIAS(f, t) WEAK_ALIAS(f,t)
#endif
.text
ENTRY_NOPROFILE(_atomic_dec_32,1)
fetchadd4.rel r8=[r32],-1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_dec_64,1)
fetchadd8.rel r8=[r32],-1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_dec_32_nv,1)
fetchadd4.rel r8=[r32],-1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_dec_64_nv,1)
fetchadd8.rel r8=[r32],-1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_inc_32,1)
fetchadd4.rel r8=[r32],1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_inc_64,1)
fetchadd8.rel r8=[r32],1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_inc_32_nv,1)
fetchadd4.rel r8=[r32],1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_inc_64_nv,1)
fetchadd8.rel r8=[r32],1
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_swap_32,2)
xchg4 r8=[r32],r33
;;
mov r33=r8
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_swap_64,2)
xchg8 r8=[r32],r33
;;
mov r33=r8
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_cas_32,3)
mov ar.ccv=r33
;;
cmpxchg4.acq r8=[r32],r34,ar.ccv
br.ret.sptk rp
ENTRY_NOPROFILE(_atomic_cas_64,3)
mov ar.ccv=r33
;;
cmpxchg8.acq r8=[r32],r34,ar.ccv
br.ret.sptk rp
ENTRY_NOPROFILE(_membar_consumer,0)
mf
br.ret.sptk rp
ENTRY_NOPROFILE(_membar_producer,0)
mf
br.ret.sptk rp
ENTRY_NOPROFILE(_membar_enter,0)
mf
br.ret.sptk rp
ENTRY_NOPROFILE(_membar_exit,0)
mf
br.ret.sptk rp
ENTRY_NOPROFILE(_membar_sync,0)
mf
br.ret.sptk rp
ALIAS(atomic_add_32,_atomic_add_32)
ALIAS(atomic_add_int,_atomic_add_32)
ALIAS(atomic_add_64,_atomic_add_64)
ALIAS(atomic_add_long,_atomic_add_64)
ALIAS(atomic_add_ptr,_atomic_add_64)
ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
ALIAS(atomic_add_64_nv,_atomic_add_64_nv)
ALIAS(atomic_add_long_nv,_atomic_add_64_nv)
ALIAS(atomic_add_ptr_nv,_atomic_add_64_nv)
ALIAS(atomic_and_32,_atomic_and_32)
ALIAS(atomic_and_uint,_atomic_and_32)
ALIAS(atomic_and_64,_atomic_and_64)
ALIAS(atomic_and_ulong,_atomic_and_64)
ALIAS(atomic_and_ptr,_atomic_and_64)
ALIAS(atomic_and_32_nv,_atomic_and_32_nv)
ALIAS(atomic_and_uint_nv,_atomic_and_32_nv)
ALIAS(atomic_and_64_nv,_atomic_and_64_nv)
ALIAS(atomic_and_ulong_nv,_atomic_and_64_nv)
ALIAS(atomic_and_ptr_nv,_atomic_and_64_nv)
ALIAS(atomic_dec_32,_atomic_dec_32)
ALIAS(atomic_dec_uint,_atomic_dec_32)
ALIAS(atomic_dec_64,_atomic_dec_64)
ALIAS(atomic_dec_ulong,_atomic_dec_64)
ALIAS(atomic_dec_ptr,_atomic_dec_64)
ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv)
ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv)
ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
ALIAS(atomic_dec_ulong_nv,_atomic_dec_64_nv)
ALIAS(atomic_dec_ptr_nv,_atomic_dec_64_nv)
ALIAS(atomic_inc_32,_atomic_inc_32)
ALIAS(atomic_inc_uint,_atomic_inc_32)
ALIAS(atomic_inc_64,_atomic_inc_64)
ALIAS(atomic_inc_ulong,_atomic_inc_64)
ALIAS(atomic_inc_ptr,_atomic_inc_64)
ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv)
ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv)
ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
ALIAS(atomic_inc_ulong_nv,_atomic_inc_64_nv)
ALIAS(atomic_inc_ptr_nv,_atomic_inc_64_nv)
ALIAS(atomic_or_32,_atomic_or_32)
ALIAS(atomic_or_uint,_atomic_or_32)
ALIAS(atomic_or_64,_atomic_or_64)
ALIAS(atomic_or_ulong,_atomic_or_64)
ALIAS(atomic_or_ptr,_atomic_or_64)
ALIAS(atomic_or_32_nv,_atomic_or_32_nv)
ALIAS(atomic_or_uint_nv,_atomic_or_32_nv)
ALIAS(atomic_or_64_nv,_atomic_or_64_nv)
ALIAS(atomic_or_ulong_nv,_atomic_or_64_nv)
ALIAS(atomic_or_ptr_nv,_atomic_or_64_nv)
ALIAS(atomic_swap_32,_atomic_swap_32)
ALIAS(atomic_swap_uint,_atomic_swap_32)
ALIAS(atomic_swap_64,_atomic_swap_64)
ALIAS(atomic_swap_ulong,_atomic_swap_64)
ALIAS(atomic_swap_ptr,_atomic_swap_64)
ALIAS(atomic_cas_32,_atomic_cas_32)
ALIAS(atomic_cas_uint,_atomic_cas_32)
ALIAS(atomic_cas_64,_atomic_cas_64)
ALIAS(atomic_cas_ulong,_atomic_cas_64)
ALIAS(atomic_cas_ptr,_atomic_cas_64)
ALIAS(membar_consumer,_membar_consumer)
ALIAS(membar_producer,_membar_producer)
ALIAS(membar_enter,_membar_enter)
ALIAS(membar_exit,_membar_exit)
ALIAS(membar_sync,_membar_sync)
STRONG_ALIAS(_atomic_add_int,_atomic_add_32)
STRONG_ALIAS(_atomic_add_long,_atomic_add_64)
STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64)
STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv)
STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv)
STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv)
STRONG_ALIAS(_atomic_and_uint,_atomic_and_32)
STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64)
STRONG_ALIAS(_atomic_and_ptr,_atomic_and_64)
STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv)
STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_64_nv)
STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_64_nv)
STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32)
STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_64)
STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_64)
STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv)
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32)
STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_64)
STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_64)
STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv)
STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_64_nv)
STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_64_nv)
STRONG_ALIAS(_atomic_or_uint,_atomic_or_32)
STRONG_ALIAS(_atomic_or_ulong,_atomic_or_64)
STRONG_ALIAS(_atomic_or_ptr,_atomic_or_64)
STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv)
STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_64_nv)
STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_64_nv)
STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32)
STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64)
STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64)
STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32)
STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64)
STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64)
--- src/common/lib/libc/arch/m68k/atomic/Makefile.inc 2008/01/09 01:20:54 1.2.4.2
+++ src/common/lib/libc/arch/m68k/atomic/Makefile.inc 2008/03/23 00:12:41 1.2.4.3
@@ -1,17 +1,23 @@ | @@ -1,17 +1,23 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.2.4.2 2008/01/09 01:20:54 matt Exp $ | 1 | # Makefile.inc,v 1.2.4.2 2008/01/09 01:20:54 matt Exp | |
2 | 2 | |||
3 | # | 3 | # | |
4 | # Note: The atomic operations here in these assembly files are atomic | 4 | # Note: The atomic operations here in these assembly files are atomic | |
5 | # only with respect to regular memory on uniprocessor systems. Since | 5 | # only with respect to regular memory on uniprocessor systems. Since | |
6 | # we don't support any MP m68k systems, this is just fine. If we ever | 6 | # we don't support any MP m68k systems, this is just fine. If we ever | |
7 | # do, then these routines will probably need to be replaced with CAS- | 7 | # do, then these routines will probably need to be replaced with CAS- | |
8 | # based routines (CAS generates an atomic bus cycle, whereas these | 8 | # based routines (CAS generates an atomic bus cycle, whereas these | |
9 | # others are merely single-instruction). | 9 | # others are merely single-instruction). | |
10 | # | 10 | # | |
11 | 11 | |||
12 | .if defined(LIB) && (${LIB} == "kern") | 12 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
13 | 13 | |||
14 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | 14 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | |
15 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops_nop.c | 15 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops_nop.c | |
16 | 16 | |||
17 | .endif | 17 | .endif | |
18 | ||||
19 | .if defined(LIB) && (${LIB} == "c") | |||
20 | ||||
21 | SRCS+= atomic_init_cas.c | |||
22 | ||||
23 | .endif |
--- src/common/lib/libc/arch/m68k/atomic/atomic_cas.S 2008/01/09 01:20:56 1.2.4.2
+++ src/common/lib/libc/arch/m68k/atomic/atomic_cas.S 2008/03/23 00:12:41 1.2.4.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: atomic_cas.S,v 1.2.4.2 2008/01/09 01:20:56 matt Exp $ */ | 1 | /* atomic_cas.S,v 1.2.4.2 2008/01/09 01:20:56 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -38,20 +38,30 @@ | @@ -38,20 +38,30 @@ | |||
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_cas_32) | 43 | ENTRY_NOPROFILE(_atomic_cas_32) | |
44 | movl %sp@(4), %a0 | 44 | movl %sp@(4), %a0 | |
45 | movl %sp@(8), %d0 | 45 | movl %sp@(8), %d0 | |
46 | movl %sp@(12), %d1 | 46 | movl %sp@(12), %d1 | |
47 | casl %d0, %d1, %a0@ | 47 | casl %d0, %d1, %a0@ | |
48 | /* %d0 now contains the old value */ | 48 | /* %d0 now contains the old value */ | |
49 | movl %d0, %a0 /* pointers return also in %a0 */ | 49 | movl %d0, %a0 /* pointers return also in %a0 */ | |
50 | rts | 50 | rts | |
51 | ||||
51 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | 52 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | |
52 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | 53 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | |
53 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 54 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
54 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) | 55 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) | |
55 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | 56 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | |
56 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32) | 57 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32) | |
57 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | 58 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | |
59 | ||||
60 | ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) | |||
61 | STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) | |||
62 | ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) | |||
63 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) | |||
64 | ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32) | |||
65 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32) | |||
66 | ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32) | |||
67 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32) |
--- src/common/lib/libc/arch/m68k/atomic/atomic_and.S 2008/01/09 01:20:55 1.3.4.2
+++ src/common/lib/libc/arch/m68k/atomic/atomic_and.S 2008/03/23 00:12:41 1.3.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_and.S,v 1.3.4.2 2008/01/09 01:20:55 matt Exp $ */ | 1 | /* atomic_and.S,v 1.3.4.2 2008/01/09 01:20:55 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -50,22 +50,21 @@ ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_ | @@ -50,22 +50,21 @@ ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_ | |||
50 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | 50 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | |
51 | ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32) | 51 | ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32) | |
52 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) | 52 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) | |
53 | ATOMIC_OP_ALIAS(atomic_and_ptr,_atomic_and_32) | 53 | ATOMIC_OP_ALIAS(atomic_and_ptr,_atomic_and_32) | |
54 | STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32) | 54 | STRONG_ALIAS(_atomic_and_ptr,_atomic_and_32) | |
55 | 55 | |||
56 | ENTRY_NOPROFILE(_atomic_and_32_nv) | 56 | ENTRY_NOPROFILE(_atomic_and_32_nv) | |
57 | movl %sp@(4), %a0 | 57 | movl %sp@(4), %a0 | |
58 | 1: movl %a0@, %d0 | 58 | 1: movl %a0@, %d0 | |
59 | movl %d0, %d1 | 59 | movl %d0, %d1 | |
60 | andl %sp@(8), %d0 | 60 | andl %sp@(8), %d0 | |
61 | casl %d1, %d0, %a0@ | 61 | casl %d1, %d0, %a0@ | |
62 | bne 1b | 62 | bne 1b | |
63 | movl %d0, %a0 /* pointers return also in %a0 */ | |||
64 | rts | 63 | rts | |
65 | ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv) | 64 | ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv) | |
66 | ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv) | 65 | ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv) | |
67 | STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv) | 66 | STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv) | |
68 | ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv) | 67 | ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv) | |
69 | STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv) | 68 | STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv) | |
70 | ATOMIC_OP_ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv) | 69 | ATOMIC_OP_ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv) | |
71 | STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv) | 70 | STRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv) |
--- src/common/lib/libc/arch/m68k/atomic/atomic_or.S 2008/01/09 01:20:57 1.3.4.2
+++ src/common/lib/libc/arch/m68k/atomic/atomic_or.S 2008/03/23 00:12:41 1.3.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_or.S,v 1.3.4.2 2008/01/09 01:20:57 matt Exp $ */ | 1 | /* atomic_or.S,v 1.3.4.2 2008/01/09 01:20:57 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -50,22 +50,21 @@ ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_o | @@ -50,22 +50,21 @@ ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_o | |||
50 | STRONG_ALIAS(_atomic_or_uint,_atomic_or_32) | 50 | STRONG_ALIAS(_atomic_or_uint,_atomic_or_32) | |
51 | ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32) | 51 | ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32) | |
52 | STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32) | 52 | STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32) | |
53 | ATOMIC_OP_ALIAS(atomic_or_ptr,_atomic_or_32) | 53 | ATOMIC_OP_ALIAS(atomic_or_ptr,_atomic_or_32) | |
54 | STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32) | 54 | STRONG_ALIAS(_atomic_or_ptr,_atomic_or_32) | |
55 | 55 | |||
56 | ENTRY_NOPROFILE(_atomic_or_32_nv) | 56 | ENTRY_NOPROFILE(_atomic_or_32_nv) | |
57 | movl %sp@(4), %a0 | 57 | movl %sp@(4), %a0 | |
58 | 1: movl %a0@, %d0 | 58 | 1: movl %a0@, %d0 | |
59 | movl %d0, %d1 | 59 | movl %d0, %d1 | |
60 | orl %sp@(8), %d0 | 60 | orl %sp@(8), %d0 | |
61 | casl %d1, %d0, %a0@ | 61 | casl %d1, %d0, %a0@ | |
62 | bne 1b | 62 | bne 1b | |
63 | movl %d0, %a0 /* pointers return also in %a0 */ | |||
64 | rts | 63 | rts | |
65 | ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv) | 64 | ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv) | |
66 | ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv) | 65 | ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv) | |
67 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | 66 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | |
68 | ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) | 67 | ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) | |
69 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) | 68 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) | |
70 | ATOMIC_OP_ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv) | 69 | ATOMIC_OP_ALIAS(atomic_or_ptr_nv,_atomic_or_32_nv) | |
71 | STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv) | 70 | STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_32_nv) |
--- src/common/lib/libc/arch/mips/atomic/Makefile.inc 2008/01/09 01:20:58 1.4.4.2
+++ src/common/lib/libc/arch/mips/atomic/Makefile.inc 2008/03/23 00:12:41 1.4.4.3
@@ -1,14 +1,26 @@ | @@ -1,14 +1,26 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.4.4.2 2008/01/09 01:20:58 matt Exp $ | 1 | # Makefile.inc,v 1.4.4.2 2008/01/09 01:20:58 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | 5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | |
6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | 6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | |
7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | 7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | |
8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c atomic_add_64_cas.c \ | 8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c atomic_add_64_cas.c \ | |
9 | atomic_add_64_nv_cas.c atomic_and_64_cas.c atomic_and_64_nv_cas.c \ | 9 | atomic_add_64_nv_cas.c atomic_and_64_cas.c atomic_and_64_nv_cas.c \ | |
10 | atomic_dec_64_cas.c atomic_dec_64_nv_cas.c atomic_inc_64_cas.c \ | 10 | atomic_dec_64_cas.c atomic_dec_64_nv_cas.c atomic_inc_64_cas.c \ | |
11 | atomic_inc_64_nv_cas.c atomic_or_64_cas.c atomic_or_64_nv_cas.c \ | 11 | atomic_inc_64_nv_cas.c atomic_or_64_cas.c atomic_or_64_nv_cas.c \ | |
12 | atomic_swap_64_cas.c membar_ops.o | 12 | atomic_swap_64_cas.c membar_ops.o | |
13 | 13 | |||
14 | .endif | 14 | .endif | |
15 | ||||
16 | .if defined(LIB) && (${LIB} == "c") | |||
17 | ||||
18 | SRCS+= membar_ops_nop.c atomic_init_testset.c | |||
19 | ||||
20 | .endif | |||
21 | ||||
22 | .if defined(LIB) && (${LIB} == "kern") | |||
23 | ||||
24 | SRCS+= membar_ops.S | |||
25 | ||||
26 | .endif |
--- src/common/lib/libc/arch/powerpc/atomic/Makefile.inc 2008/01/09 01:20:59 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/Makefile.inc 2008/03/23 00:12:42 1.2.4.3
@@ -1,8 +1,14 @@ | @@ -1,8 +1,14 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.2.4.2 2008/01/09 01:20:59 matt Exp $ | 1 | # Makefile.inc,v 1.2.4.2 2008/01/09 01:20:59 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | 5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | |
6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | 6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | |
7 | 7 | |||
8 | .endif | 8 | .endif | |
9 | ||||
10 | .if defined(LIB) && (${LIB} == "c") | |||
11 | ||||
12 | SRCS+= atomic_init_cas.c | |||
13 | ||||
14 | .endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_add.S 2008/01/09 01:21:00 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_add.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_add.S,v 1.2.4.2 2008/01/09 01:21:00 matt Exp $ */ | 1 | /* atomic_add.S,v 1.2.4.2 2008/01/09 01:21:00 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -31,44 +31,44 @@ | @@ -31,44 +31,44 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_add_32) | 43 | ENTRY_NOPROFILE(_atomic_add_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | add r10,r10,r4 | 45 | add %r10,%r10,%r4 | |
46 | stwcx. r10,0,r3 | 46 | stwcx. %r10,0,%r3 | |
47 | bne- 1b | 47 | bne- 1b | |
48 | blr | 48 | blr | |
49 | ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32) | 49 | ATOMIC_OP_ALIAS(atomic_add_32,_atomic_add_32) | |
50 | ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32) | 50 | ATOMIC_OP_ALIAS(atomic_add_int,_atomic_add_32) | |
51 | STRONG_ALIAS(_atomic_add_int,_atomic_add_32) | 51 | STRONG_ALIAS(_atomic_add_int,_atomic_add_32) | |
52 | #if !defined(_LP64) | 52 | #if !defined(_LP64) | |
53 | ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32) | 53 | ATOMIC_OP_ALIAS(atomic_add_long,_atomic_add_32) | |
54 | STRONG_ALIAS(_atomic_add_long,_atomic_add_32) | 54 | STRONG_ALIAS(_atomic_add_long,_atomic_add_32) | |
55 | ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32) | 55 | ATOMIC_OP_ALIAS(atomic_add_ptr,_atomic_add_32) | |
56 | STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32) | 56 | STRONG_ALIAS(_atomic_add_ptr,_atomic_add_32) | |
57 | #endif | 57 | #endif | |
58 | 58 | |||
59 | ENTRY_NOPROFILE(_atomic_add_32_nv) | 59 | ENTRY_NOPROFILE(_atomic_add_32_nv) | |
60 | 1: lwarx r10,0,r3 | 60 | 1: lwarx %r10,0,%r3 | |
61 | add r10,r10,r4 | 61 | add %r10,%r10,%r4 | |
62 | stwcx. r10,0,r3 | 62 | stwcx. %r10,0,%r3 | |
63 | bne- 1b | 63 | bne- 1b | |
64 | mr r3,r10 | 64 | mr %r3,%r10 | |
65 | blr | 65 | blr | |
66 | ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv) | 66 | ATOMIC_OP_ALIAS(atomic_add_32_nv,_atomic_add_32_nv) | |
67 | ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv) | 67 | ATOMIC_OP_ALIAS(atomic_add_int_nv,_atomic_add_32_nv) | |
68 | STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) | 68 | STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) | |
69 | #if !defined(_LP64) | 69 | #if !defined(_LP64) | |
70 | ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv) | 70 | ATOMIC_OP_ALIAS(atomic_add_long_nv,_atomic_add_32_nv) | |
71 | STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv) | 71 | STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_32_nv) | |
72 | ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv) | 72 | ATOMIC_OP_ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv) | |
73 | STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv) | 73 | STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_32_nv) | |
74 | #endif | 74 | #endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_and.S 2008/01/09 01:21:00 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_and.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_and.S,v 1.2.4.2 2008/01/09 01:21:00 matt Exp $ */ | 1 | /* atomic_and.S,v 1.2.4.2 2008/01/09 01:21:00 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -31,40 +31,40 @@ | @@ -31,40 +31,40 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_and_32) | 43 | ENTRY_NOPROFILE(_atomic_and_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | and r10,r10,r4 | 45 | and %r10,%r10,%r4 | |
46 | stwcx. r10,0,r3 | 46 | stwcx. %r10,0,%r3 | |
47 | bne- 1b | 47 | bne- 1b | |
48 | blr | 48 | blr | |
49 | ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32) | 49 | ATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32) | |
50 | ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32) | 50 | ATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32) | |
51 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | 51 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | |
52 | #if !defined(_LP64) | 52 | #if !defined(_LP64) | |
53 | ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32) | 53 | ATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32) | |
54 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) | 54 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) | |
55 | #endif | 55 | #endif | |
56 | 56 | |||
57 | ENTRY_NOPROFILE(_atomic_and_32_nv) | 57 | ENTRY_NOPROFILE(_atomic_and_32_nv) | |
58 | 1: lwarx r10,0,r3 | 58 | 1: lwarx %r10,0,%r3 | |
59 | and r10,r10,r4 | 59 | and %r10,%r10,%r4 | |
60 | stwcx. r10,0,r3 | 60 | stwcx. %r10,0,%r3 | |
61 | bne- 1b | 61 | bne- 1b | |
62 | mr r3,r10 | 62 | mr %r3,%r10 | |
63 | blr | 63 | blr | |
64 | ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv) | 64 | ATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv) | |
65 | ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv) | 65 | ATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv) | |
66 | STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv) | 66 | STRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv) | |
67 | #if !defined(_LP64) | 67 | #if !defined(_LP64) | |
68 | ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv) | 68 | ATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv) | |
69 | STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv) | 69 | STRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv) | |
70 | #endif | 70 | #endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_cas.S 2008/01/09 01:21:00 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_cas.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: atomic_cas.S,v 1.2.4.2 2008/01/09 01:21:00 matt Exp $ */ | 1 | /* atomic_cas.S,v 1.2.4.2 2008/01/09 01:21:00 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -31,29 +31,41 @@ | @@ -31,29 +31,41 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_cas_32) | 43 | ENTRY_NOPROFILE(_atomic_cas_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | cmpw r10,r4 | 45 | cmpw %r10,%r4 | |
46 | bne- 2f | 46 | bne- 2f | |
47 | stwcx. r5,0,r3 | 47 | stwcx. %r5,0,%r3 | |
48 | bne- 1b | 48 | bne- 1b | |
49 | 2: mr r3,r10 | 49 | 2: mr %r3,%r10 | |
50 | blr | 50 | blr | |
51 | ||||
51 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | 52 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | |
52 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | 53 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | |
53 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 54 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
54 | #if !defined(_LP64) | 55 | #if !defined(_LP64) | |
55 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) | 56 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) | |
56 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | 57 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | |
57 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32) | 58 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32) | |
58 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | 59 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | |
59 | #endif | 60 | #endif | |
61 | ||||
62 | ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) | |||
63 | STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) | |||
64 | ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) | |||
65 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) | |||
66 | #if !defined(_LP64) | |||
67 | ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32) | |||
68 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32) | |||
69 | ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32) | |||
70 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32) | |||
71 | #endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_dec.S 2008/01/09 01:21:01 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_dec.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_dec.S,v 1.2.4.2 2008/01/09 01:21:01 matt Exp $ */ | 1 | /* atomic_dec.S,v 1.2.4.2 2008/01/09 01:21:01 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -31,44 +31,44 @@ | @@ -31,44 +31,44 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_dec_32) | 43 | ENTRY_NOPROFILE(_atomic_dec_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | addi r10,r10,-1 | 45 | addi %r10,%r10,-1 | |
46 | stwcx. r10,0,r3 | 46 | stwcx. %r10,0,%r3 | |
47 | bne- 1b | 47 | bne- 1b | |
48 | blr | 48 | blr | |
49 | ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32) | 49 | ATOMIC_OP_ALIAS(atomic_dec_32,_atomic_dec_32) | |
50 | ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32) | 50 | ATOMIC_OP_ALIAS(atomic_dec_uint,_atomic_dec_32) | |
51 | STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32) | 51 | STRONG_ALIAS(_atomic_dec_uint,_atomic_dec_32) | |
52 | #if !defined(_LP64) | 52 | #if !defined(_LP64) | |
53 | ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32) | 53 | ATOMIC_OP_ALIAS(atomic_dec_ulong,_atomic_dec_32) | |
54 | STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32) | 54 | STRONG_ALIAS(_atomic_dec_ulong,_atomic_dec_32) | |
55 | ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_32) | 55 | ATOMIC_OP_ALIAS(atomic_dec_ptr,_atomic_dec_32) | |
56 | STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32) | 56 | STRONG_ALIAS(_atomic_dec_ptr,_atomic_dec_32) | |
57 | #endif | 57 | #endif | |
58 | 58 | |||
59 | ENTRY_NOPROFILE(_atomic_dec_32_nv) | 59 | ENTRY_NOPROFILE(_atomic_dec_32_nv) | |
60 | 1: lwarx r10,0,r3 | 60 | 1: lwarx %r10,0,%r3 | |
61 | addi r10,r10,-1 | 61 | addi %r10,%r10,-1 | |
62 | stwcx. r10,0,r3 | 62 | stwcx. %r10,0,%r3 | |
63 | bne- 1b | 63 | bne- 1b | |
64 | mr r3,r10 | 64 | mr %r3,%r10 | |
65 | blr | 65 | blr | |
66 | ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv) | 66 | ATOMIC_OP_ALIAS(atomic_dec_32_nv,_atomic_dec_32_nv) | |
67 | ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv) | 67 | ATOMIC_OP_ALIAS(atomic_dec_uint_nv,_atomic_dec_32_nv) | |
68 | STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv) | 68 | STRONG_ALIAS(_atomic_dec_uint_nv,_atomic_dec_32_nv) | |
69 | #if !defined(_LP64) | 69 | #if !defined(_LP64) | |
70 | ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv) | 70 | ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_32_nv) | |
71 | STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv) | 71 | STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_32_nv) | |
72 | ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv) | 72 | ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_32_nv) | |
73 | STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv) | 73 | STRONG_ALIAS(_atomic_dec_ptr_nv,_atomic_dec_32_nv) | |
74 | #endif | 74 | #endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_inc.S 2008/01/09 01:21:01 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_inc.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_inc.S,v 1.2.4.2 2008/01/09 01:21:01 matt Exp $ */ | 1 | /* atomic_inc.S,v 1.2.4.2 2008/01/09 01:21:01 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -31,44 +31,44 @@ | @@ -31,44 +31,44 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_inc_32) | 43 | ENTRY_NOPROFILE(_atomic_inc_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | addi r10,r10,1 | 45 | addi %r10,%r10,1 | |
46 | stwcx. r10,0,r3 | 46 | stwcx. %r10,0,%r3 | |
47 | bne- 1b | 47 | bne- 1b | |
48 | blr | 48 | blr | |
49 | ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32) | 49 | ATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32) | |
50 | ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32) | 50 | ATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32) | |
51 | STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32) | 51 | STRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32) | |
52 | #if !defined(_LP64) | 52 | #if !defined(_LP64) | |
53 | ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32) | 53 | ATOMIC_OP_ALIAS(atomic_inc_ulong,_atomic_inc_32) | |
54 | STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32) | 54 | STRONG_ALIAS(_atomic_inc_ulong,_atomic_inc_32) | |
55 | ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_32) | 55 | ATOMIC_OP_ALIAS(atomic_inc_ptr,_atomic_inc_32) | |
56 | STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32) | 56 | STRONG_ALIAS(_atomic_inc_ptr,_atomic_inc_32) | |
57 | #endif | 57 | #endif | |
58 | 58 | |||
59 | ENTRY_NOPROFILE(_atomic_inc_32_nv) | 59 | ENTRY_NOPROFILE(_atomic_inc_32_nv) | |
60 | 1: lwarx r10,0,r3 | 60 | 1: lwarx %r10,0,%r3 | |
61 | addi r10,r10,1 | 61 | addi %r10,%r10,1 | |
62 | stwcx. r10,0,r3 | 62 | stwcx. %r10,0,%r3 | |
63 | bne- 1b | 63 | bne- 1b | |
64 | mr r3,r10 | 64 | mr %r3,%r10 | |
65 | blr | 65 | blr | |
66 | ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv) | 66 | ATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32_nv) | |
67 | ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv) | 67 | ATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32_nv) | |
68 | STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv) | 68 | STRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32_nv) | |
69 | #if !defined(_LP64) | 69 | #if !defined(_LP64) | |
70 | ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv) | 70 | ATOMIC_OP_ALIAS(atomic_inc_ulong_nv,_atomic_inc_32_nv) | |
71 | STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv) | 71 | STRONG_ALIAS(_atomic_inc_ulong_nv,_atomic_inc_32_nv) | |
72 | ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv) | 72 | ATOMIC_OP_ALIAS(atomic_inc_ptr_nv,_atomic_inc_32_nv) | |
73 | STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv) | 73 | STRONG_ALIAS(_atomic_inc_ptr_nv,_atomic_inc_32_nv) | |
74 | #endif | 74 | #endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h 2008/01/09 01:21:01 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_op_asm.h 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_op_asm.h,v 1.2.4.2 2008/01/09 01:21:01 matt Exp $ */ | 1 | /* atomic_op_asm.h,v 1.2.4.2 2008/01/09 01:21:01 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -29,26 +29,27 @@ | @@ -29,26 +29,27 @@ | |||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 30 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #ifndef _ATOMIC_OP_ASM_H_ | 39 | #ifndef _ATOMIC_OP_ASM_H_ | |
40 | #define _ATOMIC_OP_ASM_H_ | 40 | #define _ATOMIC_OP_ASM_H_ | |
41 | 41 | |||
42 | #define _NOREGNAMES | |||
42 | #include <machine/asm.h> | 43 | #include <machine/asm.h> | |
43 | 44 | |||
44 | #if defined(_KERNEL) | 45 | #if defined(_KERNEL) | |
45 | 46 | |||
46 | #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) | 47 | #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) | |
47 | 48 | |||
48 | #else /* _KERNEL */ | 49 | #else /* _KERNEL */ | |
49 | 50 | |||
50 | #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) | 51 | #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) | |
51 | 52 | |||
52 | #endif /* _KERNEL */ | 53 | #endif /* _KERNEL */ | |
53 | 54 | |||
54 | #endif /* _ATOMIC_OP_ASM_H_ */ | 55 | #endif /* _ATOMIC_OP_ASM_H_ */ |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_or.S 2008/01/09 01:21:02 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_or.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_or.S,v 1.2.4.2 2008/01/09 01:21:02 matt Exp $ */ | 1 | /* atomic_or.S,v 1.2.4.2 2008/01/09 01:21:02 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -31,40 +31,40 @@ | @@ -31,40 +31,40 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_or_32) | 43 | ENTRY_NOPROFILE(_atomic_or_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | or r10,r10,r4 | 45 | or %r10,%r10,%r4 | |
46 | stwcx. r10,0,r3 | 46 | stwcx. %r10,0,%r3 | |
47 | bne- 1b | 47 | bne- 1b | |
48 | blr | 48 | blr | |
49 | ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32) | 49 | ATOMIC_OP_ALIAS(atomic_or_32,_atomic_or_32) | |
50 | ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32) | 50 | ATOMIC_OP_ALIAS(atomic_or_uint,_atomic_or_32) | |
51 | STRONG_ALIAS(_atomic_or_uint,_atomic_or_32) | 51 | STRONG_ALIAS(_atomic_or_uint,_atomic_or_32) | |
52 | #if !defined(_LP64) | 52 | #if !defined(_LP64) | |
53 | ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32) | 53 | ATOMIC_OP_ALIAS(atomic_or_ulong,_atomic_or_32) | |
54 | STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32) | 54 | STRONG_ALIAS(_atomic_or_ulong,_atomic_or_32) | |
55 | #endif | 55 | #endif | |
56 | 56 | |||
57 | ENTRY_NOPROFILE(_atomic_or_32_nv) | 57 | ENTRY_NOPROFILE(_atomic_or_32_nv) | |
58 | 1: lwarx r10,0,r3 | 58 | 1: lwarx %r10,0,%r3 | |
59 | or r10,r10,r4 | 59 | or %r10,%r10,%r4 | |
60 | stwcx. r10,0,r3 | 60 | stwcx. %r10,0,%r3 | |
61 | bne- 1b | 61 | bne- 1b | |
62 | mr r3,r10 | 62 | mr %r3,%r10 | |
63 | blr | 63 | blr | |
64 | ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv) | 64 | ATOMIC_OP_ALIAS(atomic_or_32_nv,_atomic_or_32_nv) | |
65 | ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv) | 65 | ATOMIC_OP_ALIAS(atomic_or_uint_nv,_atomic_or_32_nv) | |
66 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | 66 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | |
67 | #if !defined(_LP64) | 67 | #if !defined(_LP64) | |
68 | ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) | 68 | ATOMIC_OP_ALIAS(atomic_or_ulong_nv,_atomic_or_32_nv) | |
69 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) | 69 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_32_nv) | |
70 | #endif | 70 | #endif |
--- src/common/lib/libc/arch/powerpc/atomic/atomic_swap.S 2008/01/09 01:21:02 1.2.4.2
+++ src/common/lib/libc/arch/powerpc/atomic/atomic_swap.S 2008/03/23 00:12:42 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_swap.S,v 1.2.4.2 2008/01/09 01:21:02 matt Exp $ */ | 1 | /* atomic_swap.S,v 1.2.4.2 2008/01/09 01:21:02 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -31,27 +31,27 @@ | @@ -31,27 +31,27 @@ | |||
31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_swap_32) | 43 | ENTRY_NOPROFILE(_atomic_swap_32) | |
44 | 1: lwarx r10,0,r3 | 44 | 1: lwarx %r10,0,%r3 | |
45 | stwcx. r4,0,r3 | 45 | stwcx. %r4,0,%r3 | |
46 | bne- 1b | 46 | bne- 1b | |
47 | mr r3,r10 | 47 | mr %r3,%r10 | |
48 | blr | 48 | blr | |
49 | ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32) | 49 | ATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32) | |
50 | ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32) | 50 | ATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32) | |
51 | STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) | 51 | STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) | |
52 | #if !defined(_LP64) | 52 | #if !defined(_LP64) | |
53 | ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32) | 53 | ATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32) | |
54 | STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32) | 54 | STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32) | |
55 | ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32) | 55 | ATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32) | |
56 | STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32) | 56 | STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32) | |
57 | #endif | 57 | #endif |
/* $NetBSD: bcopy.S,v 1.1.2.2 2008/03/23 00:12:42 matt Exp $ */
#define _BCOPY
#include "memmove.S"
/* $NetBSD: memcmp.S,v 1.2.2.2 2008/03/23 00:12:42 matt Exp $ */
/* stropt/memcmp.S, pl_string_common, pl_linux 10/11/04 11:45:35
* ==========================================================================
* Optimized memcmp implementation for IBM PowerPC 405/440.
*
* Copyright (c) 2003, IBM Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* * 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.
* * Neither the name of IBM 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 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 OWNER 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.
*
* ==========================================================================
*
* Function: Compare two character strings (up to n characters)
*
* int memcmp(const char *s1, const char *s2, int n)
*
* Input: r3 - buffer 1 address
* r4 - buffer 2 address
* r5 - maximum characters to compare
* Output: r3 <0 (less), 0 (equal), >0 (greater)
*
* ==========================================================================
*/
#define _NOREGNAMES
#include <machine/asm.h>
.text
.align 4
/* LINTSTUB: Func: void *memcmp(const void *, const void *, size_t) */
ENTRY(memcmp)
/*
* Check count passed in R5. If zero, return 0; otherwise continue.
*/
cmpwi %r5,0
beq- ret_0;
/*
* Most of the time the difference is found in the first
* several bytes. The following code minimizes the number
* of load operations for short compares.
*/
mr %r11, %r3 /* Save buffer 1 */
again:
not %r10, %r4 /* buffer 2: bytes to page bdy */
rlwinm. %r10, %r10,29,23,31 /* buffer 2: dwords to page bdy */
beq- bytebybyte /* If < 8 bytes to the page bdy */
/* do byte by byte */
lwz %r8, 0(%r4) /* load 1st buffer 2 word */
not %r12, %r11 /* buffer 1: bytes to page bdy */
rlwinm. %r12, %r12,29,23,31 /* buffer 1: dwords to page bdy */
beq- bytebybyte /* If < 8 bytes to the page bdy */
/* do byte by byte */
lwz %r6, 0(%r11) /* load 1st buffer 1 word */
cmpwi %r5, 4 /* If remaining count <= 4 */
ble+ first4 /* handle specially. DWG */
cmplw %r8, %r6 /* compare buffer 2 and buffer 1*/
bne+ all_done /* different => we're done */
lwzu %r9, 4(%r4) /* load 2nd buffer 2 word */
lwzu %r7, 4(%r11) /* load 2nd buffer 1 word */
cmpwi %r5, 8 /* If remaining count <= 8 */
ble+ last4 /* handle specially. DWG */
cmplw %r9, %r7 /* compare buffer 2 and buffer 1*/
bne+ all_done /* different => we're done */
addi %r5, %r5, -8 /* Update character counter DWG */
addi %r10, %r4, 0x0004 /* DWG*/
not %r10, %r10 /* buffer 2: bytes to page bdy DWG */
rlwinm. %r10, %r10,29,23,31 /* buffer 2: dwords to page bdy DWG */
addi %r12, %r11, 0x0004 /* DWG */
not %r12, %r12 /* buffer 1: bytes to page bdy DWG */
rlwinm. %r12, %r12,29,23,31 /* buffer 1: dwords to page bdy DWG */
/* The following section prior to loop: figures out whether */
/* the buffer 1 or buffer 2 is closer to the page boundary. */
/* The main loop count is then set up to reflect the number of */
/* double words of the buffer that is closest */
cmpw %r10, %r12 /* Find closest */
blt lt
mr %r10, %r12
lt:
srwi %r12, %r5, 3 /* Double check the total count */
cmpw %r10, %r12 /* limitation */
blt lt2
mr %r10, %r12 /* DWG */
lt2: /* DWG */
cmpwi %r10, 0 /* DWG */
bne lt3 /* DWG */
addi %r4, %r4, 0x0004 /* DWG */
addi %r11,%r11,0x0004 /* DWG */
b again /* DWG */
lt3: /* DWG */
mtctr %r10 /* dword count for loop */
lwzu %r6, 4(%r11) /* pre-load buffer 1 word */
b in /* To the loop */
loop: /* main loop */
cmplw %r8, %r6 /* Compare first buffer 2 word */
bne- all_done /* with first buffer 1 word */
/* If different, we're done */
cmplw %r9, %r7 /* Compare second buffer 2 word */
/* with second buffer 1 word */
lwzu %r6, 4(%r11) /* pre-load buffer 1 word */
bne- all_done /* If different, we're done */
in:
lwzu %r7, 4(%r11) /* pre-load buffer 1 word */
lwzu %r8, 4(%r4) /* pre-load buffer 2 word */
lwzu %r9, 4(%r4) /* pre-load buffer 2 word */
bdnz+ loop /* Do more DW's if cnt > 0 */
/*mfctr %r12*/ /*DWG*/ /* number of dwords left */
/*subf %r10, %r12, %r10*/ /*DWG*//* number of dwords compared */
slwi %r10, %r10, 3
subf %r5, %r10, %r5 /* adjust byte counter */
/*bne+ partial*/ /*DWG*/ /* If less than 8 bytes, handle */
/* specially */
/*cmpwi %r5, 8*/ /* Removed. DWG */
/*blt partial*/ /* Removed. DWG */
/*addic %r5, %r5, -8*/ /*DWG*/ /* Subtract two words from count*/
cmplw %r8, %r6 /* compare last dword */
addi %r4, %r4, 4
bne- all_done
cmplw %r9, %r7
addi %r11, %r11, 4
bne- all_done
bytebybyte:
/* We've gotten close to a page boundary: do a byte-byte-byte
* compare for the following 8 bytes, and then go back to
* the full-word compare loop.
*/
li %r3, 8 /* loop count */
cmpw %r3, %r5 /* take min(8, counter) */
ble f2
mr. %r3, %r5
beqlr
f2:
mtctr %r3
subf %r5, %r3, %r5 /* adjust counter */
bbb:
lbz %r6, 0(%r11) /* byte copy loop */
addi %r11, %r11, 1
lbz %r8, 0(%r4)
addi %r4, %r4, 1
cmplw %r8, %r6
bdnzt+ eq, bbb
bne all_done
cmpwi %r5, 0
bgt again /* handle the rest */
xor %r3,%r3,%r3
blr
#if 0 /* Removed code section. DWG */
partial:
mr. %r3, %r5
beqlr /* If count -> 0, we're done */
f1:
subfic %r3, %r3, 4 /* zero/end in first word? */
cmpwi %r3, 0
blt last4
#endif /* DWG */
first4:
subfic %r3, %r5, 4 /* If count <= 4, handle */
rlwinm %r3, %r3, 3, 0, 31 /* count *= 8 */
srw %r6, %r6, %r3 /* align 1st buffer 1 word */
srw %r8, %r8, %r3 /* align 1st buffer 2 word */
cmplw %r8, %r6 /* get result */
bne all_done
xor %r3,%r3,%r3
blr
last4:
subfic %r10, %r5, 8 /*DWG*/
rlwinm %r10, %r10, 3, 0, 31 /* count *= 8 */
srw %r7, %r7, %r10 /* align 2nd buffer 1 word */
srw %r9, %r9, %r10 /* align 2nd buffer 2 word */
cmplw %r9, %r7 /* get result */
bne all_done
ret_0:
xor %r3,%r3,%r3 /* Equal result */
blr
all_done:
blt finish_lt
addi %r3,0,-1 /* Less than result */
blr
finish_lt:
addi %r3,0,1 /* Greater than result */
blr
/* $NetBSD: memcpy.S,v 1.2.2.2 2008/03/23 00:12:43 matt Exp $ */
/* stropt/memcpy_440.S, pl_string_common, pl_linux 10/11/04 11:45:36
* ==========================================================================
* Optimized memcpy implementation for IBM PowerPC 440.
*
* Copyright (c) 2003, IBM Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* * 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.
* * Neither the name of IBM 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 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 OWNER 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.
*
* ==========================================================================
*
* Function: Copy n bytes of the source to the destination. Behavior is
* undefined for objects that overlap.
*
*
* void *memcpy(void * dest, const void * src, int n)
*
* Input: r3 - destination address
* r4 - source address
* r5 - byte count
* Output: r3 - destination address
*
* ==========================================================================
*/
#define _NOREGNAMES
#include <machine/asm.h>
.text
.align 4
/* LINTSTUB: Func: void *memcpy(void *, const void *, size_t) */
ENTRY(memcpy)
/*
* Check count passed in R5. If zero, return; otherwise continue.
*/
cmpwi %r5,0
beqlr-
mr %r8, %r3 /* Copy dst (return value) */
addi %r4, %r4, -4 /* Prepare for main loop's auto */
addi %r8, %r8, -4 /* update */
srwi. %r9,%r5,2 /* Word count -> r9 */
beq- last1 /* Partial copy if <4 bytes */
mtctr %r9 /* Word cnt in CTR for loop */
lwzu %r7, 4(%r4) /* Preload for main loop */
b g1
g0: /* Main loop */
lwzu %r7, 4(%r4) /* Load a new word */
stwu %r6, 4(%r8) /* Store previous word */
g1:
bdz- last /* Dec ctr and exit loop if no */
/* more words */
lwzu %r6, 4(%r4) /* Load another word */
stwu %r7, 4(%r8) /* Store previous word */
bdnz+ g0 /* Dec ctr and continue loop if */
/* more words */
mr %r7, %r6
last:
stwu %r7, 4(%r8) /* Store last word */
last1: /* Byte-by-byte copy */
clrlwi. %r5,%r5,30
beqlr
mtctr %r5
lbzu %r6, 4(%r4) /* 1st byte: update by word */
stbu %r6, 4(%r8)
bdzlr-
last2:
lbzu %r6, 1(%r4) /* Handle the rest */
stbu %r6, 1(%r8)
bdnz+ last2
blr
/* $NetBSD: memmove.S,v 1.2.2.2 2008/03/23 00:12:43 matt Exp $ */
/* stropt/memmove.S, pl_string_common, pl_linux 10/11/04 11:45:37
* ==========================================================================
* Optimized memmove implementation for IBM PowerPC 405/440.
*
* Copyright (c) 2003, IBM Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* * 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.
* * Neither the name of IBM 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 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 OWNER 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.
*
* ==========================================================================
*
* Function: Move memory area (handles overlapping regions)
*
* void *memmove(void * dest, const void * src, int n)
*
* Input: r3 - destination address
* r4 - source address
* r5 - byte count
* Output: r3 - destination address
*
* ==========================================================================
*/
#define _NOREGNAMES
#include <machine/asm.h>
.text
.align 4
#ifdef _BCOPY
/* bcopy = memcpy/memmove with arguments reversed. */
/* LINTSTUB: Func: void bcopy(void *, void *, size_t) */
ENTRY(bcopy)
mr %r6, %r3 /* swap src/dst */
mr %r3, %r4
mr %r4, %r6
#else
/* LINTSTUB: Func: void *memmove(void *, const void *, size_t) */
ENTRY(memmove)
#endif
mr %r8, %r3 /* Save dst (return value) */
cmpw %r4, %r8 /* Branch to reverse if */
blt reverse /* src < dest. Don't want to */
/* overwrite end of src with */
/* start of dest */
addi %r4, %r4, -4 /* Back up src and dst pointers */
addi %r8, %r8, -4 /* due to auto-update of 'load' */
srwi. %r9,%r5,2 /* How many words in total cnt */
beq- last1 /* Handle byte by byte if < 4 */
/* bytes total */
mtctr %r9 /* Count of words for loop */
lwzu %r7, 4(%r4) /* Preload first word */
b g1
g0: /* Main loop */
lwzu %r7, 4(%r4) /* Load a new word */
stwu %r6, 4(%r8) /* Store previous word */
g1:
bdz- last /* Dec cnt, and branch if just */
/* one word to store */
lwzu %r6, 4(%r4) /* Load another word */
stwu %r7, 4(%r8) /* Store previous word */
bdnz+ g0 /* Dec cnt, and loop again if */
/* more words */
mr %r7, %r6 /* If word count -> 0, then... */
last:
stwu %r7, 4(%r8) /* ... store last word */
last1: /* Byte-by-byte copy */
clrlwi. %r5,%r5,30 /* If count -> 0, then ... */
beqlr /* we're done */
mtctr %r5 /* else load count for loop */
lbzu %r6, 4(%r4) /* 1st byte: update addr by 4 */
stbu %r6, 4(%r8) /* since we pre-adjusted by 4 */
bdzlr- /* in anticipation of main loop */
last2:
lbzu %r6, 1(%r4) /* But handle the rest by */
stbu %r6, 1(%r8) /* updating addr by 1 */
bdnz+ last2
blr
/* We're here since src < dest. Don't want to overwrite end of */
/* src with start of dest */
reverse:
add %r4, %r4, %r5 /* Work from end to beginning */
add %r8, %r8, %r5 /* so add count to string ptrs */
srwi. %r9,%r5,2 /* Words in total count */
beq- rlast1 /* Handle byte by byte if < 4 */
/* bytes total */
mtctr %r9 /* Count of words for loop */
lwzu %r7, -4(%r4) /* Preload first word */
b rg1
rg0: /* Main loop */
lwzu %r7, -4(%r4) /* Load a new word */
stwu %r6, -4(%r8) /* Store previous word */
rg1:
bdz- rlast /* Dec cnt, and branch if just */
/* one word to store */
lwzu %r6, -4(%r4) /* Load another word */
stwu %r7, -4(%r8) /* Store previous word */
bdnz+ rg0 /* Dec cnt, and loop again if */
/* more words */
mr %r7, %r6 /* If word count -> 0, then... */
rlast:
stwu %r7, -4(%r8) /* ... store last word */
rlast1: /* Byte-by-byte copy */
clrlwi. %r5,%r5,30 /* If count -> 0, then... */
beqlr /* ... we're done */
mtctr %r5 /* else load count for loop */
rlast2:
lbzu %r6, -1(%r4) /* Handle the rest, byte by */
stbu %r6, -1(%r8) /* byte */
bdnz+ rlast2 /* Dec ctr, and branch if more */
/* bytes left */
blr
--- src/common/lib/libc/arch/powerpc64/atomic/Makefile.inc 2008/01/09 01:21:03 1.2.4.2
+++ src/common/lib/libc/arch/powerpc64/atomic/Makefile.inc 2008/03/23 00:12:43 1.2.4.3
@@ -1,8 +1,14 @@ | @@ -1,8 +1,14 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.2.4.2 2008/01/09 01:21:03 matt Exp $ | 1 | # Makefile.inc,v 1.2.4.2 2008/01/09 01:21:03 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | 5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | |
6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | 6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | |
7 | 7 | |||
8 | .endif | 8 | .endif | |
9 | ||||
10 | .if defined(LIB) && (${LIB} == "c") | |||
11 | ||||
12 | SRCS+= atomic_init_cas.c | |||
13 | ||||
14 | .endif |
--- src/common/lib/libc/arch/powerpc64/atomic/Attic/atomic_cas.S 2008/01/09 01:21:04 1.2.4.2
+++ src/common/lib/libc/arch/powerpc64/atomic/Attic/atomic_cas.S 2008/03/23 00:12:43 1.2.4.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: atomic_cas.S,v 1.2.4.2 2008/01/09 01:21:04 matt Exp $ */ | 1 | /* atomic_cas.S,v 1.2.4.2 2008/01/09 01:21:04 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -40,18 +40,26 @@ | @@ -40,18 +40,26 @@ | |||
40 | 40 | |||
41 | #include "../../powerpc/atomic/atomic_cas.S" | 41 | #include "../../powerpc/atomic/atomic_cas.S" | |
42 | 42 | |||
43 | .text | 43 | .text | |
44 | 44 | |||
45 | ENTRY_NOPROFILE(_atomic_cas_64) | 45 | ENTRY_NOPROFILE(_atomic_cas_64) | |
46 | 1: ldarx r10,0,r3 | 46 | 1: ldarx r10,0,r3 | |
47 | cmpd r10,r4 | 47 | cmpd r10,r4 | |
48 | bne- 2f | 48 | bne- 2f | |
49 | stdcx. r5,0,r3 | 49 | stdcx. r5,0,r3 | |
50 | bne- 1b | 50 | bne- 1b | |
51 | 2: mr r3,r10 | 51 | 2: mr r3,r10 | |
52 | blr | 52 | blr | |
53 | ||||
53 | ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) | 54 | ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) | |
54 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64) | 55 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_64) | |
55 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) | 56 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) | |
56 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64) | 57 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_64) | |
57 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) | 58 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) | |
59 | ||||
60 | ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64) | |||
61 | STRONG_ALIAS(_atomic_cas_64_ni,_atomic_cas_64) | |||
62 | ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_64) | |||
63 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64) | |||
64 | ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_64) | |||
65 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64) |
--- src/common/lib/libc/arch/sh3/atomic/Makefile.inc 2008/01/09 01:21:07 1.1.4.2
+++ src/common/lib/libc/arch/sh3/atomic/Makefile.inc 2008/03/23 00:12:43 1.1.4.3
@@ -1,10 +1,16 @@ | @@ -1,10 +1,16 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.1.4.2 2008/01/09 01:21:07 matt Exp $ | 1 | # Makefile.inc,v 1.1.4.2 2008/01/09 01:21:07 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | 5 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | |
6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | 6 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | |
7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | 7 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | |
8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c | 8 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c | |
9 | 9 | |||
10 | .endif | 10 | .endif | |
11 | ||||
12 | .if defined(LIB) && (${LIB} == "c") | |||
13 | ||||
14 | SRCS+= atomic_init_testset.c | |||
15 | ||||
16 | .endif |
--- src/common/lib/libc/arch/sh3/string/memset.S 2005/12/20 19:28:50 1.1
+++ src/common/lib/libc/arch/sh3/string/memset.S 2008/03/23 00:12:43 1.1.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $ */ | 1 | /* memset.S,v 1.1 2005/12/20 19:28:50 christos Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002 SHIMIZU Ryo. All rights reserved. | 4 | * Copyright (c) 2002 SHIMIZU Ryo. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. The name of the author may not be used to endorse or promote products | 14 | * 3. The name of the author may not be used to endorse or promote products | |
@@ -19,27 +19,27 @@ | @@ -19,27 +19,27 @@ | |||
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <machine/asm.h> | 29 | #include <machine/asm.h> | |
30 | 30 | |||
31 | #if defined(LIBC_SCCS) && !defined(lint) | 31 | #if defined(LIBC_SCCS) && !defined(lint) | |
32 | RCSID("$NetBSD: memset.S,v 1.1 2005/12/20 19:28:50 christos Exp $") | 32 | RCSID("memset.S,v 1.1 2005/12/20 19:28:50 christos Exp") | |
33 | #endif | 33 | #endif | |
34 | 34 | |||
35 | #define REG_PTR r0 | 35 | #define REG_PTR r0 | |
36 | #define REG_TMP1 r1 | 36 | #define REG_TMP1 r1 | |
37 | 37 | |||
38 | #ifdef BZERO | 38 | #ifdef BZERO | |
39 | # define REG_C r2 | 39 | # define REG_C r2 | |
40 | # define REG_DST r4 | 40 | # define REG_DST r4 | |
41 | # define REG_LEN r5 | 41 | # define REG_LEN r5 | |
42 | #else | 42 | #else | |
43 | # define REG_DST0 r3 | 43 | # define REG_DST0 r3 | |
44 | # define REG_DST r4 | 44 | # define REG_DST r4 | |
45 | # define REG_C r5 | 45 | # define REG_C r5 | |
@@ -263,36 +263,36 @@ aligned: | @@ -263,36 +263,36 @@ aligned: | |||
263 | 263 | |||
264 | unaligned_dst: | 264 | unaligned_dst: | |
265 | mov #1,REG_TMP1 | 265 | mov #1,REG_TMP1 | |
266 | tst REG_TMP1,REG_DST /* if (dst & 1) { */ | 266 | tst REG_TMP1,REG_DST /* if (dst & 1) { */ | |
267 | add #1,REG_TMP1 | 267 | add #1,REG_TMP1 | |
268 | bt/s 2f | 268 | bt/s 2f | |
269 | tst REG_TMP1,REG_DST | 269 | tst REG_TMP1,REG_DST | |
270 | mov.b REG_C,@REG_DST /* *dst++ = c; */ | 270 | mov.b REG_C,@REG_DST /* *dst++ = c; */ | |
271 | add #1,REG_DST | 271 | add #1,REG_DST | |
272 | tst REG_TMP1,REG_DST | 272 | tst REG_TMP1,REG_DST | |
273 | 2: /* } */ | 273 | 2: /* } */ | |
274 | /* if (dst & 2) { */ | 274 | /* if (dst & 2) { */ | |
275 | bt 4f | 275 | bt 4f | |
276 | mov.w REG_C,@REG_DST /* *(u_int16_t*)dst++ = c; */ | 276 | mov.w REG_C,@REG_DST /* *(uint16_t*)dst++ = c; */ | |
277 | add #2,REG_DST | 277 | add #2,REG_DST | |
278 | 4: /* } */ | 278 | 4: /* } */ | |
279 | 279 | |||
280 | 280 | |||
281 | tst #3,REG_PTR /* if (ptr & 3) { */ | 281 | tst #3,REG_PTR /* if (ptr & 3) { */ | |
282 | bt/s 4f /* */ | 282 | bt/s 4f /* */ | |
283 | unaligned_len: | 283 | unaligned_len: | |
284 | tst #1,REG_PTR /* if (ptr & 1) { */ | 284 | tst #1,REG_PTR /* if (ptr & 1) { */ | |
285 | bt/s 2f | 285 | bt/s 2f | |
286 | tst #2,REG_PTR | 286 | tst #2,REG_PTR | |
287 | mov.b REG_C,@-REG_PTR /* --ptr = c; */ | 287 | mov.b REG_C,@-REG_PTR /* --ptr = c; */ | |
288 | 2: /* } */ | 288 | 2: /* } */ | |
289 | /* if (ptr & 2) { */ | 289 | /* if (ptr & 2) { */ | |
290 | bt 4f | 290 | bt 4f | |
291 | mov.w REG_C,@-REG_PTR /* *--(u_int16_t*)ptr = c; */ | 291 | mov.w REG_C,@-REG_PTR /* *--(uint16_t*)ptr = c; */ | |
292 | 4: /* } */ | 292 | 4: /* } */ | |
293 | /* } */ | 293 | /* } */ | |
294 | 294 | |||
295 | mov REG_PTR,REG_LEN | 295 | mov REG_PTR,REG_LEN | |
296 | bra aligned | 296 | bra aligned | |
297 | sub REG_DST,REG_LEN | 297 | sub REG_DST,REG_LEN | |
298 | 298 |
--- src/common/lib/libc/arch/sparc/atomic/Makefile.inc 2008/01/09 01:21:07 1.4.2.2
+++ src/common/lib/libc/arch/sparc/atomic/Makefile.inc 2008/03/23 00:12:43 1.4.2.3
@@ -1,23 +1,34 @@ | @@ -1,23 +1,34 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.4.2.2 2008/01/09 01:21:07 matt Exp $ | 1 | # Makefile.inc,v 1.4.2.2 2008/01/09 01:21:07 matt Exp | |
2 | 2 | |||
3 | .include <bsd.own.mk> | 3 | .include <bsd.own.mk> | |
4 | 4 | |||
5 | .if ${MACHINE} == "sparc64" | 5 | .if ${MACHINE} == "sparc64" | |
6 | 6 | |||
7 | SPARC64DIR= ${.PARSEDIR}/../../sparc64/atomic | 7 | SPARC64DIR= ${.PARSEDIR}/../../sparc64/atomic | |
8 | .PATH: ${SPARC64DIR} | 8 | .PATH.c: ${SPARC64DIR} | |
9 | .PATH.S: ${SPARC64DIR} | |||
9 | 10 | |||
10 | .include "${SPARC64DIR}/Makefile.inc" | 11 | .include "${SPARC64DIR}/Makefile.inc" | |
11 | 12 | |||
12 | .else | 13 | .else | |
13 | . if defined(LIB) && (${LIB} == "kern") | |||
14 | 14 | |||
15 | . if defined(LIB) | |||
16 | ||||
17 | . if (${LIB} == "kern" || ${LIB} == "c") | |||
15 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | 18 | SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \ | |
16 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | 19 | atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \ | |
17 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | 20 | atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \ | |
18 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c \ | 21 | atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops.S | |
19 | atomic_cas.S membar_ops.S | 22 | . endif | |
23 | ||||
24 | . if (${LIB} == "kern") | |||
25 | SRCS+= atomic_cas.S | |||
26 | . endif | |||
27 | ||||
28 | . if (${LIB} == "c") | |||
29 | SRCS+= atomic_init_testset.c | |||
30 | . endif | |||
20 | 31 | |||
21 | . endif | 32 | . endif | |
22 | 33 | |||
23 | .endif | 34 | .endif |
--- src/common/lib/libc/arch/sparc/atomic/atomic_cas.S 2008/01/09 01:21:08 1.4.4.2
+++ src/common/lib/libc/arch/sparc/atomic/atomic_cas.S 2008/03/23 00:12:43 1.4.4.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: atomic_cas.S,v 1.4.4.2 2008/01/09 01:21:08 matt Exp $ */ | 1 | /* atomic_cas.S,v 1.4.4.2 2008/01/09 01:21:08 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Andrew Doran and Jason R. Thorpe. | 8 | * by Andrew Doran and Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -129,13 +129,22 @@ ENTRY_NOPROFILE(_atomic_cas_32) | @@ -129,13 +129,22 @@ ENTRY_NOPROFILE(_atomic_cas_32) | |||
129 | 129 | |||
130 | 3: RELEASE_INTERLOCK | 130 | 3: RELEASE_INTERLOCK | |
131 | 131 | |||
132 | retl | 132 | retl | |
133 | mov %o3, %o0 ! return old value | 133 | mov %o3, %o0 ! return old value | |
134 | 134 | |||
135 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | 135 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | |
136 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | 136 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | |
137 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 137 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
138 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) | 138 | ATOMIC_OP_ALIAS(atomic_cas_ulong,_atomic_cas_32) | |
139 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | 139 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_32) | |
140 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32) | 140 | ATOMIC_OP_ALIAS(atomic_cas_ptr,_atomic_cas_32) | |
141 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | 141 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32) | |
142 | ||||
143 | ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) | |||
144 | STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) | |||
145 | ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) | |||
146 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) | |||
147 | ATOMIC_OP_ALIAS(atomic_cas_ulong_ni,_atomic_cas_32) | |||
148 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_32) | |||
149 | ATOMIC_OP_ALIAS(atomic_cas_ptr_ni,_atomic_cas_32) | |||
150 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_32) |
--- src/common/lib/libc/arch/sparc/atomic/atomic_op_asm.h 2008/01/09 01:21:08 1.3.2.2
+++ src/common/lib/libc/arch/sparc/atomic/atomic_op_asm.h 2008/03/23 00:12:43 1.3.2.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_op_asm.h,v 1.3.2.2 2008/01/09 01:21:08 matt Exp $ */ | 1 | /* atomic_op_asm.h,v 1.3.2.2 2008/01/09 01:21:08 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -35,38 +35,38 @@ | @@ -35,38 +35,38 @@ | |||
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #ifndef _ATOMIC_OP_ASM_H_ | 39 | #ifndef _ATOMIC_OP_ASM_H_ | |
40 | #define _ATOMIC_OP_ASM_H_ | 40 | #define _ATOMIC_OP_ASM_H_ | |
41 | 41 | |||
42 | #include <machine/asm.h> | 42 | #include <machine/asm.h> | |
43 | 43 | |||
44 | #if defined(_KERNEL) | 44 | #if defined(_KERNEL) | |
45 | 45 | |||
46 | #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) | 46 | #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) | |
47 | 47 | |||
48 | #ifdef __sparc64__ | 48 | #ifdef __arch64__ | |
49 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | 49 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | |
50 | #else | 50 | #else | |
51 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | 51 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | |
52 | #endif | 52 | #endif | |
53 | 53 | |||
54 | #else /* _KERNEL */ | 54 | #else /* _KERNEL */ | |
55 | 55 | |||
56 | #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) | 56 | #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) | |
57 | 57 | |||
58 | #ifdef __sparc64__ | 58 | #ifdef __arch64__ | |
59 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_64) | 59 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_64) | |
60 | #else | 60 | #else | |
61 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_32) | 61 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_32) | |
62 | #endif | 62 | #endif | |
63 | 63 | |||
64 | #endif /* _KERNEL */ | 64 | #endif /* _KERNEL */ | |
65 | 65 | |||
66 | #ifdef __sparc64__ | 66 | #ifdef __arch64__ | |
67 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | 67 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | |
68 | #else | 68 | #else | |
69 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | 69 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | |
70 | #endif | 70 | #endif | |
71 | 71 | |||
72 | #endif /* _ATOMIC_OP_ASM_H_ */ | 72 | #endif /* _ATOMIC_OP_ASM_H_ */ |
--- src/common/lib/libc/arch/sparc64/atomic/Makefile.inc 2008/01/09 01:21:09 1.2.4.2
+++ src/common/lib/libc/arch/sparc64/atomic/Makefile.inc 2008/03/23 00:12:43 1.2.4.3
@@ -1,8 +1,14 @@ | @@ -1,8 +1,14 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.2.4.2 2008/01/09 01:21:09 matt Exp $ | 1 | # Makefile.inc,v 1.2.4.2 2008/01/09 01:21:09 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | 5 | SRCS+= atomic_add.S atomic_and.S atomic_cas.S atomic_dec.S \ | |
6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | 6 | atomic_inc.S atomic_or.S atomic_swap.S membar_ops.S | |
7 | 7 | |||
8 | .endif | 8 | .endif | |
9 | ||||
10 | .if defined(LIB) && (${LIB} == "c") | |||
11 | ||||
12 | SRCS+= atomic_init_cas.c | |||
13 | ||||
14 | .endif |
--- src/common/lib/libc/arch/sparc64/atomic/membar_ops.S 2008/01/09 01:21:14 1.2.4.2
+++ src/common/lib/libc/arch/sparc64/atomic/membar_ops.S 2008/03/23 00:12:43 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: membar_ops.S,v 1.2.4.2 2008/01/09 01:21:14 matt Exp $ */ | 1 | /* membar_ops.S,v 1.2.4.2 2008/01/09 01:21:14 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe, and by Andrew Doran. | 8 | * by Jason R. Thorpe, and by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -37,24 +37,25 @@ | @@ -37,24 +37,25 @@ | |||
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | /* These assume Total Store Order (TSO) */ | 43 | /* These assume Total Store Order (TSO) */ | |
44 | 44 | |||
45 | ENTRY_NOPROFILE(_membar_producer) | 45 | ENTRY_NOPROFILE(_membar_producer) | |
46 | retl | 46 | retl | |
47 | nop | 47 | nop | |
48 | 48 | |||
49 | ENTRY_NOPROFILE(_membar_consumer) | 49 | ENTRY_NOPROFILE(_membar_consumer) | |
50 | membar #LoadLoad | |||
50 | retl | 51 | retl | |
51 | membar #LoadLoad | 52 | nop | |
52 | 53 | |||
53 | ATOMIC_OP_ALIAS(membar_producer,_membar_producer) | 54 | ATOMIC_OP_ALIAS(membar_producer,_membar_producer) | |
54 | ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer) | 55 | ATOMIC_OP_ALIAS(membar_consumer,_membar_consumer) | |
55 | ATOMIC_OP_ALIAS(membar_enter,_membar_consumer) | 56 | ATOMIC_OP_ALIAS(membar_enter,_membar_consumer) | |
56 | STRONG_ALIAS(_membar_enter,_membar_consumer) | 57 | STRONG_ALIAS(_membar_enter,_membar_consumer) | |
57 | ATOMIC_OP_ALIAS(membar_exit,_membar_consumer) | 58 | ATOMIC_OP_ALIAS(membar_exit,_membar_consumer) | |
58 | STRONG_ALIAS(_membar_exit,_membar_consumer) | 59 | STRONG_ALIAS(_membar_exit,_membar_consumer) | |
59 | ATOMIC_OP_ALIAS(membar_sync,_membar_consumer) | 60 | ATOMIC_OP_ALIAS(membar_sync,_membar_consumer) | |
60 | STRONG_ALIAS(_membar_sync,_membar_consumer) | 61 | STRONG_ALIAS(_membar_sync,_membar_consumer) |
--- src/common/lib/libc/arch/sparc64/atomic/atomic_cas.S 2008/01/09 01:21:11 1.3.2.2
+++ src/common/lib/libc/arch/sparc64/atomic/atomic_cas.S 2008/03/23 00:12:43 1.3.2.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: atomic_cas.S,v 1.3.2.2 2008/01/09 01:21:11 matt Exp $ */ | 1 | /* atomic_cas.S,v 1.3.2.2 2008/01/09 01:21:11 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
@@ -34,27 +34,40 @@ | @@ -34,27 +34,40 @@ | |||
34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include "atomic_op_asm.h" | 39 | #include "atomic_op_asm.h" | |
40 | 40 | |||
41 | .text | 41 | .text | |
42 | 42 | |||
43 | ENTRY_NOPROFILE(_atomic_cas_32) | 43 | ENTRY_NOPROFILE(_atomic_cas_32) | |
44 | cas [%o0], %o1, %o2 | 44 | cas [%o0], %o1, %o2 | |
45 | retl | 45 | retl | |
46 | mov %o2, %o0 | 46 | mov %o2, %o0 | |
47 | ||||
47 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | 48 | ATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) | |
48 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | 49 | ATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) | |
49 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 50 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
50 | 51 | |||
52 | ATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) | |||
53 | STRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) | |||
54 | ATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) | |||
55 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) | |||
56 | ||||
51 | ENTRY_NOPROFILE(_atomic_cas_64) | 57 | ENTRY_NOPROFILE(_atomic_cas_64) | |
52 | casx [%o0], %o1, %o2 | 58 | casx [%o0], %o1, %o2 | |
53 | retl | 59 | retl | |
54 | mov %o2, %o0 | 60 | mov %o2, %o0 | |
55 | ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) | |||
56 | 61 | |||
62 | ATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) | |||
57 | ATOMIC_OP_ALIAS_SIZE(atomic_cas_ulong,_atomic_cas) | 63 | ATOMIC_OP_ALIAS_SIZE(atomic_cas_ulong,_atomic_cas) | |
58 | STRONG_ALIAS_SIZE(_atomic_cas_ulong,_atomic_cas) | 64 | STRONG_ALIAS_SIZE(_atomic_cas_ulong,_atomic_cas) | |
59 | ATOMIC_OP_ALIAS_SIZE(atomic_cas_ptr,_atomic_cas) | 65 | ATOMIC_OP_ALIAS_SIZE(atomic_cas_ptr,_atomic_cas) | |
60 | STRONG_ALIAS_SIZE(_atomic_cas_ptr,_atomic_cas) | 66 | STRONG_ALIAS_SIZE(_atomic_cas_ptr,_atomic_cas) | |
67 | ||||
68 | ATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64) | |||
69 | STRONG_ALIAS_SIZE(_atomic_cas_64_ni,_atomic_cas) | |||
70 | ATOMIC_OP_ALIAS_SIZE(atomic_cas_ulong_ni,_atomic_cas) | |||
71 | STRONG_ALIAS_SIZE(_atomic_cas_ulong_ni,_atomic_cas) | |||
72 | ATOMIC_OP_ALIAS_SIZE(atomic_cas_ptr_ni,_atomic_cas) | |||
73 | STRONG_ALIAS_SIZE(_atomic_cas_ptr_ni,_atomic_cas) |
--- src/common/lib/libc/arch/sparc64/atomic/atomic_op_asm.h 2008/01/09 01:21:12 1.3.2.2
+++ src/common/lib/libc/arch/sparc64/atomic/atomic_op_asm.h 2008/03/23 00:12:43 1.3.2.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_op_asm.h,v 1.3.2.2 2008/01/09 01:21:12 matt Exp $ */ | 1 | /* atomic_op_asm.h,v 1.3.2.2 2008/01/09 01:21:12 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -35,38 +35,38 @@ | @@ -35,38 +35,38 @@ | |||
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
36 | * POSSIBILITY OF SUCH DAMAGE. | 36 | * POSSIBILITY OF SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #ifndef _ATOMIC_OP_ASM_H_ | 39 | #ifndef _ATOMIC_OP_ASM_H_ | |
40 | #define _ATOMIC_OP_ASM_H_ | 40 | #define _ATOMIC_OP_ASM_H_ | |
41 | 41 | |||
42 | #include <machine/asm.h> | 42 | #include <machine/asm.h> | |
43 | 43 | |||
44 | #if defined(_KERNEL) | 44 | #if defined(_KERNEL) | |
45 | 45 | |||
46 | #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) | 46 | #define ATOMIC_OP_ALIAS(a,s) STRONG_ALIAS(a,s) | |
47 | 47 | |||
48 | #ifdef __sparc64__ | 48 | #ifdef __arch64__ | |
49 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | 49 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | |
50 | #else | 50 | #else | |
51 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | 51 | #define ATOMIC_OP_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | |
52 | #endif | 52 | #endif | |
53 | 53 | |||
54 | #else /* _KERNEL */ | 54 | #else /* _KERNEL */ | |
55 | 55 | |||
56 | #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) | 56 | #define ATOMIC_OP_ALIAS(a,s) WEAK_ALIAS(a,s) | |
57 | 57 | |||
58 | #ifdef __sparc64__ | 58 | #ifdef __arch64__ | |
59 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_64) | 59 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_64) | |
60 | #else | 60 | #else | |
61 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_32) | 61 | #define ATOMIC_OP_ALIAS_SIZE(a,s) WEAK_ALIAS(a,s/**/_32) | |
62 | #endif | 62 | #endif | |
63 | 63 | |||
64 | #endif /* _KERNEL */ | 64 | #endif /* _KERNEL */ | |
65 | 65 | |||
66 | #ifdef __sparc64__ | 66 | #ifdef __arch64__ | |
67 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | 67 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_64) | |
68 | #else | 68 | #else | |
69 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | 69 | #define STRONG_ALIAS_SIZE(a,s) STRONG_ALIAS(a,s/**/_32) | |
70 | #endif | 70 | #endif | |
71 | 71 | |||
72 | #endif /* _ATOMIC_OP_ASM_H_ */ | 72 | #endif /* _ATOMIC_OP_ASM_H_ */ |
--- src/common/lib/libc/arch/sparc64/atomic/atomic_or.S 2008/01/09 01:21:13 1.3.2.2
+++ src/common/lib/libc/arch/sparc64/atomic/atomic_or.S 2008/03/23 00:12:43 1.3.2.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic_or.S,v 1.3.2.2 2008/01/09 01:21:13 matt Exp $ */ | 1 | /* atomic_or.S,v 1.3.2.2 2008/01/09 01:21:13 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -63,17 +63,17 @@ ENTRY_NOPROFILE(_atomic_or_64) | @@ -63,17 +63,17 @@ ENTRY_NOPROFILE(_atomic_or_64) | |||
63 | 1: or %o1, %o2, %o3 | 63 | 1: or %o1, %o2, %o3 | |
64 | casx [%o0], %o2, %o3 | 64 | casx [%o0], %o2, %o3 | |
65 | cmp %o2, %o3 | 65 | cmp %o2, %o3 | |
66 | bne,a,pn %icc, 1b | 66 | bne,a,pn %icc, 1b | |
67 | mov %o3, %o2 | 67 | mov %o3, %o2 | |
68 | retl | 68 | retl | |
69 | or %o1, %o2, %o0 | 69 | or %o1, %o2, %o0 | |
70 | ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64) | 70 | ATOMIC_OP_ALIAS(atomic_or_64,_atomic_or_64) | |
71 | 71 | |||
72 | ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64) | 72 | ATOMIC_OP_ALIAS(atomic_or_64_nv,_atomic_or_64) | |
73 | STRONG_ALIAS(_atomic_or_64_nv,_atomic_or_64) | 73 | STRONG_ALIAS(_atomic_or_64_nv,_atomic_or_64) | |
74 | 74 | |||
75 | ATOMIC_OP_ALIAS_SIZE(atomic_or_ulong,_atomic_or) | 75 | ATOMIC_OP_ALIAS_SIZE(atomic_or_ulong,_atomic_or) | |
76 | STRONG_ALIAS(_atomic_or_ulong,_atomic_or) | 76 | STRONG_ALIAS_SIZE(_atomic_or_ulong,_atomic_or) | |
77 | 77 | |||
78 | ATOMIC_OP_ALIAS_SIZE(atomic_or_ulong_nv,_atomic_or) | 78 | ATOMIC_OP_ALIAS_SIZE(atomic_or_ulong_nv,_atomic_or) | |
79 | STRONG_ALIAS_SIZE(_atomic_or_ulong_nv,_atomic_or) | 79 | STRONG_ALIAS_SIZE(_atomic_or_ulong_nv,_atomic_or) |
# $NetBSD: Makefile.inc,v 1.3.4.2 2008/03/23 00:12:43 matt Exp $
.if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c")
SRCS+= atomic_add_32_cas.c atomic_add_32_nv_cas.c atomic_and_32_cas.c \
atomic_and_32_nv_cas.c atomic_dec_32_cas.c atomic_dec_32_nv_cas.c \
atomic_inc_32_cas.c atomic_inc_32_nv_cas.c atomic_or_32_cas.c \
atomic_or_32_nv_cas.c atomic_swap_32_cas.c membar_ops_nop.c
.endif
.if defined(LIB) && (${LIB} == "c")
SRCS+= atomic_init_testset.c
.endif
--- src/common/lib/libc/arch/x86_64/atomic/Makefile.inc 2008/01/09 01:21:14 1.2.4.2
+++ src/common/lib/libc/arch/x86_64/atomic/Makefile.inc 2008/03/23 00:12:44 1.2.4.3
@@ -1,7 +1,13 @@ | @@ -1,7 +1,13 @@ | |||
1 | # $NetBSD: Makefile.inc,v 1.2.4.2 2008/01/09 01:21:14 matt Exp $ | 1 | # Makefile.inc,v 1.2.4.2 2008/01/09 01:21:14 matt Exp | |
2 | 2 | |||
3 | .if defined(LIB) && (${LIB} == "kern") | 3 | .if defined(LIB) && (${LIB} == "kern" || ${LIB} == "c") | |
4 | 4 | |||
5 | SRCS+= atomic.S | 5 | SRCS+= atomic.S | |
6 | 6 | |||
7 | .endif | 7 | .endif | |
8 | ||||
9 | .if defined(LIB) && (${LIB} == "c") | |||
10 | ||||
11 | SRCS+= atomic_init_cas.c | |||
12 | ||||
13 | .endif |
--- src/common/lib/libc/arch/x86_64/atomic/atomic.S 2008/01/09 01:21:15 1.7.4.2
+++ src/common/lib/libc/arch/x86_64/atomic/atomic.S 2008/03/23 00:12:44 1.7.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atomic.S,v 1.7.4.2 2008/01/09 01:21:15 matt Exp $ */ | 1 | /* atomic.S,v 1.7.4.2 2008/01/09 01:21:15 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe, and by Andrew Doran. | 8 | * by Jason R. Thorpe, and by Andrew Doran. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -122,26 +122,32 @@ NENTRY(_atomic_or_32_nv) | @@ -122,26 +122,32 @@ NENTRY(_atomic_or_32_nv) | |||
122 | 122 | |||
123 | NENTRY(_atomic_swap_32) | 123 | NENTRY(_atomic_swap_32) | |
124 | movl %esi, %eax | 124 | movl %esi, %eax | |
125 | xchgl %eax, (%rdi) | 125 | xchgl %eax, (%rdi) | |
126 | ret | 126 | ret | |
127 | 127 | |||
128 | NENTRY(_atomic_cas_32) | 128 | NENTRY(_atomic_cas_32) | |
129 | movl %esi, %eax | 129 | movl %esi, %eax | |
130 | LOCK(12) | 130 | LOCK(12) | |
131 | cmpxchgl %edx, (%rdi) | 131 | cmpxchgl %edx, (%rdi) | |
132 | /* %eax now contains the old value */ | 132 | /* %eax now contains the old value */ | |
133 | ret | 133 | ret | |
134 | 134 | |||
135 | NENTRY(_atomic_cas_32_ni) | |||
136 | movl %esi, %eax | |||
137 | cmpxchgl %edx, (%rdi) | |||
138 | /* %eax now contains the old value */ | |||
139 | ret | |||
140 | ||||
135 | /* 64-bit */ | 141 | /* 64-bit */ | |
136 | 142 | |||
137 | NENTRY(_atomic_add_64) | 143 | NENTRY(_atomic_add_64) | |
138 | LOCK(13) | 144 | LOCK(13) | |
139 | addq %rsi, (%rdi) | 145 | addq %rsi, (%rdi) | |
140 | ret | 146 | ret | |
141 | 147 | |||
142 | NENTRY(_atomic_add_64_nv) | 148 | NENTRY(_atomic_add_64_nv) | |
143 | movq %rsi, %rax | 149 | movq %rsi, %rax | |
144 | LOCK(14) | 150 | LOCK(14) | |
145 | xaddq %rax, (%rdi) | 151 | xaddq %rax, (%rdi) | |
146 | addq %rsi, %rax | 152 | addq %rsi, %rax | |
147 | ret | 153 | ret | |
@@ -204,52 +210,46 @@ NENTRY(_atomic_or_64_nv) | @@ -204,52 +210,46 @@ NENTRY(_atomic_or_64_nv) | |||
204 | 210 | |||
205 | NENTRY(_atomic_swap_64) | 211 | NENTRY(_atomic_swap_64) | |
206 | movq %rsi, %rax | 212 | movq %rsi, %rax | |
207 | xchgq %rax, (%rdi) | 213 | xchgq %rax, (%rdi) | |
208 | ret | 214 | ret | |
209 | 215 | |||
210 | NENTRY(_atomic_cas_64) | 216 | NENTRY(_atomic_cas_64) | |
211 | movq %rsi, %rax | 217 | movq %rsi, %rax | |
212 | LOCK(24) | 218 | LOCK(24) | |
213 | cmpxchgq %rdx, (%rdi) | 219 | cmpxchgq %rdx, (%rdi) | |
214 | /* %eax now contains the old value */ | 220 | /* %eax now contains the old value */ | |
215 | ret | 221 | ret | |
216 | 222 | |||
223 | NENTRY(_atomic_cas_64_ni) | |||
224 | movq %rsi, %rax | |||
225 | cmpxchgq %rdx, (%rdi) | |||
226 | /* %eax now contains the old value */ | |||
227 | ret | |||
228 | ||||
217 | /* memory barriers */ | 229 | /* memory barriers */ | |
218 | 230 | |||
219 | NENTRY(_membar_consumer) | 231 | NENTRY(_membar_consumer) | |
220 | LOCK(25) | 232 | LOCK(25) | |
221 | addq $0, -8(%rsp) | 233 | addq $0, -8(%rsp) | |
222 | ret | 234 | ret | |
223 | END(membar_consumer_end) | 235 | END(membar_consumer_end) | |
224 | 236 | |||
225 | NENTRY(_membar_producer) | 237 | NENTRY(_membar_producer) | |
226 | /* A store is enough */ | 238 | /* A store is enough */ | |
227 | movq $0, -8(%rsp) | 239 | movq $0, -8(%rsp) | |
228 | ret | 240 | ret | |
229 | END(membar_producer_end) | 241 | END(membar_producer_end) | |
230 | 242 | |||
231 | NENTRY(_membar_enter) | |||
232 | /* A store is enough */ | |||
233 | movq $0, -8(%rsp) | |||
234 | ret | |||
235 | END(membar_enter_end) | |||
236 | ||||
237 | NENTRY(_membar_exit) | |||
238 | /* A store is enough */ | |||
239 | movq $0, -8(%rsp) | |||
240 | ret | |||
241 | END(membar_exit_end) | |||
242 | ||||
243 | NENTRY(_membar_sync) | 243 | NENTRY(_membar_sync) | |
244 | LOCK(26) | 244 | LOCK(26) | |
245 | addq $0, -8(%rsp) | 245 | addq $0, -8(%rsp) | |
246 | ret | 246 | ret | |
247 | END(membar_sync_end) | 247 | END(membar_sync_end) | |
248 | 248 | |||
249 | #ifdef _KERNEL | 249 | #ifdef _KERNEL | |
250 | NENTRY(sse2_lfence) | 250 | NENTRY(sse2_lfence) | |
251 | lfence | 251 | lfence | |
252 | ret | 252 | ret | |
253 | END(sse2_lfence_end) | 253 | END(sse2_lfence_end) | |
254 | 254 | |||
255 | NENTRY(sse2_mfence) | 255 | NENTRY(sse2_mfence) | |
@@ -328,30 +328,36 @@ ALIAS(atomic_or_ptr_nv,_atomic_or_64_nv) | @@ -328,30 +328,36 @@ ALIAS(atomic_or_ptr_nv,_atomic_or_64_nv) | |||
328 | 328 | |||
329 | ALIAS(atomic_swap_32,_atomic_swap_32) | 329 | ALIAS(atomic_swap_32,_atomic_swap_32) | |
330 | ALIAS(atomic_swap_64,_atomic_swap_64) | 330 | ALIAS(atomic_swap_64,_atomic_swap_64) | |
331 | ALIAS(atomic_swap_uint,_atomic_swap_32) | 331 | ALIAS(atomic_swap_uint,_atomic_swap_32) | |
332 | ALIAS(atomic_swap_ulong,_atomic_swap_64) | 332 | ALIAS(atomic_swap_ulong,_atomic_swap_64) | |
333 | ALIAS(atomic_swap_ptr,_atomic_swap_64) | 333 | ALIAS(atomic_swap_ptr,_atomic_swap_64) | |
334 | 334 | |||
335 | ALIAS(atomic_cas_32,_atomic_cas_32) | 335 | ALIAS(atomic_cas_32,_atomic_cas_32) | |
336 | ALIAS(atomic_cas_64,_atomic_cas_64) | 336 | ALIAS(atomic_cas_64,_atomic_cas_64) | |
337 | ALIAS(atomic_cas_uint,_atomic_cas_32) | 337 | ALIAS(atomic_cas_uint,_atomic_cas_32) | |
338 | ALIAS(atomic_cas_ulong,_atomic_cas_64) | 338 | ALIAS(atomic_cas_ulong,_atomic_cas_64) | |
339 | ALIAS(atomic_cas_ptr,_atomic_cas_64) | 339 | ALIAS(atomic_cas_ptr,_atomic_cas_64) | |
340 | 340 | |||
341 | ALIAS(atomic_cas_32_ni,_atomic_cas_32_ni) | |||
342 | ALIAS(atomic_cas_64_ni,_atomic_cas_64_ni) | |||
343 | ALIAS(atomic_cas_uint_ni,_atomic_cas_32_ni) | |||
344 | ALIAS(atomic_cas_ulong_ni,_atomic_cas_64_ni) | |||
345 | ALIAS(atomic_cas_ptr_ni,_atomic_cas_64_ni) | |||
346 | ||||
341 | ALIAS(membar_consumer,_membar_consumer) | 347 | ALIAS(membar_consumer,_membar_consumer) | |
342 | ALIAS(membar_producer,_membar_producer) | 348 | ALIAS(membar_producer,_membar_producer) | |
343 | ALIAS(membar_enter,_membar_enter) | 349 | ALIAS(membar_enter,_membar_consumer) | |
344 | ALIAS(membar_exit,_membar_exit) | 350 | ALIAS(membar_exit,_membar_producer) | |
345 | ALIAS(membar_sync,_membar_sync) | 351 | ALIAS(membar_sync,_membar_sync) | |
346 | 352 | |||
347 | STRONG_ALIAS(_atomic_add_int,_atomic_add_32) | 353 | STRONG_ALIAS(_atomic_add_int,_atomic_add_32) | |
348 | STRONG_ALIAS(_atomic_add_long,_atomic_add_64) | 354 | STRONG_ALIAS(_atomic_add_long,_atomic_add_64) | |
349 | STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64) | 355 | STRONG_ALIAS(_atomic_add_ptr,_atomic_add_64) | |
350 | 356 | |||
351 | STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) | 357 | STRONG_ALIAS(_atomic_add_int_nv,_atomic_add_32_nv) | |
352 | STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv) | 358 | STRONG_ALIAS(_atomic_add_long_nv,_atomic_add_64_nv) | |
353 | STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv) | 359 | STRONG_ALIAS(_atomic_add_ptr_nv,_atomic_add_64_nv) | |
354 | 360 | |||
355 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | 361 | STRONG_ALIAS(_atomic_and_uint,_atomic_and_32) | |
356 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64) | 362 | STRONG_ALIAS(_atomic_and_ulong,_atomic_and_64) | |
357 | STRONG_ALIAS(_atomic_and_ptr,_atomic_and_64) | 363 | STRONG_ALIAS(_atomic_and_ptr,_atomic_and_64) | |
@@ -381,13 +387,20 @@ STRONG_ALIAS(_atomic_or_ulong,_atomic_or | @@ -381,13 +387,20 @@ STRONG_ALIAS(_atomic_or_ulong,_atomic_or | |||
381 | STRONG_ALIAS(_atomic_or_ptr,_atomic_or_64) | 387 | STRONG_ALIAS(_atomic_or_ptr,_atomic_or_64) | |
382 | 388 | |||
383 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | 389 | STRONG_ALIAS(_atomic_or_uint_nv,_atomic_or_32_nv) | |
384 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_64_nv) | 390 | STRONG_ALIAS(_atomic_or_ulong_nv,_atomic_or_64_nv) | |
385 | STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_64_nv) | 391 | STRONG_ALIAS(_atomic_or_ptr_nv,_atomic_or_64_nv) | |
386 | 392 | |||
387 | STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) | 393 | STRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) | |
388 | STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64) | 394 | STRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64) | |
389 | STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64) | 395 | STRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64) | |
390 | 396 | |||
391 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | 397 | STRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) | |
392 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) | 398 | STRONG_ALIAS(_atomic_cas_ulong,_atomic_cas_64) | |
393 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) | 399 | STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_64) | |
400 | ||||
401 | STRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32_ni) | |||
402 | STRONG_ALIAS(_atomic_cas_ulong_ni,_atomic_cas_64_ni) | |||
403 | STRONG_ALIAS(_atomic_cas_ptr_ni,_atomic_cas_64_ni) | |||
404 | ||||
405 | STRONG_ALIAS(_membar_enter,_membar_consumer) | |||
406 | STRONG_ALIAS(_membar_exit,_membar_producer) |
/* $NetBSD: atomic_init_cas.c,v 1.2.4.2 2008/03/23 00:12:44 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 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.
*/
/*
* libc glue for atomic operations where the hardware _does_ provide
* compare-and-swap.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: atomic_init_cas.c,v 1.2.4.2 2008/03/23 00:12:44 matt Exp $");
void __libc_atomic_init(void) __attribute__ ((visibility("hidden")));
void
__libc_atomic_init(void)
{
/* nothing to do */
}
/* $NetBSD: atomic_init_testset.c,v 1.3.4.2 2008/03/23 00:12:44 matt Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 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.
*/
/*
* libc glue for atomic operations where the hardware does not provide
* compare-and-swap. It's assumed that this will only be used on 32-bit
* platforms.
*
* This should be compiled with '-fno-reorder-blocks -fomit-frame-pointer'
* if using gcc.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: atomic_init_testset.c,v 1.3.4.2 2008/03/23 00:12:44 matt Exp $");
#include "atomic_op_namespace.h"
#include <sys/types.h>
#include <sys/atomic.h>
#include <sys/lock.h>
#include <sys/ras.h>
#include <sys/sysctl.h>
#include <string.h>
#define I2 __SIMPLELOCK_UNLOCKED, __SIMPLELOCK_UNLOCKED,
#define I16 I2 I2 I2 I2 I2 I2 I2 I2
#define I128 I16 I16 I16 I16 I16 I16 I16 I16
static __cpu_simple_lock_t atomic_locks[128] = { I128 };
static uint32_t (*_atomic_cas_fn)(volatile uint32_t *, uint32_t, uint32_t);
void __libc_atomic_init(void) __attribute__ ((visibility("hidden")));
RAS_DECL(_atomic_cas);
static uint32_t
_atomic_cas_up(volatile uint32_t *ptr, uint32_t old, uint32_t new)
{
uint32_t ret;
RAS_START(_atomic_cas);
ret = *ptr;
if (__predict_false(ret != old)) {
return ret;
}
*ptr = new;
RAS_END(_atomic_cas);
return ret;
}
static uint32_t
_atomic_cas_mp(volatile uint32_t *ptr, uint32_t old, uint32_t new)
{
__cpu_simple_lock_t *lock;
uint32_t ret;
lock = &atomic_locks[((uint32_t)ptr >> 3) & 127];
__cpu_simple_lock(lock);
ret = *ptr;
if (__predict_true(ret == old)) {
*ptr = new;
}
__cpu_simple_unlock(lock);
return ret;
}
uint32_t
_atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new)
{
return (*_atomic_cas_fn)(ptr, old, new);
}
void
__libc_atomic_init(void)
{
int ncpu, mib[2];
size_t len;
_atomic_cas_fn = _atomic_cas_mp;
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
len = sizeof(ncpu);
if (sysctl(mib, 2, &ncpu, &len, NULL, 0) == -1)
return;
if (ncpu > 1)
return;
if (rasctl(RAS_ADDR(_atomic_cas), RAS_SIZE(_atomic_cas),
RAS_INSTALL) == 0) {
_atomic_cas_fn = _atomic_cas_up;
return;
}
}
#undef atomic_cas_32
#undef atomic_cas_uint
#undef atomic_cas_ulong
#undef atomic_cas_ptr
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)
--- src/common/lib/libc/atomic/Attic/atomic_ops.3 2008/01/09 01:21:30 1.3.4.2
+++ src/common/lib/libc/atomic/Attic/atomic_ops.3 2008/03/23 00:12:44 1.3.4.3
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | .\" $NetBSD: atomic_ops.3,v 1.3.4.2 2008/01/09 01:21:30 matt Exp $ | 1 | .\" atomic_ops.3,v 1.3.4.2 2008/01/09 01:21:30 matt Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2007 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
15 | .\" notice, this list of conditions and the following disclaimer in the | 15 | .\" notice, this list of conditions and the following disclaimer in the | |
16 | .\" documentation and/or other materials provided with the distribution. | 16 | .\" documentation and/or other materials provided with the distribution. | |
@@ -24,88 +24,120 @@ | @@ -24,88 +24,120 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd April 11, 2007 | 37 | .Dd Febuary 11, 2007 | |
38 | .Dt ATOMIC_OPS 3 | 38 | .Dt ATOMIC_OPS 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm atomic_ops | 41 | .Nm atomic_ops | |
42 | .Nd atomic memory operations | 42 | .Nd atomic memory operations | |
43 | .\" .Sh LIBRARY | 43 | .\" .Sh LIBRARY | |
44 | .\" .Lb libc | 44 | .\" .Lb libc | |
45 | .Sh SYNOPSIS | 45 | .Sh SYNOPSIS | |
46 | .In sys/atomic.h | 46 | .In sys/atomic.h | |
47 | .Sh DESCRIPTION | 47 | .Sh DESCRIPTION | |
48 | The | 48 | The | |
49 | .Nm atomic_ops | 49 | .Nm atomic_ops | |
50 | family of functions provide atomic memory operations. | 50 | family of functions provide atomic memory operations. | |
51 | There are 7 classes of atomic memory operations available: | 51 | There are 7 classes of atomic memory operations available | |
52 | : | |||
52 | .Pp | 53 | .Pp | |
53 | .Bl -tag -width "atomic_swap(3)" | 54 | .Bl -tag -width "atomic_swap(3)" | |
54 | .It Xr atomic_add 3 | 55 | .It Xr atomic_add 3 | |
55 | These functions perform atomic addition. | 56 | These functions perform atomic addition. | |
56 | .It Xr atomic_and 3 | 57 | .It Xr atomic_and 3 | |
57 | These functions perform atomic logical | 58 | These functions perform atomic logical | |
58 | .Dq and . | 59 | .Dq and . | |
59 | .It Xr atomic_cas 3 | 60 | .It Xr atomic_cas 3 | |
60 | These functions perform atomic compare-and-swap. | 61 | These functions perform atomic compare-and-swap. | |
61 | .It Xr atomic_dec 3 | 62 | .It Xr atomic_dec 3 | |
62 | These functions perform atomic decrement. | 63 | These functions perform atomic decrement. | |
63 | .It Xr atomic_inc 3 | 64 | .It Xr atomic_inc 3 | |
64 | These functions perform atomic increment. | 65 | These functions perform atomic increment. | |
65 | .It Xr atomic_or 3 | 66 | .It Xr atomic_or 3 | |
66 | These functions perform atomic logical | 67 | These functions perform atomic logical | |
67 | .Dq or . | 68 | .Dq or . | |
68 | .It Xr atomic_swap 3 | 69 | .It Xr atomic_swap 3 | |
69 | These functions perform atomic swap. | 70 | These functions perform atomic swap. | |
70 | .El | 71 | .El | |
71 | .Pp | 72 | .Pp | |
72 | After an atomic operation is complete, the store to the target memory | 73 | .Bl -tag -width aa | |
73 | location will have global visibility. | 74 | .It Synchronization mechanisms | |
74 | The global visibility of other loads and stores before and after the atomic | |||
75 | operation are undefined. | |||
76 | Applications that require synchronization of loads and stores with respect | |||
77 | to an atomic operation must use memory barriers. | |||
78 | See | |||
79 | .Xr membar_ops 3 . | |||
80 | .Pp | 75 | .Pp | |
81 | Because atomic memory operations require expensive synchronization at the | 76 | Where the architecture does not provide hardware support for atomic compare | |
82 | hardware level, applications should take care to minimize their use. | 77 | and swap (CAS), atomicity is provided by a restartable sequence or by a | |
83 | In certain cases, it may be more appropriate to use a mutex, especially | 78 | spinlock. | |
84 | if more than one memory location will be modified. | 79 | The chosen method is not ordinarily distinguishable by or visible to users | |
80 | of the interface. | |||
81 | The following architectures can be assumed to provide CAS in hardware: | |||
82 | alpha, amd64, i386, powerpc, powerpc64, sparc64. | |||
83 | .It Scope and restrictions | |||
84 | .Pp | |||
85 | If hardware CAS is available, the atomic operations are globally atomic: | |||
86 | operations within a memory region shared between processes are | |||
87 | guaranteed to be performed atomically. | |||
88 | If hardware CAS is not available, it may only be assumed that the operations | |||
89 | are atomic with respect to threads in the same process. | |||
90 | Additionally, if hardware CAS is not available, the atomic operations must | |||
91 | not be used within a signal handler. | |||
85 | .Pp | 92 | .Pp | |
86 | Users of atomic memory operations should not make assumptions about how | 93 | Users of atomic memory operations should not make assumptions about how | |
87 | the memory access is performed | 94 | the memory access is performed | |
88 | .Pq specifically, the width of the memory access . | 95 | .Pq specifically, the width of the memory access . | |
89 | For this reason, applications making use of atomic memory operations should | 96 | For this reason, applications making use of atomic memory operations should | |
90 | limit their use to regular memory. | 97 | limit their use to regular memory. | |
91 | The results of using atomic memory operations on anything other than | 98 | The results of using atomic memory operations on anything other than | |
92 | regular memory are undefined. | 99 | regular memory are undefined. | |
93 | .Pp | 100 | .Pp | |
94 | Users of atomic memory operations should take care to modify any given | 101 | Users of atomic memory operations should take care to modify any given | |
95 | memory location either entirely with atomic operations or entirely with | 102 | memory location either entirely with atomic operations or entirely with | |
96 | some other synchronization mechanism. | 103 | some other synchronization mechanism. | |
97 | Intermixing of atomic operations with other synchronization mechanisms | 104 | Intermixing of atomic operations with other synchronization mechanisms | |
98 | for the same memory location results in undefined behavior. | 105 | for the same memory location results in undefined behavior. | |
106 | .It Visibility and ordering of memory accesses | |||
107 | .Pp | |||
108 | If hardware CAS is available, stores to the target memory location by an | |||
109 | atomic operation will reach global visibility before the operation | |||
110 | completes. | |||
111 | If hardware CAS is not available, the store may not reach global visibility | |||
112 | until some time after the atomic operation has completed. | |||
113 | However, in all cases a subsequent atomic operation on the same memory cell | |||
114 | will be delayed until the result of any preceeding operation has reached | |||
115 | global visibility. | |||
116 | .Pp | |||
117 | Atomic operations are strongly ordered with respect to each other. | |||
118 | The global visibility of other loads and stores before and after an atomic | |||
119 | operation is undefined. | |||
120 | Applications that require synchronization of loads and stores with respect | |||
121 | to an atomic operation must use memory barriers. | |||
122 | See | |||
123 | .Xr membar_ops 3 . | |||
124 | .It Performance | |||
125 | .Pp | |||
126 | Because atomic memory operations require expensive synchronization at the | |||
127 | hardware level, applications should take care to minimize their use. | |||
128 | In certain cases, it may be more appropriate to use a mutex, especially | |||
129 | if more than one memory location will be modified. | |||
130 | .El | |||
99 | .Sh SEE ALSO | 131 | .Sh SEE ALSO | |
100 | .Xr atomic_add 3 , | 132 | .Xr atomic_add 3 , | |
101 | .Xr atomic_and 3 , | 133 | .Xr atomic_and 3 , | |
102 | .Xr atomic_cas 3 , | 134 | .Xr atomic_cas 3 , | |
103 | .Xr atomic_dec 3 , | 135 | .Xr atomic_dec 3 , | |
104 | .Xr atomic_inc 3 , | 136 | .Xr atomic_inc 3 , | |
105 | .Xr atomic_or 3 , | 137 | .Xr atomic_or 3 , | |
106 | .Xr atomic_swap 3 , | 138 | .Xr atomic_swap 3 , | |
107 | .Xr membar_ops 3 | 139 | .Xr membar_ops 3 | |
108 | .Sh HISTORY | 140 | .Sh HISTORY | |
109 | The | 141 | The | |
110 | .Nm atomic_ops | 142 | .Nm atomic_ops | |
111 | functions first appeared in | 143 | functions first appeared in |
--- src/common/lib/libc/atomic/Attic/membar_ops.3 2008/01/09 01:21:34 1.3.4.2
+++ src/common/lib/libc/atomic/Attic/membar_ops.3 2008/03/23 00:12:44 1.3.4.3
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | .\" $NetBSD: membar_ops.3,v 1.3.4.2 2008/01/09 01:21:34 matt Exp $ | 1 | .\" membar_ops.3,v 1.3.4.2 2008/01/09 01:21:34 matt Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2007 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
15 | .\" notice, this list of conditions and the following disclaimer in the | 15 | .\" notice, this list of conditions and the following disclaimer in the | |
16 | .\" documentation and/or other materials provided with the distribution. | 16 | .\" documentation and/or other materials provided with the distribution. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd April 11, 2007 | 37 | .Dd Febuary 11, 2007 | |
38 | .Dt MEMBAR_OPS 3 | 38 | .Dt MEMBAR_OPS 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm membar_ops , | 41 | .Nm membar_ops , | |
42 | .Nm membar_enter , | 42 | .Nm membar_enter , | |
43 | .Nm membar_exit , | 43 | .Nm membar_exit , | |
44 | .Nm membar_producer , | 44 | .Nm membar_producer , | |
45 | .Nm membar_consumer , | 45 | .Nm membar_consumer , | |
46 | .Nm membar_sync | 46 | .Nm membar_sync | |
47 | .Nd memory access barrier operations | 47 | .Nd memory access barrier operations | |
48 | .\" .Sh LIBRARY | 48 | .\" .Sh LIBRARY | |
49 | .\" .Lb libc | 49 | .\" .Lb libc | |
50 | .Sh SYNOPSIS | 50 | .Sh SYNOPSIS | |
@@ -57,51 +57,53 @@ | @@ -57,51 +57,53 @@ | |||
57 | .Ft void | 57 | .Ft void | |
58 | .Fn membar_producer "void" | 58 | .Fn membar_producer "void" | |
59 | .Ft void | 59 | .Ft void | |
60 | .Fn membar_consumer "void" | 60 | .Fn membar_consumer "void" | |
61 | .Ft void | 61 | .Ft void | |
62 | .Fn membar_sync "void" | 62 | .Fn membar_sync "void" | |
63 | .Sh DESCRIPTION | 63 | .Sh DESCRIPTION | |
64 | The | 64 | The | |
65 | .Nm membar_ops | 65 | .Nm membar_ops | |
66 | family of functions provide memory access barrier operations necessary | 66 | family of functions provide memory access barrier operations necessary | |
67 | for synchronization in multiprocessor execution environments that have | 67 | for synchronization in multiprocessor execution environments that have | |
68 | relaxed load and store order. | 68 | relaxed load and store order. | |
69 | .Pp | 69 | .Pp | |
70 | .Bl -tag -width "membar_producer()" | 70 | .Bl -tag -width "mem" | |
71 | .It Fn membar_enter | 71 | .It Fn membar_enter | |
72 | All loads and stores preceding the memory barrier will complete and | 72 | .Pp | |
73 | reach global visibility before any stores after the memory barrier reach | 73 | Any store preceeding | |
74 | global visibility | 74 | .Fn membar_enter | |
75 | .Pq RW-W . | 75 | will reach global visibility before all loads and stores following it. | |
76 | .Pp | |||
76 | .Fn membar_enter | 77 | .Fn membar_enter | |
77 | is typically used in code that implements locking primitives to ensure | 78 | is typically used in code that implements locking primitives to ensure | |
78 | that a lock protects its data. | 79 | that a lock protects its data. | |
79 | .It Fn membar_exit | 80 | .It Fn membar_exit | |
80 | All stores preceding the memory barrier will reach global visibility | 81 | .Pp | |
81 | before any loads and stores after the memory barrier will complete and | 82 | All loads and stores preceding | |
82 | reach global visibility | |||
83 | .Pq W-RW . | |||
84 | .Fn membar_exit | 83 | .Fn membar_exit | |
85 | is typically used in code that implements locking primitives when a lock | 84 | will reach global visibility before any store that follows it. | |
86 | is released. | 85 | .Pp | |
86 | .Fn membar_exit | |||
87 | is typically used in code that implements locking primitives to ensure | |||
88 | that a lock protects its data. | |||
87 | .It Fn membar_producer | 89 | .It Fn membar_producer | |
90 | .Pp | |||
88 | All stores preceding the memory barrier will reach global visibility | 91 | All stores preceding the memory barrier will reach global visibility | |
89 | before any stores after the memory barrier reach global visibility | 92 | before any stores after the memory barrier reach global visibility. | |
90 | .Pq W-W . | |||
91 | .It Fn membar_consumer | 93 | .It Fn membar_consumer | |
94 | .Pp | |||
92 | All loads preceding the memory barrier will complete before any loads | 95 | All loads preceding the memory barrier will complete before any loads | |
93 | after the memory barrier complete | 96 | after the memory barrier complete. | |
94 | .Pq R-R . | |||
95 | .It Fn membar_sync | 97 | .It Fn membar_sync | |
98 | .Pp | |||
96 | All loads and stores preceding the memory barrier will complete and | 99 | All loads and stores preceding the memory barrier will complete and | |
97 | reach global visibility before any loads and stores after the memory | 100 | reach global visibility before any loads and stores after the memory | |
98 | barrier complete and reach global visibility | 101 | barrier complete and reach global visibility. | |
99 | .Pq RW-RW . | |||
100 | .El | 102 | .El | |
101 | .Sh SEE ALSO | 103 | .Sh SEE ALSO | |
102 | .Xr atomic_ops 3 | 104 | .Xr atomic_ops 3 | |
103 | .Sh HISTORY | 105 | .Sh HISTORY | |
104 | The | 106 | The | |
105 | .Nm membar_ops | 107 | .Nm membar_ops | |
106 | functions first appeared in | 108 | functions first appeared in | |
107 | .Nx 5.0 . | 109 | .Nx 5.0 . |
--- src/common/lib/libc/gen/bswap16.c 2005/12/20 19:28:51 1.1
+++ src/common/lib/libc/gen/bswap16.c 2008/03/23 00:12:44 1.1.18.1
@@ -1,23 +1,23 @@ | @@ -1,23 +1,23 @@ | |||
1 | /* $NetBSD: bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */ | 1 | /* bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Written by Manuel Bouyer <bouyer@NetBSD.org>. | 4 | * Written by Manuel Bouyer <bouyer@NetBSD.org>. | |
5 | * Public domain. | 5 | * Public domain. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | #include <sys/cdefs.h> | 8 | #include <sys/cdefs.h> | |
9 | #if defined(LIBC_SCCS) && !defined(lint) | 9 | #if defined(LIBC_SCCS) && !defined(lint) | |
10 | __RCSID("$NetBSD: bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp $"); | 10 | __RCSID("bswap16.c,v 1.1 2005/12/20 19:28:51 christos Exp"); | |
11 | #endif /* LIBC_SCCS and not lint */ | 11 | #endif /* LIBC_SCCS and not lint */ | |
12 | 12 | |||
13 | #include <sys/types.h> | 13 | #include <sys/types.h> | |
14 | #include <machine/bswap.h> | 14 | #include <machine/bswap.h> | |
15 | 15 | |||
16 | #undef bswap16 | 16 | #undef bswap16 | |
17 | 17 | |||
18 | u_int16_t | 18 | uint16_t | |
19 | bswap16(x) | 19 | bswap16(x) | |
20 | u_int16_t x; | 20 | uint16_t x; | |
21 | { | 21 | { | |
22 | return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); | 22 | return ((x << 8) & 0xff00) | ((x >> 8) & 0x00ff); | |
23 | } | 23 | } |
--- src/common/lib/libc/gen/bswap32.c 2005/12/20 19:28:51 1.1
+++ src/common/lib/libc/gen/bswap32.c 2008/03/23 00:12:44 1.1.18.1
@@ -1,26 +1,26 @@ | @@ -1,26 +1,26 @@ | |||
1 | /* $NetBSD: bswap32.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */ | 1 | /* bswap32.c,v 1.1 2005/12/20 19:28:51 christos Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Written by Manuel Bouyer <bouyer@NetBSD.org>. | 4 | * Written by Manuel Bouyer <bouyer@NetBSD.org>. | |
5 | * Public domain. | 5 | * Public domain. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | #include <sys/cdefs.h> | 8 | #include <sys/cdefs.h> | |
9 | #if defined(LIBC_SCCS) && !defined(lint) | 9 | #if defined(LIBC_SCCS) && !defined(lint) | |
10 | __RCSID("$NetBSD: bswap32.c,v 1.1 2005/12/20 19:28:51 christos Exp $"); | 10 | __RCSID("bswap32.c,v 1.1 2005/12/20 19:28:51 christos Exp"); | |
11 | #endif /* LIBC_SCCS and not lint */ | 11 | #endif /* LIBC_SCCS and not lint */ | |
12 | 12 | |||
13 | #include <sys/types.h> | 13 | #include <sys/types.h> | |
14 | #include <machine/bswap.h> | 14 | #include <machine/bswap.h> | |
15 | 15 | |||
16 | #undef bswap32 | 16 | #undef bswap32 | |
17 | 17 | |||
18 | u_int32_t | 18 | uint32_t | |
19 | bswap32(x) | 19 | bswap32(x) | |
20 | u_int32_t x; | 20 | uint32_t x; | |
21 | { | 21 | { | |
22 | return ((x << 24) & 0xff000000 ) | | 22 | return ((x << 24) & 0xff000000 ) | | |
23 | ((x << 8) & 0x00ff0000 ) | | 23 | ((x << 8) & 0x00ff0000 ) | | |
24 | ((x >> 8) & 0x0000ff00 ) | | 24 | ((x >> 8) & 0x0000ff00 ) | | |
25 | ((x >> 24) & 0x000000ff ); | 25 | ((x >> 24) & 0x000000ff ); | |
26 | } | 26 | } |
--- src/common/lib/libc/gen/bswap64.c 2005/12/20 19:28:51 1.1
+++ src/common/lib/libc/gen/bswap64.c 2008/03/23 00:12:44 1.1.18.1
@@ -1,45 +1,45 @@ | @@ -1,45 +1,45 @@ | |||
1 | /* $NetBSD: bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */ | 1 | /* bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Written by Manuel Bouyer <bouyer@NetBSD.org>. | 4 | * Written by Manuel Bouyer <bouyer@NetBSD.org>. | |
5 | * Public domain. | 5 | * Public domain. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | #include <sys/cdefs.h> | 8 | #include <sys/cdefs.h> | |
9 | #if defined(LIBC_SCCS) && !defined(lint) | 9 | #if defined(LIBC_SCCS) && !defined(lint) | |
10 | __RCSID("$NetBSD: bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp $"); | 10 | __RCSID("bswap64.c,v 1.1 2005/12/20 19:28:51 christos Exp"); | |
11 | #endif /* LIBC_SCCS and not lint */ | 11 | #endif /* LIBC_SCCS and not lint */ | |
12 | 12 | |||
13 | #include <sys/types.h> | 13 | #include <sys/types.h> | |
14 | #include <machine/bswap.h> | 14 | #include <machine/bswap.h> | |
15 | 15 | |||
16 | #undef bswap64 | 16 | #undef bswap64 | |
17 | 17 | |||
18 | u_int64_t | 18 | uint64_t | |
19 | bswap64(x) | 19 | bswap64(x) | |
20 | u_int64_t x; | 20 | uint64_t x; | |
21 | { | 21 | { | |
22 | #ifdef _LP64 | 22 | #ifdef _LP64 | |
23 | /* | 23 | /* | |
24 | * Assume we have wide enough registers to do it without touching | 24 | * Assume we have wide enough registers to do it without touching | |
25 | * memory. | 25 | * memory. | |
26 | */ | 26 | */ | |
27 | return ( (x << 56) & 0xff00000000000000UL ) | | 27 | return ( (x << 56) & 0xff00000000000000UL ) | | |
28 | ( (x << 40) & 0x00ff000000000000UL ) | | 28 | ( (x << 40) & 0x00ff000000000000UL ) | | |
29 | ( (x << 24) & 0x0000ff0000000000UL ) | | 29 | ( (x << 24) & 0x0000ff0000000000UL ) | | |
30 | ( (x << 8) & 0x000000ff00000000UL ) | | 30 | ( (x << 8) & 0x000000ff00000000UL ) | | |
31 | ( (x >> 8) & 0x00000000ff000000UL ) | | 31 | ( (x >> 8) & 0x00000000ff000000UL ) | | |
32 | ( (x >> 24) & 0x0000000000ff0000UL ) | | 32 | ( (x >> 24) & 0x0000000000ff0000UL ) | | |
33 | ( (x >> 40) & 0x000000000000ff00UL ) | | 33 | ( (x >> 40) & 0x000000000000ff00UL ) | | |
34 | ( (x >> 56) & 0x00000000000000ffUL ); | 34 | ( (x >> 56) & 0x00000000000000ffUL ); | |
35 | #else | 35 | #else | |
36 | /* | 36 | /* | |
37 | * Split the operation in two 32bit steps. | 37 | * Split the operation in two 32bit steps. | |
38 | */ | 38 | */ | |
39 | u_int32_t tl, th; | 39 | uint32_t tl, th; | |
40 | 40 | |||
41 | th = bswap32((u_int32_t)(x & 0x00000000ffffffffULL)); | 41 | th = bswap32((uint32_t)(x & 0x00000000ffffffffULL)); | |
42 | tl = bswap32((u_int32_t)((x >> 32) & 0x00000000ffffffffULL)); | 42 | tl = bswap32((uint32_t)((x >> 32) & 0x00000000ffffffffULL)); | |
43 | return ((u_int64_t)th << 32) | tl; | 43 | return ((uint64_t)th << 32) | tl; | |
44 | #endif | 44 | #endif | |
45 | } | 45 | } |
--- src/common/lib/libc/hash/rmd160/rmd160.c 2007/07/18 13:57:54 1.3
+++ src/common/lib/libc/hash/rmd160/rmd160.c 2008/03/23 00:12:44 1.3.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rmd160.c,v 1.3 2007/07/18 13:57:54 joerg Exp $ */ | 1 | /* rmd160.c,v 1.3 2007/07/18 13:57:54 joerg Exp */ | |
2 | /* $KAME: rmd160.c,v 1.2 2003/07/25 09:37:55 itojun Exp $ */ | 2 | /* $KAME: rmd160.c,v 1.2 2003/07/25 09:37:55 itojun Exp $ */ | |
3 | /* $OpenBSD: rmd160.c,v 1.3 2001/09/26 21:40:13 markus Exp $ */ | 3 | /* $OpenBSD: rmd160.c,v 1.3 2001/09/26 21:40:13 markus Exp $ */ | |
4 | /* | 4 | /* | |
5 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 5 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -23,34 +23,34 @@ | @@ -23,34 +23,34 @@ | |||
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | /* | 27 | /* | |
28 | * Preneel, Bosselaers, Dobbertin, "The Cryptographic Hash Function RIPEMD-160", | 28 | * Preneel, Bosselaers, Dobbertin, "The Cryptographic Hash Function RIPEMD-160", | |
29 | * RSA Laboratories, CryptoBytes, Volume 3, Number 2, Autumn 1997, | 29 | * RSA Laboratories, CryptoBytes, Volume 3, Number 2, Autumn 1997, | |
30 | * ftp://ftp.rsasecurity.com/pub/cryptobytes/crypto3n2.pdf | 30 | * ftp://ftp.rsasecurity.com/pub/cryptobytes/crypto3n2.pdf | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | 34 | |||
35 | #if defined(_KERNEL) || defined(_STANDALONE) | 35 | #if defined(_KERNEL) || defined(_STANDALONE) | |
36 | __KERNEL_RCSID(0, "$NetBSD: rmd160.c,v 1.3 2007/07/18 13:57:54 joerg Exp $"); | 36 | __KERNEL_RCSID(0, "rmd160.c,v 1.3 2007/07/18 13:57:54 joerg Exp"); | |
37 | 37 | |||
38 | #include <lib/libkern/libkern.h> | 38 | #include <lib/libkern/libkern.h> | |
39 | 39 | |||
40 | #else | 40 | #else | |
41 | 41 | |||
42 | #if defined(LIBC_SCCS) && !defined(lint) | 42 | #if defined(LIBC_SCCS) && !defined(lint) | |
43 | __RCSID("$NetBSD: rmd160.c,v 1.3 2007/07/18 13:57:54 joerg Exp $"); | 43 | __RCSID("rmd160.c,v 1.3 2007/07/18 13:57:54 joerg Exp"); | |
44 | #endif /* LIBC_SCCS and not lint */ | 44 | #endif /* LIBC_SCCS and not lint */ | |
45 | 45 | |||
46 | #include "namespace.h" | 46 | #include "namespace.h" | |
47 | #include <assert.h> | 47 | #include <assert.h> | |
48 | #include <string.h> | 48 | #include <string.h> | |
49 | 49 | |||
50 | #endif | 50 | #endif | |
51 | 51 | |||
52 | #include <sys/types.h> | 52 | #include <sys/types.h> | |
53 | #include <sys/param.h> | 53 | #include <sys/param.h> | |
54 | #include <sys/rmd160.h> | 54 | #include <sys/rmd160.h> | |
55 | 55 | |||
56 | 56 | |||
@@ -120,82 +120,82 @@ __weak_alias(RMD160Transform,_RMD160Tran | @@ -120,82 +120,82 @@ __weak_alias(RMD160Transform,_RMD160Tran | |||
120 | 120 | |||
121 | void | 121 | void | |
122 | RMD160Init(RMD160_CTX *ctx) | 122 | RMD160Init(RMD160_CTX *ctx) | |
123 | { | 123 | { | |
124 | ctx->count = 0; | 124 | ctx->count = 0; | |
125 | ctx->state[0] = H0; | 125 | ctx->state[0] = H0; | |
126 | ctx->state[1] = H1; | 126 | ctx->state[1] = H1; | |
127 | ctx->state[2] = H2; | 127 | ctx->state[2] = H2; | |
128 | ctx->state[3] = H3; | 128 | ctx->state[3] = H3; | |
129 | ctx->state[4] = H4; | 129 | ctx->state[4] = H4; | |
130 | } | 130 | } | |
131 | 131 | |||
132 | void | 132 | void | |
133 | RMD160Update(RMD160_CTX *ctx, const u_char *input, u_int32_t len) | 133 | RMD160Update(RMD160_CTX *ctx, const u_char *input, uint32_t len) | |
134 | { | 134 | { | |
135 | u_int32_t have, off, need; | 135 | uint32_t have, off, need; | |
136 | 136 | |||
137 | have = (u_int32_t)((ctx->count/8) % 64); | 137 | have = (uint32_t)((ctx->count/8) % 64); | |
138 | need = 64 - have; | 138 | need = 64 - have; | |
139 | ctx->count += 8 * len; | 139 | ctx->count += 8 * len; | |
140 | off = 0; | 140 | off = 0; | |
141 | 141 | |||
142 | if (len >= need) { | 142 | if (len >= need) { | |
143 | if (have) { | 143 | if (have) { | |
144 | memcpy(ctx->buffer + have, input, (size_t)need); | 144 | memcpy(ctx->buffer + have, input, (size_t)need); | |
145 | RMD160Transform(ctx->state, ctx->buffer); | 145 | RMD160Transform(ctx->state, ctx->buffer); | |
146 | off = need; | 146 | off = need; | |
147 | have = 0; | 147 | have = 0; | |
148 | } | 148 | } | |
149 | /* now the buffer is empty */ | 149 | /* now the buffer is empty */ | |
150 | while (off + 64 <= len) { | 150 | while (off + 64 <= len) { | |
151 | RMD160Transform(ctx->state, input+off); | 151 | RMD160Transform(ctx->state, input+off); | |
152 | off += 64; | 152 | off += 64; | |
153 | } | 153 | } | |
154 | } | 154 | } | |
155 | if (off < len) | 155 | if (off < len) | |
156 | memcpy(ctx->buffer + have, input+off, (size_t)len-off); | 156 | memcpy(ctx->buffer + have, input+off, (size_t)len-off); | |
157 | } | 157 | } | |
158 | 158 | |||
159 | void | 159 | void | |
160 | RMD160Final(u_char digest[20], RMD160_CTX *ctx) | 160 | RMD160Final(u_char digest[20], RMD160_CTX *ctx) | |
161 | { | 161 | { | |
162 | int i; | 162 | int i; | |
163 | u_char size[8]; | 163 | u_char size[8]; | |
164 | u_int32_t padlen; | 164 | uint32_t padlen; | |
165 | 165 | |||
166 | PUT_64BIT_LE(size, ctx->count); | 166 | PUT_64BIT_LE(size, ctx->count); | |
167 | 167 | |||
168 | /* | 168 | /* | |
169 | * pad to 64 byte blocks, at least one byte from PADDING plus 8 bytes | 169 | * pad to 64 byte blocks, at least one byte from PADDING plus 8 bytes | |
170 | * for the size | 170 | * for the size | |
171 | */ | 171 | */ | |
172 | padlen = (u_int32_t)(64 - ((ctx->count/8) % 64)); | 172 | padlen = (uint32_t)(64 - ((ctx->count/8) % 64)); | |
173 | if (padlen < 1 + 8) | 173 | if (padlen < 1 + 8) | |
174 | padlen += 64; | 174 | padlen += 64; | |
175 | RMD160Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */ | 175 | RMD160Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */ | |
176 | RMD160Update(ctx, size, 8); | 176 | RMD160Update(ctx, size, 8); | |
177 | 177 | |||
178 | if (digest != NULL) | 178 | if (digest != NULL) | |
179 | for (i = 0; i < 5; i++) | 179 | for (i = 0; i < 5; i++) | |
180 | PUT_32BIT_LE(digest + i*4, ctx->state[i]); | 180 | PUT_32BIT_LE(digest + i*4, ctx->state[i]); | |
181 | 181 | |||
182 | memset(ctx, 0, sizeof (*ctx)); | 182 | memset(ctx, 0, sizeof (*ctx)); | |
183 | } | 183 | } | |
184 | 184 | |||
185 | void | 185 | void | |
186 | RMD160Transform(u_int32_t state[5], const u_char block[64]) | 186 | RMD160Transform(uint32_t state[5], const u_char block[64]) | |
187 | { | 187 | { | |
188 | u_int32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16]; | 188 | uint32_t a, b, c, d, e, aa, bb, cc, dd, ee, t, x[16]; | |
189 | 189 | |||
190 | #if BYTE_ORDER == LITTLE_ENDIAN | 190 | #if BYTE_ORDER == LITTLE_ENDIAN | |
191 | memcpy(x, block, (size_t)64); | 191 | memcpy(x, block, (size_t)64); | |
192 | #else | 192 | #else | |
193 | int i; | 193 | int i; | |
194 | 194 | |||
195 | for (i = 0; i < 16; i++) | 195 | for (i = 0; i < 16; i++) | |
196 | x[i] = le32dec(block+i*4); | 196 | x[i] = le32dec(block+i*4); | |
197 | #endif | 197 | #endif | |
198 | 198 | |||
199 | a = state[0]; | 199 | a = state[0]; | |
200 | b = state[1]; | 200 | b = state[1]; | |
201 | c = state[2]; | 201 | c = state[2]; |
--- src/common/lib/libc/hash/sha1/sha1.c 2006/10/27 21:25:21 1.2
+++ src/common/lib/libc/hash/sha1/sha1.c 2008/03/23 00:12:44 1.2.16.1
@@ -1,43 +1,43 @@ | @@ -1,43 +1,43 @@ | |||
1 | /* $NetBSD: sha1.c,v 1.2 2006/10/27 21:25:21 christos Exp $ */ | 1 | /* sha1.c,v 1.2 2006/10/27 21:25:21 christos Exp */ | |
2 | /* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */ | 2 | /* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * SHA-1 in C | 5 | * SHA-1 in C | |
6 | * By Steve Reid <steve@edmweb.com> | 6 | * By Steve Reid <steve@edmweb.com> | |
7 | * 100% Public Domain | 7 | * 100% Public Domain | |
8 | * | 8 | * | |
9 | * Test Vectors (from FIPS PUB 180-1) | 9 | * Test Vectors (from FIPS PUB 180-1) | |
10 | * "abc" | 10 | * "abc" | |
11 | * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D | 11 | * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D | |
12 | * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" | 12 | * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" | |
13 | * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 | 13 | * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 | |
14 | * A million repetitions of "a" | 14 | * A million repetitions of "a" | |
15 | * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F | 15 | * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F | |
16 | */ | 16 | */ | |
17 | 17 | |||
18 | #define SHA1HANDSOFF /* Copies data before messing with it. */ | 18 | #define SHA1HANDSOFF /* Copies data before messing with it. */ | |
19 | 19 | |||
20 | #include <sys/cdefs.h> | 20 | #include <sys/cdefs.h> | |
21 | 21 | |||
22 | #if defined(_KERNEL) || defined(_STANDALONE) | 22 | #if defined(_KERNEL) || defined(_STANDALONE) | |
23 | __KERNEL_RCSID(0, "$NetBSD: sha1.c,v 1.2 2006/10/27 21:25:21 christos Exp $"); | 23 | __KERNEL_RCSID(0, "sha1.c,v 1.2 2006/10/27 21:25:21 christos Exp"); | |
24 | 24 | |||
25 | #include <lib/libkern/libkern.h> | 25 | #include <lib/libkern/libkern.h> | |
26 | 26 | |||
27 | #else | 27 | #else | |
28 | 28 | |||
29 | #if defined(LIBC_SCCS) && !defined(lint) | 29 | #if defined(LIBC_SCCS) && !defined(lint) | |
30 | __RCSID("$NetBSD: sha1.c,v 1.2 2006/10/27 21:25:21 christos Exp $"); | 30 | __RCSID("sha1.c,v 1.2 2006/10/27 21:25:21 christos Exp"); | |
31 | #endif /* LIBC_SCCS and not lint */ | 31 | #endif /* LIBC_SCCS and not lint */ | |
32 | 32 | |||
33 | #include "namespace.h" | 33 | #include "namespace.h" | |
34 | #include <assert.h> | 34 | #include <assert.h> | |
35 | #include <string.h> | 35 | #include <string.h> | |
36 | 36 | |||
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/types.h> | 39 | #include <sys/types.h> | |
40 | #include <sys/sha1.h> | 40 | #include <sys/sha1.h> | |
41 | 41 | |||
42 | 42 | |||
43 | #if HAVE_NBTOOL_CONFIG_H | 43 | #if HAVE_NBTOOL_CONFIG_H | |
@@ -80,86 +80,86 @@ __weak_alias(SHA1Final,_SHA1Final) | @@ -80,86 +80,86 @@ __weak_alias(SHA1Final,_SHA1Final) | |||
80 | 80 | |||
81 | typedef union { | 81 | typedef union { | |
82 | u_char c[64]; | 82 | u_char c[64]; | |
83 | u_int l[16]; | 83 | u_int l[16]; | |
84 | } CHAR64LONG16; | 84 | } CHAR64LONG16; | |
85 | 85 | |||
86 | /* old sparc64 gcc could not compile this */ | 86 | /* old sparc64 gcc could not compile this */ | |
87 | #undef SPARC64_GCC_WORKAROUND | 87 | #undef SPARC64_GCC_WORKAROUND | |
88 | #if defined(__sparc64__) && defined(__GNUC__) && __GNUC__ < 3 | 88 | #if defined(__sparc64__) && defined(__GNUC__) && __GNUC__ < 3 | |
89 | #define SPARC64_GCC_WORKAROUND | 89 | #define SPARC64_GCC_WORKAROUND | |
90 | #endif | 90 | #endif | |
91 | 91 | |||
92 | #ifdef SPARC64_GCC_WORKAROUND | 92 | #ifdef SPARC64_GCC_WORKAROUND | |
93 | void do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *); | 93 | void do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *); | |
94 | void do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *); | 94 | void do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *); | |
95 | void do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *); | 95 | void do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *); | |
96 | void do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *); | 96 | void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *); | |
97 | 97 | |||
98 | #define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i) | 98 | #define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i) | |
99 | #define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i) | 99 | #define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i) | |
100 | #define nR2(v,w,x,y,z,i) R2(*v,*w,*x,*y,*z,i) | 100 | #define nR2(v,w,x,y,z,i) R2(*v,*w,*x,*y,*z,i) | |
101 | #define nR3(v,w,x,y,z,i) R3(*v,*w,*x,*y,*z,i) | 101 | #define nR3(v,w,x,y,z,i) R3(*v,*w,*x,*y,*z,i) | |
102 | #define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i) | 102 | #define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i) | |
103 | 103 | |||
104 | void | 104 | void | |
105 | do_R01(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block) | 105 | do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block) | |
106 | { | 106 | { | |
107 | nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3); | 107 | nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3); | |
108 | nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7); | 108 | nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7); | |
109 | nR0(c,d,e,a,b, 8); nR0(b,c,d,e,a, 9); nR0(a,b,c,d,e,10); nR0(e,a,b,c,d,11); | 109 | nR0(c,d,e,a,b, 8); nR0(b,c,d,e,a, 9); nR0(a,b,c,d,e,10); nR0(e,a,b,c,d,11); | |
110 | nR0(d,e,a,b,c,12); nR0(c,d,e,a,b,13); nR0(b,c,d,e,a,14); nR0(a,b,c,d,e,15); | 110 | nR0(d,e,a,b,c,12); nR0(c,d,e,a,b,13); nR0(b,c,d,e,a,14); nR0(a,b,c,d,e,15); | |
111 | nR1(e,a,b,c,d,16); nR1(d,e,a,b,c,17); nR1(c,d,e,a,b,18); nR1(b,c,d,e,a,19); | 111 | nR1(e,a,b,c,d,16); nR1(d,e,a,b,c,17); nR1(c,d,e,a,b,18); nR1(b,c,d,e,a,19); | |
112 | } | 112 | } | |
113 | 113 | |||
114 | void | 114 | void | |
115 | do_R2(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block) | 115 | do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block) | |
116 | { | 116 | { | |
117 | nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23); | 117 | nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23); | |
118 | nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27); | 118 | nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27); | |
119 | nR2(c,d,e,a,b,28); nR2(b,c,d,e,a,29); nR2(a,b,c,d,e,30); nR2(e,a,b,c,d,31); | 119 | nR2(c,d,e,a,b,28); nR2(b,c,d,e,a,29); nR2(a,b,c,d,e,30); nR2(e,a,b,c,d,31); | |
120 | nR2(d,e,a,b,c,32); nR2(c,d,e,a,b,33); nR2(b,c,d,e,a,34); nR2(a,b,c,d,e,35); | 120 | nR2(d,e,a,b,c,32); nR2(c,d,e,a,b,33); nR2(b,c,d,e,a,34); nR2(a,b,c,d,e,35); | |
121 | nR2(e,a,b,c,d,36); nR2(d,e,a,b,c,37); nR2(c,d,e,a,b,38); nR2(b,c,d,e,a,39); | 121 | nR2(e,a,b,c,d,36); nR2(d,e,a,b,c,37); nR2(c,d,e,a,b,38); nR2(b,c,d,e,a,39); | |
122 | } | 122 | } | |
123 | 123 | |||
124 | void | 124 | void | |
125 | do_R3(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block) | 125 | do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block) | |
126 | { | 126 | { | |
127 | nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43); | 127 | nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43); | |
128 | nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47); | 128 | nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47); | |
129 | nR3(c,d,e,a,b,48); nR3(b,c,d,e,a,49); nR3(a,b,c,d,e,50); nR3(e,a,b,c,d,51); | 129 | nR3(c,d,e,a,b,48); nR3(b,c,d,e,a,49); nR3(a,b,c,d,e,50); nR3(e,a,b,c,d,51); | |
130 | nR3(d,e,a,b,c,52); nR3(c,d,e,a,b,53); nR3(b,c,d,e,a,54); nR3(a,b,c,d,e,55); | 130 | nR3(d,e,a,b,c,52); nR3(c,d,e,a,b,53); nR3(b,c,d,e,a,54); nR3(a,b,c,d,e,55); | |
131 | nR3(e,a,b,c,d,56); nR3(d,e,a,b,c,57); nR3(c,d,e,a,b,58); nR3(b,c,d,e,a,59); | 131 | nR3(e,a,b,c,d,56); nR3(d,e,a,b,c,57); nR3(c,d,e,a,b,58); nR3(b,c,d,e,a,59); | |
132 | } | 132 | } | |
133 | 133 | |||
134 | void | 134 | void | |
135 | do_R4(u_int32_t *a, u_int32_t *b, u_int32_t *c, u_int32_t *d, u_int32_t *e, CHAR64LONG16 *block) | 135 | do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block) | |
136 | { | 136 | { | |
137 | nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63); | 137 | nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63); | |
138 | nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67); | 138 | nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67); | |
139 | nR4(c,d,e,a,b,68); nR4(b,c,d,e,a,69); nR4(a,b,c,d,e,70); nR4(e,a,b,c,d,71); | 139 | nR4(c,d,e,a,b,68); nR4(b,c,d,e,a,69); nR4(a,b,c,d,e,70); nR4(e,a,b,c,d,71); | |
140 | nR4(d,e,a,b,c,72); nR4(c,d,e,a,b,73); nR4(b,c,d,e,a,74); nR4(a,b,c,d,e,75); | 140 | nR4(d,e,a,b,c,72); nR4(c,d,e,a,b,73); nR4(b,c,d,e,a,74); nR4(a,b,c,d,e,75); | |
141 | nR4(e,a,b,c,d,76); nR4(d,e,a,b,c,77); nR4(c,d,e,a,b,78); nR4(b,c,d,e,a,79); | 141 | nR4(e,a,b,c,d,76); nR4(d,e,a,b,c,77); nR4(c,d,e,a,b,78); nR4(b,c,d,e,a,79); | |
142 | } | 142 | } | |
143 | #endif | 143 | #endif | |
144 | 144 | |||
145 | /* | 145 | /* | |
146 | * Hash a single 512-bit block. This is the core of the algorithm. | 146 | * Hash a single 512-bit block. This is the core of the algorithm. | |
147 | */ | 147 | */ | |
148 | void SHA1Transform(state, buffer) | 148 | void SHA1Transform(state, buffer) | |
149 | u_int32_t state[5]; | 149 | uint32_t state[5]; | |
150 | const u_char buffer[64]; | 150 | const u_char buffer[64]; | |
151 | { | 151 | { | |
152 | u_int32_t a, b, c, d, e; | 152 | uint32_t a, b, c, d, e; | |
153 | CHAR64LONG16 *block; | 153 | CHAR64LONG16 *block; | |
154 | 154 | |||
155 | #ifdef SHA1HANDSOFF | 155 | #ifdef SHA1HANDSOFF | |
156 | CHAR64LONG16 workspace; | 156 | CHAR64LONG16 workspace; | |
157 | #endif | 157 | #endif | |
158 | 158 | |||
159 | _DIAGASSERT(buffer != 0); | 159 | _DIAGASSERT(buffer != 0); | |
160 | _DIAGASSERT(state != 0); | 160 | _DIAGASSERT(state != 0); | |
161 | 161 | |||
162 | #ifdef SHA1HANDSOFF | 162 | #ifdef SHA1HANDSOFF | |
163 | block = &workspace; | 163 | block = &workspace; | |
164 | (void)memcpy(block, buffer, 64); | 164 | (void)memcpy(block, buffer, 64); | |
165 | #else | 165 | #else |
--- src/common/lib/libc/hash/sha2/sha2.c 2007/07/18 16:58:14 1.6
+++ src/common/lib/libc/hash/sha2/sha2.c 2008/03/23 00:12:44 1.6.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sha2.c,v 1.6 2007/07/18 16:58:14 drochner Exp $ */ | 1 | /* sha2.c,v 1.6 2007/07/18 16:58:14 drochner Exp */ | |
2 | /* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */ | 2 | /* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * sha2.c | 5 | * sha2.c | |
6 | * | 6 | * | |
7 | * Version 1.0.0beta1 | 7 | * Version 1.0.0beta1 | |
8 | * | 8 | * | |
9 | * Written by Aaron D. Gifford <me@aarongifford.com> | 9 | * Written by Aaron D. Gifford <me@aarongifford.com> | |
10 | * | 10 | * | |
11 | * Copyright 2000 Aaron D. Gifford. All rights reserved. | 11 | * Copyright 2000 Aaron D. Gifford. All rights reserved. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -29,34 +29,34 @@ | @@ -29,34 +29,34 @@ | |||
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | * SUCH DAMAGE. | 35 | * SUCH DAMAGE. | |
36 | * | 36 | * | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | 40 | |||
41 | #if defined(_KERNEL) || defined(_STANDALONE) | 41 | #if defined(_KERNEL) || defined(_STANDALONE) | |
42 | __KERNEL_RCSID(0, "$NetBSD: sha2.c,v 1.6 2007/07/18 16:58:14 drochner Exp $"); | 42 | __KERNEL_RCSID(0, "sha2.c,v 1.6 2007/07/18 16:58:14 drochner Exp"); | |
43 | 43 | |||
44 | #include <lib/libkern/libkern.h> | 44 | #include <lib/libkern/libkern.h> | |
45 | 45 | |||
46 | #else | 46 | #else | |
47 | 47 | |||
48 | #if defined(LIBC_SCCS) && !defined(lint) | 48 | #if defined(LIBC_SCCS) && !defined(lint) | |
49 | __RCSID("$NetBSD: sha2.c,v 1.6 2007/07/18 16:58:14 drochner Exp $"); | 49 | __RCSID("sha2.c,v 1.6 2007/07/18 16:58:14 drochner Exp"); | |
50 | #endif /* LIBC_SCCS and not lint */ | 50 | #endif /* LIBC_SCCS and not lint */ | |
51 | 51 | |||
52 | #include "namespace.h" | 52 | #include "namespace.h" | |
53 | #include <assert.h> | 53 | #include <assert.h> | |
54 | #include <string.h> | 54 | #include <string.h> | |
55 | 55 | |||
56 | #endif | 56 | #endif | |
57 | 57 | |||
58 | #include <sys/types.h> | 58 | #include <sys/types.h> | |
59 | #include <sys/param.h> | 59 | #include <sys/param.h> | |
60 | #include <sys/sha2.h> | 60 | #include <sys/sha2.h> | |
61 | 61 | |||
62 | /* | 62 | /* | |
@@ -109,38 +109,38 @@ __RCSID("$NetBSD: sha2.c,v 1.6 2007/07/1 | @@ -109,38 +109,38 @@ __RCSID("$NetBSD: sha2.c,v 1.6 2007/07/1 | |||
109 | * | 109 | * | |
110 | * The FreeBSD machine this was written on defines BYTE_ORDER | 110 | * The FreeBSD machine this was written on defines BYTE_ORDER | |
111 | * appropriately by including <sys/types.h> (which in turn includes | 111 | * appropriately by including <sys/types.h> (which in turn includes | |
112 | * <machine/endian.h> where the appropriate definitions are actually | 112 | * <machine/endian.h> where the appropriate definitions are actually | |
113 | * made). | 113 | * made). | |
114 | */ | 114 | */ | |
115 | #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) | 115 | #if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) | |
116 | #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN | 116 | #error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN | |
117 | #endif | 117 | #endif | |
118 | 118 | |||
119 | /* | 119 | /* | |
120 | * Define the followingsha2_* types to types of the correct length on | 120 | * Define the followingsha2_* types to types of the correct length on | |
121 | * the native archtecture. Most BSD systems and Linux define u_intXX_t | 121 | * the native archtecture. Most BSD systems and Linux define u_intXX_t | |
122 | * types. Machines with very recent ANSI C headers, can use the | 122 | * types. Machines with recent ANSI C headers, can use the standard C99 | |
123 | * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H | 123 | * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H | |
124 | * during compile or in the sha.h header file. | 124 | * during compile or in the sha.h header file. | |
125 | * | 125 | * | |
126 | * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t | 126 | * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t | |
127 | * will need to define these three typedefs below (and the appropriate | 127 | * will need to define these three typedefs below (and the appropriate | |
128 | * ones in sha.h too) by hand according to their system architecture. | 128 | * ones in sha.h too) by hand according to their system architecture. | |
129 | * | 129 | * | |
130 | * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t | 130 | * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t | |
131 | * types and pointing out recent ANSI C support for uintXX_t in inttypes.h. | 131 | * types and pointing out recent ANSI C support for uintXX_t in inttypes.h. | |
132 | */ | 132 | */ | |
133 | #if 0 /*def SHA2_USE_INTTYPES_H*/ | 133 | #if 1 /*def SHA2_USE_INTTYPES_H*/ | |
134 | 134 | |||
135 | typedef uint8_t sha2_byte; /* Exactly 1 byte */ | 135 | typedef uint8_t sha2_byte; /* Exactly 1 byte */ | |
136 | typedef uint32_t sha2_word32; /* Exactly 4 bytes */ | 136 | typedef uint32_t sha2_word32; /* Exactly 4 bytes */ | |
137 | typedef uint64_t sha2_word64; /* Exactly 8 bytes */ | 137 | typedef uint64_t sha2_word64; /* Exactly 8 bytes */ | |
138 | 138 | |||
139 | #else /* SHA2_USE_INTTYPES_H */ | 139 | #else /* SHA2_USE_INTTYPES_H */ | |
140 | 140 | |||
141 | typedef u_int8_t sha2_byte; /* Exactly 1 byte */ | 141 | typedef u_int8_t sha2_byte; /* Exactly 1 byte */ | |
142 | typedef u_int32_t sha2_word32; /* Exactly 4 bytes */ | 142 | typedef u_int32_t sha2_word32; /* Exactly 4 bytes */ | |
143 | typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ | 143 | typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ | |
144 | 144 | |||
145 | #endif /* SHA2_USE_INTTYPES_H */ | 145 | #endif /* SHA2_USE_INTTYPES_H */ | |
146 | 146 |
--- src/common/lib/libc/inet/inet_addr.c 2005/12/20 19:28:51 1.1
+++ src/common/lib/libc/inet/inet_addr.c 2008/03/23 00:12:44 1.1.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: inet_addr.c,v 1.1 2005/12/20 19:28:51 christos Exp $ */ | 1 | /* inet_addr.c,v 1.1 2005/12/20 19:28:51 christos Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1983, 1990, 1993 | 4 | * Copyright (c) 1983, 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -67,27 +67,27 @@ | @@ -67,27 +67,27 @@ | |||
67 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 67 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
68 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 68 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
69 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 69 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
70 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 70 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
71 | */ | 71 | */ | |
72 | 72 | |||
73 | #if !defined(_KERNEL) && !defined(_STANDALONE) | 73 | #if !defined(_KERNEL) && !defined(_STANDALONE) | |
74 | #include <sys/cdefs.h> | 74 | #include <sys/cdefs.h> | |
75 | #if defined(LIBC_SCCS) && !defined(lint) | 75 | #if defined(LIBC_SCCS) && !defined(lint) | |
76 | #if 0 | 76 | #if 0 | |
77 | static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; | 77 | static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93"; | |
78 | static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp"; | 78 | static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp"; | |
79 | #else | 79 | #else | |
80 | __RCSID("$NetBSD: inet_addr.c,v 1.1 2005/12/20 19:28:51 christos Exp $"); | 80 | __RCSID("inet_addr.c,v 1.1 2005/12/20 19:28:51 christos Exp"); | |
81 | #endif | 81 | #endif | |
82 | #endif /* LIBC_SCCS and not lint */ | 82 | #endif /* LIBC_SCCS and not lint */ | |
83 | 83 | |||
84 | #include "port_before.h" | 84 | #include "port_before.h" | |
85 | 85 | |||
86 | #include "namespace.h" | 86 | #include "namespace.h" | |
87 | #include <sys/types.h> | 87 | #include <sys/types.h> | |
88 | #include <sys/param.h> | 88 | #include <sys/param.h> | |
89 | 89 | |||
90 | #include <netinet/in.h> | 90 | #include <netinet/in.h> | |
91 | #include <arpa/inet.h> | 91 | #include <arpa/inet.h> | |
92 | 92 | |||
93 | #include <ctype.h> | 93 | #include <ctype.h> | |
@@ -96,49 +96,49 @@ __RCSID("$NetBSD: inet_addr.c,v 1.1 2005 | @@ -96,49 +96,49 @@ __RCSID("$NetBSD: inet_addr.c,v 1.1 2005 | |||
96 | 96 | |||
97 | #ifdef __weak_alias | 97 | #ifdef __weak_alias | |
98 | __weak_alias(inet_aton,_inet_aton) | 98 | __weak_alias(inet_aton,_inet_aton) | |
99 | #endif | 99 | #endif | |
100 | #else | 100 | #else | |
101 | #include <lib/libkern/libkern.h> | 101 | #include <lib/libkern/libkern.h> | |
102 | #include <netinet/in.h> | 102 | #include <netinet/in.h> | |
103 | #endif | 103 | #endif | |
104 | 104 | |||
105 | /* | 105 | /* | |
106 | * Ascii internet address interpretation routine. | 106 | * Ascii internet address interpretation routine. | |
107 | * The value returned is in network order. | 107 | * The value returned is in network order. | |
108 | */ | 108 | */ | |
109 | u_int32_t | 109 | uint32_t | |
110 | inet_addr(const char *cp) { | 110 | inet_addr(const char *cp) { | |
111 | struct in_addr val; | 111 | struct in_addr val; | |
112 | 112 | |||
113 | if (inet_aton(cp, &val)) | 113 | if (inet_aton(cp, &val)) | |
114 | return (val.s_addr); | 114 | return (val.s_addr); | |
115 | return (INADDR_NONE); | 115 | return (INADDR_NONE); | |
116 | } | 116 | } | |
117 | 117 | |||
118 | /* | 118 | /* | |
119 | * Check whether "cp" is a valid ascii representation | 119 | * Check whether "cp" is a valid ascii representation | |
120 | * of an Internet address and convert to a binary address. | 120 | * of an Internet address and convert to a binary address. | |
121 | * Returns 1 if the address is valid, 0 if not. | 121 | * Returns 1 if the address is valid, 0 if not. | |
122 | * This replaces inet_addr, the return value from which | 122 | * This replaces inet_addr, the return value from which | |
123 | * cannot distinguish between failure and a local broadcast address. | 123 | * cannot distinguish between failure and a local broadcast address. | |
124 | */ | 124 | */ | |
125 | int | 125 | int | |
126 | inet_aton(const char *cp, struct in_addr *addr) { | 126 | inet_aton(const char *cp, struct in_addr *addr) { | |
127 | u_int32_t val; | 127 | uint32_t val; | |
128 | int base, n; | 128 | int base, n; | |
129 | char c; | 129 | char c; | |
130 | u_int8_t parts[4]; | 130 | uint8_t parts[4]; | |
131 | u_int8_t *pp = parts; | 131 | uint8_t *pp = parts; | |
132 | int digit; | 132 | int digit; | |
133 | 133 | |||
134 | c = *cp; | 134 | c = *cp; | |
135 | for (;;) { | 135 | for (;;) { | |
136 | /* | 136 | /* | |
137 | * Collect number up to ``.''. | 137 | * Collect number up to ``.''. | |
138 | * Values are specified as for C: | 138 | * Values are specified as for C: | |
139 | * 0x=hex, 0=octal, isdigit=decimal. | 139 | * 0x=hex, 0=octal, isdigit=decimal. | |
140 | */ | 140 | */ | |
141 | if (!isdigit((unsigned char)c)) | 141 | if (!isdigit((unsigned char)c)) | |
142 | return (0); | 142 | return (0); | |
143 | val = 0; base = 10; digit = 0; | 143 | val = 0; base = 10; digit = 0; | |
144 | if (c == '0') { | 144 | if (c == '0') { |
--- src/common/lib/libc/md/md4c.c 2005/12/24 08:34:10 1.2
+++ src/common/lib/libc/md/md4c.c 2008/03/23 00:12:45 1.2.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md4c.c,v 1.2 2005/12/24 08:34:10 matt Exp $ */ | 1 | /* md4c.c,v 1.2 2005/12/24 08:34:10 matt Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * This file is derived from the RSA Data Security, Inc. MD4 Message-Digest | 4 | * This file is derived from the RSA Data Security, Inc. MD4 Message-Digest | |
5 | * Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org> | 5 | * Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org> | |
6 | * for portability and formatting. | 6 | * for portability and formatting. | |
7 | */ | 7 | */ | |
8 | 8 | |||
9 | /* | 9 | /* | |
10 | * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. | 10 | * Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. | |
11 | * | 11 | * | |
12 | * License to copy and use this software is granted provided that it | 12 | * License to copy and use this software is granted provided that it | |
13 | * is identified as the "RSA Data Security, Inc. MD4 Message-Digest | 13 | * is identified as the "RSA Data Security, Inc. MD4 Message-Digest | |
14 | * Algorithm" in all material mentioning or referencing this software | 14 | * Algorithm" in all material mentioning or referencing this software | |
@@ -21,54 +21,54 @@ | @@ -21,54 +21,54 @@ | |||
21 | * | 21 | * | |
22 | * RSA Data Security, Inc. makes no representations concerning either | 22 | * RSA Data Security, Inc. makes no representations concerning either | |
23 | * the merchantability of this software or the suitability of this | 23 | * the merchantability of this software or the suitability of this | |
24 | * software for any particular purpose. It is provided "as is" | 24 | * software for any particular purpose. It is provided "as is" | |
25 | * without express or implied warranty of any kind. | 25 | * without express or implied warranty of any kind. | |
26 | * | 26 | * | |
27 | * These notices must be retained in any copies of any part of this | 27 | * These notices must be retained in any copies of any part of this | |
28 | * documentation and/or software. | 28 | * documentation and/or software. | |
29 | */ | 29 | */ | |
30 | 30 | |||
31 | #if !defined(_KERNEL) && !defined(_STANDALONE) | 31 | #if !defined(_KERNEL) && !defined(_STANDALONE) | |
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) | |
34 | __RCSID("$NetBSD: md4c.c,v 1.2 2005/12/24 08:34:10 matt Exp $"); | 34 | __RCSID("md4c.c,v 1.2 2005/12/24 08:34:10 matt Exp"); | |
35 | #endif /* LIBC_SCCS and not lint */ | 35 | #endif /* LIBC_SCCS and not lint */ | |
36 | 36 | |||
37 | #include "namespace.h" | 37 | #include "namespace.h" | |
38 | 38 | |||
39 | #include <sys/types.h> | 39 | #include <sys/types.h> | |
40 | 40 | |||
41 | #include <assert.h> | 41 | #include <assert.h> | |
42 | #include <md4.h> | 42 | #include <md4.h> | |
43 | #include <string.h> | 43 | #include <string.h> | |
44 | 44 | |||
45 | #if HAVE_NBTOOL_CONFIG_H | 45 | #if HAVE_NBTOOL_CONFIG_H | |
46 | #include "nbtool_config.h" | 46 | #include "nbtool_config.h" | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | #else | 49 | #else | |
50 | 50 | |||
51 | #include <sys/param.h> | 51 | #include <sys/param.h> | |
52 | #include <sys/md4.h> | 52 | #include <sys/md4.h> | |
53 | #include <lib/libkern/libkern.h> | 53 | #include <lib/libkern/libkern.h> | |
54 | 54 | |||
55 | #endif /* !_KERNEL && !_STANDALONE */ | 55 | #endif /* !_KERNEL && !_STANDALONE */ | |
56 | 56 | |||
57 | #if !HAVE_MD4_H | 57 | #if !HAVE_MD4_H | |
58 | 58 | |||
59 | typedef unsigned char *POINTER; | 59 | typedef unsigned char *POINTER; | |
60 | typedef u_int16_t UINT2; | 60 | typedef uint16_t UINT2; | |
61 | typedef u_int32_t UINT4; | 61 | typedef uint32_t UINT4; | |
62 | 62 | |||
63 | /* | 63 | /* | |
64 | * Constants for MD4Transform routine. | 64 | * Constants for MD4Transform routine. | |
65 | */ | 65 | */ | |
66 | #define S11 3 | 66 | #define S11 3 | |
67 | #define S12 7 | 67 | #define S12 7 | |
68 | #define S13 11 | 68 | #define S13 11 | |
69 | #define S14 19 | 69 | #define S14 19 | |
70 | #define S21 3 | 70 | #define S21 3 | |
71 | #define S22 5 | 71 | #define S22 5 | |
72 | #define S23 9 | 72 | #define S23 9 | |
73 | #define S24 13 | 73 | #define S24 13 | |
74 | #define S31 3 | 74 | #define S31 3 |
--- src/common/lib/libc/md/md5c.c 2005/12/24 08:34:10 1.2
+++ src/common/lib/libc/md/md5c.c 2008/03/23 00:12:45 1.2.18.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: md5c.c,v 1.2 2005/12/24 08:34:10 matt Exp $ */ | 1 | /* md5c.c,v 1.2 2005/12/24 08:34:10 matt Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * This file is derived from the RSA Data Security, Inc. MD5 Message-Digest | 4 | * This file is derived from the RSA Data Security, Inc. MD5 Message-Digest | |
5 | * Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org> | 5 | * Algorithm and has been modified by Jason R. Thorpe <thorpej@NetBSD.org> | |
6 | * for portability and formatting. | 6 | * for portability and formatting. | |
7 | */ | 7 | */ | |
8 | 8 | |||
9 | /* | 9 | /* | |
10 | * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | 10 | * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All | |
11 | * rights reserved. | 11 | * rights reserved. | |
12 | * | 12 | * | |
13 | * License to copy and use this software is granted provided that it | 13 | * License to copy and use this software is granted provided that it | |
14 | * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | 14 | * is identified as the "RSA Data Security, Inc. MD5 Message-Digest | |
@@ -26,46 +26,46 @@ | @@ -26,46 +26,46 @@ | |||
26 | * without express or implied warranty of any kind. | 26 | * without express or implied warranty of any kind. | |
27 | * | 27 | * | |
28 | * These notices must be retained in any copies of any part of this | 28 | * These notices must be retained in any copies of any part of this | |
29 | * documentation and/or software. | 29 | * documentation and/or software. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #if defined(_KERNEL) || defined(_STANDALONE) | 32 | #if defined(_KERNEL) || defined(_STANDALONE) | |
33 | #include <sys/param.h> | 33 | #include <sys/param.h> | |
34 | #include <sys/md5.h> | 34 | #include <sys/md5.h> | |
35 | #include <lib/libkern/libkern.h> | 35 | #include <lib/libkern/libkern.h> | |
36 | #else | 36 | #else | |
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | #if defined(LIBC_SCCS) && !defined(lint) | 38 | #if defined(LIBC_SCCS) && !defined(lint) | |
39 | __RCSID("$NetBSD: md5c.c,v 1.2 2005/12/24 08:34:10 matt Exp $"); | 39 | __RCSID("md5c.c,v 1.2 2005/12/24 08:34:10 matt Exp"); | |
40 | #endif /* LIBC_SCCS and not lint */ | 40 | #endif /* LIBC_SCCS and not lint */ | |
41 | #include "namespace.h" | 41 | #include "namespace.h" | |
42 | #include <sys/types.h> | 42 | #include <sys/types.h> | |
43 | #include <assert.h> | 43 | #include <assert.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | #include <md5.h> | 45 | #include <md5.h> | |
46 | #endif /* _KERNEL || _STANDALONE */ | 46 | #endif /* _KERNEL || _STANDALONE */ | |
47 | 47 | |||
48 | #if HAVE_NBTOOL_CONFIG_H | 48 | #if HAVE_NBTOOL_CONFIG_H | |
49 | #include "nbtool_config.h" | 49 | #include "nbtool_config.h" | |
50 | #endif | 50 | #endif | |
51 | 51 | |||
52 | #if !HAVE_MD5_H | 52 | #if !HAVE_MD5_H | |
53 | 53 | |||
54 | #define ZEROIZE(d, l) memset((d), 0, (l)) | 54 | #define ZEROIZE(d, l) memset((d), 0, (l)) | |
55 | 55 | |||
56 | typedef unsigned char *POINTER; | 56 | typedef unsigned char *POINTER; | |
57 | typedef u_int16_t UINT2; | 57 | typedef uint16_t UINT2; | |
58 | typedef u_int32_t UINT4; | 58 | typedef uint32_t UINT4; | |
59 | 59 | |||
60 | /* | 60 | /* | |
61 | * Constants for MD5Transform routine. | 61 | * Constants for MD5Transform routine. | |
62 | */ | 62 | */ | |
63 | #define S11 7 | 63 | #define S11 7 | |
64 | #define S12 12 | 64 | #define S12 12 | |
65 | #define S13 17 | 65 | #define S13 17 | |
66 | #define S14 22 | 66 | #define S14 22 | |
67 | #define S21 5 | 67 | #define S21 5 | |
68 | #define S22 9 | 68 | #define S22 9 | |
69 | #define S23 14 | 69 | #define S23 14 | |
70 | #define S24 20 | 70 | #define S24 20 | |
71 | #define S31 4 | 71 | #define S31 4 |
--- src/common/lib/libc/string/memchr.c 2007/06/04 18:19:27 1.2
+++ src/common/lib/libc/string/memchr.c 2008/03/23 00:12:45 1.2.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: memchr.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ | 1 | /* memchr.c,v 1.2 2007/06/04 18:19:27 christos Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1990, 1993 | 4 | * Copyright (c) 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to Berkeley by | 7 | * This code is derived from software contributed to Berkeley by | |
8 | * Chris Torek. | 8 | * Chris Torek. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -27,39 +27,40 @@ | @@ -27,39 +27,40 @@ | |||
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | 32 | * SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #include <sys/cdefs.h> | 35 | #include <sys/cdefs.h> | |
36 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) | |
37 | #if 0 | 37 | #if 0 | |
38 | static char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93"; | 38 | static char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93"; | |
39 | #else | 39 | #else | |
40 | __RCSID("$NetBSD: memchr.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); | 40 | __RCSID("memchr.c,v 1.2 2007/06/04 18:19:27 christos Exp"); | |
41 | #endif | 41 | #endif | |
42 | #endif /* LIBC_SCCS and not lint */ | 42 | #endif /* LIBC_SCCS and not lint */ | |
43 | 43 | |||
44 | #if !defined(_KERNEL) && !defined(_STANDALONE) | 44 | #if !defined(_KERNEL) && !defined(_STANDALONE) | |
45 | #include <assert.h> | 45 | #include <assert.h> | |
46 | #include <string.h> | 46 | #include <string.h> | |
47 | #else | 47 | #else | |
48 | #include <lib/libkern/libkern.h> | 48 | #include <lib/libkern/libkern.h> | |
49 | #endif | 49 | #endif | |
50 | 50 | |||
51 | void * | 51 | void * | |
52 | memchr(const void *s, int c, size_t n) | 52 | memchr(const void *s, int c, size_t n) | |
53 | { | 53 | { | |
54 | _DIAGASSERT(s != NULL); | 54 | _DIAGASSERT(s != NULL); | |
55 | 55 | |||
56 | if (n != 0) { | 56 | if (n != 0) { | |
57 | const unsigned char *p = s; | 57 | const unsigned char *p = s; | |
58 | const unsigned char cmp = c; | |||
58 | 59 | |||
59 | do { | 60 | do { | |
60 | if (*p++ == c) | 61 | if (*p++ == cmp) | |
61 | return __UNCONST(p - 1); | 62 | return __UNCONST(p - 1); | |
62 | } while (--n != 0); | 63 | } while (--n != 0); | |
63 | } | 64 | } | |
64 | return NULL; | 65 | return NULL; | |
65 | } | 66 | } |
--- src/common/lib/libc/string/strchr.c 2007/06/04 18:19:27 1.2
+++ src/common/lib/libc/string/strchr.c 2008/03/23 00:12:45 1.2.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: strchr.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ | 1 | /* strchr.c,v 1.2 2007/06/04 18:19:27 christos Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1990, 1993 | 4 | * Copyright (c) 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,44 +24,45 @@ | @@ -24,44 +24,45 @@ | |||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) | |
34 | #if 0 | 34 | #if 0 | |
35 | static char sccsid[] = "@(#)index.c 8.1 (Berkeley) 6/4/93"; | 35 | static char sccsid[] = "@(#)index.c 8.1 (Berkeley) 6/4/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: strchr.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); | 37 | __RCSID("strchr.c,v 1.2 2007/06/04 18:19:27 christos Exp"); | |
38 | #endif | 38 | #endif | |
39 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ | |
40 | 40 | |||
41 | #if !defined(_KERNEL) && !defined(_STANDALONE) | 41 | #if !defined(_KERNEL) && !defined(_STANDALONE) | |
42 | #include "namespace.h" | 42 | #include "namespace.h" | |
43 | #include <assert.h> | 43 | #include <assert.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | #else | 45 | #else | |
46 | #include <lib/libkern/libkern.h> | 46 | #include <lib/libkern/libkern.h> | |
47 | #endif | 47 | #endif | |
48 | 48 | |||
49 | char * | 49 | char * | |
50 | #ifdef INDEX | 50 | #ifdef INDEX | |
51 | index(const char *p, int ch) | 51 | index(const char *p, int ch) | |
52 | #else | 52 | #else | |
53 | strchr(const char *p, int ch) | 53 | strchr(const char *p, int ch) | |
54 | #endif | 54 | #endif | |
55 | { | 55 | { | |
56 | const char cmp = ch; | |||
56 | _DIAGASSERT(p != NULL); | 57 | _DIAGASSERT(p != NULL); | |
57 | 58 | |||
58 | for (;; ++p) { | 59 | for (;; ++p) { | |
59 | if (*p == ch) { | 60 | if (*p == cmp) { | |
60 | /* LINTED const cast-away */ | 61 | /* LINTED const cast-away */ | |
61 | return(__UNCONST(p)); | 62 | return(__UNCONST(p)); | |
62 | } | 63 | } | |
63 | if (!*p) | 64 | if (!*p) | |
64 | return((char *)NULL); | 65 | return((char *)NULL); | |
65 | } | 66 | } | |
66 | /* NOTREACHED */ | 67 | /* NOTREACHED */ | |
67 | } | 68 | } |
--- src/common/lib/libc/string/strrchr.c 2007/06/04 18:19:28 1.3
+++ src/common/lib/libc/string/strrchr.c 2008/03/23 00:12:45 1.3.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: strrchr.c,v 1.3 2007/06/04 18:19:28 christos Exp $ */ | 1 | /* strrchr.c,v 1.3 2007/06/04 18:19:28 christos Exp */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1988, 1993 | 4 | * Copyright (c) 1988, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,46 +24,46 @@ | @@ -24,46 +24,46 @@ | |||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
29 | * SUCH DAMAGE. | 29 | * SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | #if defined(LIBC_SCCS) && !defined(lint) | 33 | #if defined(LIBC_SCCS) && !defined(lint) | |
34 | #if 0 | 34 | #if 0 | |
35 | static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93"; | 35 | static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93"; | |
36 | #else | 36 | #else | |
37 | __RCSID("$NetBSD: strrchr.c,v 1.3 2007/06/04 18:19:28 christos Exp $"); | 37 | __RCSID("strrchr.c,v 1.3 2007/06/04 18:19:28 christos Exp"); | |
38 | #endif | 38 | #endif | |
39 | #endif /* LIBC_SCCS and not lint */ | 39 | #endif /* LIBC_SCCS and not lint */ | |
40 | 40 | |||
41 | #if !defined(_KERNEL) && !defined(_STANDALONE) | 41 | #if !defined(_KERNEL) && !defined(_STANDALONE) | |
42 | #include <assert.h> | 42 | #include <assert.h> | |
43 | #include <string.h> | 43 | #include <string.h> | |
44 | #else | 44 | #else | |
45 | #include <lib/libkern/libkern.h> | 45 | #include <lib/libkern/libkern.h> | |
46 | #endif | 46 | #endif | |
47 | 47 | |||
48 | char * | 48 | char * | |
49 | #ifdef RINDEX | 49 | #ifdef RINDEX | |
50 | rindex(const char *p, int ch) | 50 | rindex(const char *p, int ch) | |
51 | #else | 51 | #else | |
52 | strrchr(const char *p, int ch) | 52 | strrchr(const char *p, int ch) | |
53 | #endif | 53 | #endif | |
54 | { | 54 | { | |
55 | char *save, c; | 55 | char *save; | |
56 | const char c = ch; | |||
56 | 57 | |||
57 | _DIAGASSERT(p != NULL); | 58 | _DIAGASSERT(p != NULL); | |
58 | c = ch; | |||
59 | 59 | |||
60 | for (save = NULL;; ++p) { | 60 | for (save = NULL;; ++p) { | |
61 | if (*p == c) { | 61 | if (*p == c) { | |
62 | /* LINTED const cast-away */ | 62 | /* LINTED const cast-away */ | |
63 | save = __UNCONST(p); | 63 | save = __UNCONST(p); | |
64 | } | 64 | } | |
65 | if (!*p) | 65 | if (!*p) | |
66 | return(save); | 66 | return(save); | |
67 | } | 67 | } | |
68 | /* NOTREACHED */ | 68 | /* NOTREACHED */ | |
69 | } | 69 | } |
--- src/common/lib/libprop/prop_array.3 2008/01/09 01:21:35 1.5.2.1
+++ src/common/lib/libprop/prop_array.3 2008/03/23 00:12:45 1.5.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_array.3,v 1.5.2.1 2008/01/09 01:21:35 matt Exp $ | 1 | .\" prop_array.3,v 1.5.2.1 2008/01/09 01:21:35 matt Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -110,76 +110,93 @@ | @@ -110,76 +110,93 @@ | |||
110 | .\" | 110 | .\" | |
111 | .Ft bool | 111 | .Ft bool | |
112 | .Fn prop_array_equals "prop_array_t array1" "prop_array_t array2" | 112 | .Fn prop_array_equals "prop_array_t array1" "prop_array_t array2" | |
113 | .Sh DESCRIPTION | 113 | .Sh DESCRIPTION | |
114 | The | 114 | The | |
115 | .Nm prop_array | 115 | .Nm prop_array | |
116 | family of functions operate on the array property collection object type. | 116 | family of functions operate on the array property collection object type. | |
117 | An array is an ordered set; an iterated array will return objects in the | 117 | An array is an ordered set; an iterated array will return objects in the | |
118 | same order with which they were stored. | 118 | same order with which they were stored. | |
119 | .Bl -tag -width "xxxxx" | 119 | .Bl -tag -width "xxxxx" | |
120 | .It Fn prop_array_create "void" | 120 | .It Fn prop_array_create "void" | |
121 | Create an empty array. | 121 | Create an empty array. | |
122 | The array initially has no capacity. | 122 | The array initially has no capacity. | |
123 | Returns | |||
124 | .Dv NULL | |||
125 | on failure. | |||
123 | .It Fn prop_array_create_with_capacity "unsigned int capacity" | 126 | .It Fn prop_array_create_with_capacity "unsigned int capacity" | |
124 | Create an array with the capacity to store | 127 | Create an array with the capacity to store | |
125 | .Fa capacity | 128 | .Fa capacity | |
126 | objects. | 129 | objects. | |
130 | Returns | |||
131 | .Dv NULL | |||
132 | on failure. | |||
127 | .It Fn prop_array_copy "prop_array_t array" | 133 | .It Fn prop_array_copy "prop_array_t array" | |
128 | Copy an array. | 134 | Copy an array. | |
129 | The new array has an initial capacity equal to the number of objects stored | 135 | The new array has an initial capacity equal to the number of objects stored | |
130 | in the array being copied. | 136 | in the array being copied. | |
131 | The new array contains references to the original array's objects, not | 137 | The new array contains references to the original array's objects, not | |
132 | copies of those objects | 138 | copies of those objects | |
133 | .Pq i.e. a shallow copy is made . | 139 | .Pq i.e. a shallow copy is made . | |
134 | If the original array is immutable, the resulting array is also immutable. | 140 | If the original array is immutable, the resulting array is also immutable. | |
141 | Returns | |||
142 | .Dv NULL | |||
143 | on failure. | |||
135 | .It Fn prop_array_copy_mutable "prop_array_t array" | 144 | .It Fn prop_array_copy_mutable "prop_array_t array" | |
136 | Like | 145 | Like | |
137 | .Fn prop_array_copy , | 146 | .Fn prop_array_copy , | |
138 | except the resulting array is always mutable. | 147 | except the resulting array is always mutable. | |
139 | .It Fn prop_array_capacity "prop_array_t array" | 148 | .It Fn prop_array_capacity "prop_array_t array" | |
140 | Returns the total capacity of the array, including objects already stored | 149 | Returns the total capacity of the array, including objects already stored | |
141 | in the array. | 150 | in the array. | |
151 | If the supplied object isn't an array, zero is returned. | |||
142 | .It Fn prop_array_count "prop_array_t array" | 152 | .It Fn prop_array_count "prop_array_t array" | |
143 | Returns the number of objects stored in the array. | 153 | Returns the number of objects stored in the array. | |
154 | If the supplied object isn't an array, zero is returned. | |||
144 | .It Fn prop_array_ensure_capacity "prop_array_t array" "unsigned int capacity" | 155 | .It Fn prop_array_ensure_capacity "prop_array_t array" "unsigned int capacity" | |
145 | Ensure that the array has a total capacity of | 156 | Ensure that the array has a total capacity of | |
146 | .Fa capacity , | 157 | .Fa capacity , | |
147 | including objects already stored in the array. | 158 | including objects already stored in the array. | |
148 | Returns | 159 | Returns | |
149 | .Dv true | 160 | .Dv true | |
150 | if the capacity of the array is greater or equal to | 161 | if the capacity of the array is greater or equal to | |
151 | .Fa capacity | 162 | .Fa capacity | |
152 | or if expansion of the array's capacity was successful | 163 | or if expansion of the array's capacity was successful | |
153 | and | 164 | and | |
154 | .Dv false | 165 | .Dv false | |
155 | otherwise. | 166 | otherwise. | |
156 | .It Fn prop_array_iterator "prop_array_t array" | 167 | .It Fn prop_array_iterator "prop_array_t array" | |
157 | Create an iterator for the array. | 168 | Create an iterator for the array. | |
158 | The array is retained by the iterator. | 169 | The array is retained by the iterator. | |
159 | An array iterator returns the object references stored in the array. | 170 | An array iterator returns the object references stored in the array. | |
160 | Storing to or removing from the array invalidates any active iterators for | 171 | Storing to or removing from the array invalidates any active iterators for | |
161 | the array. | 172 | the array. | |
173 | Returns | |||
174 | .Dv NULL | |||
175 | on failure. | |||
162 | .It Fn prop_array_make_immutable "prop_array_t array" | 176 | .It Fn prop_array_make_immutable "prop_array_t array" | |
163 | Make | 177 | Make | |
164 | .Fa array | 178 | .Fa array | |
165 | immutable. | 179 | immutable. | |
166 | .It Fn prop_array_mutable "prop_array_t array" | 180 | .It Fn prop_array_mutable "prop_array_t array" | |
167 | Returns | 181 | Returns | |
168 | .Dv true | 182 | .Dv true | |
169 | if the array is mutable. | 183 | if the array is mutable. | |
170 | .It Fn prop_array_get "prop_array_t array" "unsigned int index" | 184 | .It Fn prop_array_get "prop_array_t array" "unsigned int index" | |
171 | Return the object stored at the array index | 185 | Return the object stored at the array index | |
172 | .Fa index . | 186 | .Fa index . | |
187 | Returns | |||
188 | .Dv NULL | |||
189 | on failure. | |||
173 | .It Fn prop_array_set "prop_array_t array" "unsigned int index" \ | 190 | .It Fn prop_array_set "prop_array_t array" "unsigned int index" \ | |
174 | "prop_object_t obj" | 191 | "prop_object_t obj" | |
175 | Store a reference to the object | 192 | Store a reference to the object | |
176 | .Fa obj | 193 | .Fa obj | |
177 | at the array index | 194 | at the array index | |
178 | .Fa index . | 195 | .Fa index . | |
179 | This function is not allowed to create holes in the array; | 196 | This function is not allowed to create holes in the array; | |
180 | the caller must either be setting the object just beyond the existing | 197 | the caller must either be setting the object just beyond the existing | |
181 | count or replacing an already existing object reference. | 198 | count or replacing an already existing object reference. | |
182 | The object will be retained by the array. | 199 | The object will be retained by the array. | |
183 | If an existing object reference is being replaced, that object will be | 200 | If an existing object reference is being replaced, that object will be | |
184 | released. | 201 | released. | |
185 | Returns | 202 | Returns | |
@@ -188,35 +205,46 @@ if storing the object was successful and | @@ -188,35 +205,46 @@ if storing the object was successful and | |||
188 | .Dv false | 205 | .Dv false | |
189 | otherwise. | 206 | otherwise. | |
190 | .It Fn prop_array_add "prop_array_t array" "prop_object_t obj" | 207 | .It Fn prop_array_add "prop_array_t array" "prop_object_t obj" | |
191 | Add a reference to the object | 208 | Add a reference to the object | |
192 | .Fa obj | 209 | .Fa obj | |
193 | to the array, appending to the end and growing the array's capacity if | 210 | to the array, appending to the end and growing the array's capacity if | |
194 | necessary. | 211 | necessary. | |
195 | The object will be retained by the array. | 212 | The object will be retained by the array. | |
196 | Returns | 213 | Returns | |
197 | .Dv true | 214 | .Dv true | |
198 | if storing the object was successful and | 215 | if storing the object was successful and | |
199 | .Dv false | 216 | .Dv false | |
200 | otherwise. | 217 | otherwise. | |
218 | .Pp | |||
219 | During expansion, array's capacity is augmented by the | |||
220 | .Dv EXPAND_STEP | |||
221 | constant, as defined in | |||
222 | .Pa libprop/prop_array.c | |||
223 | file, e.g. | |||
224 | .Pp | |||
225 | #define EXPAND_STEP 16 | |||
201 | .It Fn prop_array_remove "prop_array_t array" "unsigned int index" | 226 | .It Fn prop_array_remove "prop_array_t array" "unsigned int index" | |
202 | Remove the reference to the object stored at array index | 227 | Remove the reference to the object stored at array index | |
203 | .Fa index . | 228 | .Fa index . | |
204 | The object will be released and the array compacted following | 229 | The object will be released and the array compacted following | |
205 | the removal. | 230 | the removal. | |
206 | .It Fn prop_array_equals "prop_array_t array1" "prop_array_t array2" | 231 | .It Fn prop_array_equals "prop_array_t array1" "prop_array_t array2" | |
207 | Returns | 232 | Returns | |
208 | .Dv true | 233 | .Dv true | |
209 | if the two arrays are equivalent. | 234 | if the two arrays are equivalent. | |
235 | If at least one of the supplied objects isn't an array, | |||
236 | .Dv false | |||
237 | is returned. | |||
210 | Note: Objects contained in the array are compared by value, not by reference. | 238 | Note: Objects contained in the array are compared by value, not by reference. | |
211 | .It Fn prop_array_externalize "prop_array_t array" | 239 | .It Fn prop_array_externalize "prop_array_t array" | |
212 | Externalizes an array, returning a NUL-terminated buffer containing | 240 | Externalizes an array, returning a NUL-terminated buffer containing | |
213 | the XML representation of the array. | 241 | the XML representation of the array. | |
214 | The caller is responsible for freeing the returned buffer. | 242 | The caller is responsible for freeing the returned buffer. | |
215 | If converting to the external representation fails for any reason, | 243 | If converting to the external representation fails for any reason, | |
216 | .Dv NULL | 244 | .Dv NULL | |
217 | is returned. | 245 | is returned. | |
218 | .Pp | 246 | .Pp | |
219 | In user space, the buffer is allocated using | 247 | In user space, the buffer is allocated using | |
220 | .Xr malloc 3 . | 248 | .Xr malloc 3 . | |
221 | In the kernel, the buffer is allocated using | 249 | In the kernel, the buffer is allocated using | |
222 | .Xr malloc 9 | 250 | .Xr malloc 9 | |
@@ -235,26 +263,29 @@ Externalizes an array and writes it to t | @@ -235,26 +263,29 @@ Externalizes an array and writes it to t | |||
235 | .Fa path . | 263 | .Fa path . | |
236 | The file is saved with the mode | 264 | The file is saved with the mode | |
237 | .Dv 0666 | 265 | .Dv 0666 | |
238 | as modified by the process's file creation mask | 266 | as modified by the process's file creation mask | |
239 | .Pq see Xr umask 3 | 267 | .Pq see Xr umask 3 | |
240 | and is written atomically. | 268 | and is written atomically. | |
241 | Returns | 269 | Returns | |
242 | .Dv false | 270 | .Dv false | |
243 | if externalizing or writing the array fails for any reason. | 271 | if externalizing or writing the array fails for any reason. | |
244 | .It Fn prop_array_internalize_from_file "const char *path" | 272 | .It Fn prop_array_internalize_from_file "const char *path" | |
245 | Reads the XML property list contained in the file specified by | 273 | Reads the XML property list contained in the file specified by | |
246 | .Fa path , | 274 | .Fa path , | |
247 | internalizes it, and returns the corresponding array. | 275 | internalizes it, and returns the corresponding array. | |
276 | Returns | |||
277 | .Dv NULL | |||
278 | on failure. | |||
248 | .El | 279 | .El | |
249 | .Sh SEE ALSO | 280 | .Sh SEE ALSO | |
250 | .Xr prop_bool 3 , | 281 | .Xr prop_bool 3 , | |
251 | .Xr prop_data 3 , | 282 | .Xr prop_data 3 , | |
252 | .Xr prop_dictionary 3 , | 283 | .Xr prop_dictionary 3 , | |
253 | .Xr prop_number 3 , | 284 | .Xr prop_number 3 , | |
254 | .Xr prop_object 3 , | 285 | .Xr prop_object 3 , | |
255 | .Xr prop_string 3 , | 286 | .Xr prop_string 3 , | |
256 | .Xr proplib 3 | 287 | .Xr proplib 3 | |
257 | .Sh HISTORY | 288 | .Sh HISTORY | |
258 | The | 289 | The | |
259 | .Nm proplib | 290 | .Nm proplib | |
260 | property container object library first appeared in | 291 | property container object library first appeared in |
--- src/common/lib/libprop/prop_bool.3 2007/08/16 16:30:59 1.3
+++ src/common/lib/libprop/prop_bool.3 2008/03/23 00:12:45 1.3.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_bool.3,v 1.3 2007/08/16 16:30:59 thorpej Exp $ | 1 | .\" prop_bool.3,v 1.3 2007/08/16 16:30:59 thorpej Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -55,28 +55,34 @@ | @@ -55,28 +55,34 @@ | |||
55 | .\" | 55 | .\" | |
56 | .Ft bool | 56 | .Ft bool | |
57 | .Fn prop_bool_true "prop_bool_t bool" | 57 | .Fn prop_bool_true "prop_bool_t bool" | |
58 | .Sh DESCRIPTION | 58 | .Sh DESCRIPTION | |
59 | The | 59 | The | |
60 | .Nm prop_bool | 60 | .Nm prop_bool | |
61 | family of functions operate on a boolean value property object type. | 61 | family of functions operate on a boolean value property object type. | |
62 | .Bl -tag -width "xxxxx" | 62 | .Bl -tag -width "xxxxx" | |
63 | .It Fn prop_bool_create "bool val" | 63 | .It Fn prop_bool_create "bool val" | |
64 | Create a boolean value object with the value | 64 | Create a boolean value object with the value | |
65 | .Fa val . | 65 | .Fa val . | |
66 | .It Fn prop_bool_copy "prop_bool_t bool" | 66 | .It Fn prop_bool_copy "prop_bool_t bool" | |
67 | Copy a boolean value object. | 67 | Copy a boolean value object. | |
68 | If the supplied object isn't a boolean, | |||
69 | .Dv NULL | |||
70 | is returned. | |||
68 | .It Fn prop_bool_true "prop_bool_t bool" | 71 | .It Fn prop_bool_true "prop_bool_t bool" | |
69 | Returns the value of the boolean value object. | 72 | Returns the value of the boolean value object. | |
73 | If the supplied object isn't a boolean, | |||
74 | .Dv false | |||
75 | is returned. | |||
70 | .El | 76 | .El | |
71 | .Sh SEE ALSO | 77 | .Sh SEE ALSO | |
72 | .Xr prop_array 3 , | 78 | .Xr prop_array 3 , | |
73 | .Xr prop_data 3 , | 79 | .Xr prop_data 3 , | |
74 | .Xr prop_dictionary 3 , | 80 | .Xr prop_dictionary 3 , | |
75 | .Xr prop_number 3 , | 81 | .Xr prop_number 3 , | |
76 | .Xr prop_object 3 , | 82 | .Xr prop_object 3 , | |
77 | .Xr prop_string 3 , | 83 | .Xr prop_string 3 , | |
78 | .Xr proplib 3 | 84 | .Xr proplib 3 | |
79 | .Sh HISTORY | 85 | .Sh HISTORY | |
80 | The | 86 | The | |
81 | .Nm proplib | 87 | .Nm proplib | |
82 | property container object library first appeared in | 88 | property container object library first appeared in |
--- src/common/lib/libprop/prop_ingest.3 2007/08/16 16:31:00 1.3
+++ src/common/lib/libprop/prop_ingest.3 2008/03/23 00:12:45 1.3.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_ingest.3,v 1.3 2007/08/16 16:31:00 thorpej Exp $ | 1 | .\" prop_ingest.3,v 1.3 2007/08/16 16:31:00 thorpej Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd August 19, 2006 | 37 | .Dd January 21, 2008 | |
38 | .Dt PROP_INGEST 3 | 38 | .Dt PROP_INGEST 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm prop_ingest_context_alloc , | 41 | .Nm prop_ingest_context_alloc , | |
42 | .Nm prop_ingest_context_free , | 42 | .Nm prop_ingest_context_free , | |
43 | .Nm prop_ingest_context_error , | 43 | .Nm prop_ingest_context_error , | |
44 | .Nm prop_ingest_context_type , | 44 | .Nm prop_ingest_context_type , | |
45 | .Nm prop_ingest_context_key , | 45 | .Nm prop_ingest_context_key , | |
46 | .Nm prop_ingest_context_private , | 46 | .Nm prop_ingest_context_private , | |
47 | .Nm prop_dictionary_ingest | 47 | .Nm prop_dictionary_ingest | |
48 | .Nd Ingest a dictionary into an arbitrary binary format | 48 | .Nd Ingest a dictionary into an arbitrary binary format | |
49 | .Sh SYNOPSIS | 49 | .Sh SYNOPSIS | |
50 | .In prop/proplib.h | 50 | .In prop/proplib.h | |
@@ -135,26 +135,29 @@ if the value of the object is invalid to | @@ -135,26 +135,29 @@ if the value of the object is invalid to | |||
135 | otherwise. | 135 | otherwise. | |
136 | .Pp | 136 | .Pp | |
137 | The ingest context contains several pieces of information that are | 137 | The ingest context contains several pieces of information that are | |
138 | useful during the ingest process. | 138 | useful during the ingest process. | |
139 | The context also provides specific error information should the ingest | 139 | The context also provides specific error information should the ingest | |
140 | fail. | 140 | fail. | |
141 | .Bl -tag -width "xxxxx" | 141 | .Bl -tag -width "xxxxx" | |
142 | .It Fn prop_ingest_context_alloc "void *private" | 142 | .It Fn prop_ingest_context_alloc "void *private" | |
143 | Allocate an ingest context. | 143 | Allocate an ingest context. | |
144 | The argument | 144 | The argument | |
145 | .Fa private | 145 | .Fa private | |
146 | may be used to pass application-specific context to the ingest handlers. | 146 | may be used to pass application-specific context to the ingest handlers. | |
147 | Note that an ingest context can be re-used to perform multiple ingests. | 147 | Note that an ingest context can be re-used to perform multiple ingests. | |
148 | Returns | |||
149 | .Dv NULL | |||
150 | on failure. | |||
148 | .It Fn prop_ingest_context_free "prop_ingest_context_t ctx" | 151 | .It Fn prop_ingest_context_free "prop_ingest_context_t ctx" | |
149 | Free an ingest context. | 152 | Free an ingest context. | |
150 | .It Fn prop_ingest_context_error "prop_ingest_context_t ctx" | 153 | .It Fn prop_ingest_context_error "prop_ingest_context_t ctx" | |
151 | Returns the code indicating the error encountered during ingest. | 154 | Returns the code indicating the error encountered during ingest. | |
152 | The following error codes are defined: | 155 | The following error codes are defined: | |
153 | .Pp | 156 | .Pp | |
154 | .Bl -tag -width "PROP_INGEST_ERROR_HANDLER_FAILED" -compact | 157 | .Bl -tag -width "PROP_INGEST_ERROR_HANDLER_FAILED" -compact | |
155 | .It Dv PROP_INGEST_ERROR_NO_ERROR | 158 | .It Dv PROP_INGEST_ERROR_NO_ERROR | |
156 | No error was encountered during ingest. | 159 | No error was encountered during ingest. | |
157 | .It Dv PROP_INGEST_ERROR_NO_KEY | 160 | .It Dv PROP_INGEST_ERROR_NO_KEY | |
158 | A non-optional key was not found in the dictionary. | 161 | A non-optional key was not found in the dictionary. | |
159 | .It Dv PROP_INGEST_ERROR_WRONG_TYPE | 162 | .It Dv PROP_INGEST_ERROR_WRONG_TYPE | |
160 | An object in the dictionary was not the same type specifed in the rules. | 163 | An object in the dictionary was not the same type specifed in the rules. |
--- src/common/lib/libprop/prop_copyin_ioctl.9 2007/04/22 11:23:29 1.2
+++ src/common/lib/libprop/prop_copyin_ioctl.9 2008/03/23 00:12:45 1.2.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_copyin_ioctl.9,v 1.2 2007/04/22 11:23:29 yamt Exp $ | 1 | .\" prop_copyin_ioctl.9,v 1.2 2007/04/22 11:23:29 yamt Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -58,32 +58,62 @@ | @@ -58,32 +58,62 @@ | |||
58 | .Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \ | 58 | .Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \ | |
59 | "const u_long cmd" "prop_dictionary_t dict" | 59 | "const u_long cmd" "prop_dictionary_t dict" | |
60 | .Sh DESCRIPTION | 60 | .Sh DESCRIPTION | |
61 | The | 61 | The | |
62 | .Nm prop_array_copyin_ioctl , | 62 | .Nm prop_array_copyin_ioctl , | |
63 | .Nm prop_array_copyout_ioctl , | 63 | .Nm prop_array_copyout_ioctl , | |
64 | .Nm prop_dictionary_copyin_ioctl , | 64 | .Nm prop_dictionary_copyin_ioctl , | |
65 | and | 65 | and | |
66 | .Nm prop_dictionary_copyout_ioctl | 66 | .Nm prop_dictionary_copyout_ioctl | |
67 | functions implement the kernel side of a protocol for sending property lists | 67 | functions implement the kernel side of a protocol for sending property lists | |
68 | to and from the kernel using | 68 | to and from the kernel using | |
69 | .Xr ioctl 2 . | 69 | .Xr ioctl 2 . | |
70 | .Pp | 70 | .Pp | |
71 | A kernel ioctl routine receivig or returning a property list will be passed a | 71 | A kernel ioctl routine receiving or returning a property list will be passed a | |
72 | pointer to a | 72 | pointer to a | |
73 | .Vt struct plistref . | 73 | .Vt struct plistref . | |
74 | This structure encapsulates the reference to the property list in externalized | 74 | This structure encapsulates the reference to the property list in externalized | |
75 | form. | 75 | form. | |
76 | .Sh RETURN VALUES | |||
77 | If successful, functions return zero. Otherwise, an error number will be returned to indicate the error. | |||
78 | .Sh ERRORS | |||
79 | .Fn prop_array_copyin_ioctl | |||
80 | and | |||
81 | .Fn prop_dictionary_copyin_ioctl | |||
82 | will fail if: | |||
83 | .Bl -tag -width Er | |||
84 | .It Bq Er EFAULT | |||
85 | Bad address | |||
86 | .It Bq Er EIO | |||
87 | Input/output error | |||
88 | .It Bq Er ENOMEM | |||
89 | Cannot allocate memory | |||
90 | .It Bq Er ENOTSUP | |||
91 | Not supported | |||
92 | .El | |||
76 | .Pp | 93 | .Pp | |
94 | .Fn prop_array_copyout_ioctl | |||
95 | and | |||
96 | .Fn prop_dictionary_copyout_ioctl | |||
97 | will fail if: | |||
98 | .Bl -tag -width Er | |||
99 | .It Bq Er EFAULT | |||
100 | Bad address | |||
101 | .It Bq Er ENOMEM | |||
102 | Cannot allocate memory | |||
103 | .It Bq Er ENOTSUP | |||
104 | Not supported | |||
105 | .El | |||
106 | .Sh EXAMPLES | |||
77 | The following | 107 | The following | |
78 | .Pq simplified | 108 | .Pq simplified | |
79 | example demonstrates using | 109 | example demonstrates using | |
80 | .Fn prop_dictionary_copyin_ioctl | 110 | .Fn prop_dictionary_copyin_ioctl | |
81 | and | 111 | and | |
82 | .Fn prop_dictionary_copyout_ioctl | 112 | .Fn prop_dictionary_copyout_ioctl | |
83 | in an ioctl routine: | 113 | in an ioctl routine: | |
84 | .Bd -literal | 114 | .Bd -literal | |
85 | extern prop_dictionary_t fooprops; | 115 | extern prop_dictionary_t fooprops; | |
86 | 116 | |||
87 | int | 117 | int | |
88 | fooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) | 118 | fooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) | |
89 | { | 119 | { |
--- src/common/lib/libprop/prop_data.3 2007/08/16 16:31:00 1.4
+++ src/common/lib/libprop/prop_data.3 2008/03/23 00:12:45 1.4.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_data.3,v 1.4 2007/08/16 16:31:00 thorpej Exp $ | 1 | .\" prop_data.3,v 1.4 2007/08/16 16:31:00 thorpej Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -72,60 +72,83 @@ | @@ -72,60 +72,83 @@ | |||
72 | .Fn prop_data_equals "prop_data_t dat1" "prop_data_t dat2" | 72 | .Fn prop_data_equals "prop_data_t dat1" "prop_data_t dat2" | |
73 | .Ft bool | 73 | .Ft bool | |
74 | .Fn prop_data_equals_data "prop_data_t data" "const void *blob" "size_t len" | 74 | .Fn prop_data_equals_data "prop_data_t data" "const void *blob" "size_t len" | |
75 | .Sh DESCRIPTION | 75 | .Sh DESCRIPTION | |
76 | The | 76 | The | |
77 | .Nm prop_data | 77 | .Nm prop_data | |
78 | family of functions operate on an opaque data value property object type. | 78 | family of functions operate on an opaque data value property object type. | |
79 | .Bl -tag -width "xxxxx" | 79 | .Bl -tag -width "xxxxx" | |
80 | .It Fn prop_data_create_data "const void *blob" "size_t len" | 80 | .It Fn prop_data_create_data "const void *blob" "size_t len" | |
81 | Create a data object that contains a copy of | 81 | Create a data object that contains a copy of | |
82 | .Fa blob | 82 | .Fa blob | |
83 | with size | 83 | with size | |
84 | .Fa len . | 84 | .Fa len . | |
85 | Returns | |||
86 | .Dv NULL | |||
87 | on failure. | |||
85 | .It Fn prop_data_create_data_nocopy "const void *blob" "size_t len" | 88 | .It Fn prop_data_create_data_nocopy "const void *blob" "size_t len" | |
86 | Create a data object that contains a reference to | 89 | Create a data object that contains a reference to | |
87 | .Fa blob | 90 | .Fa blob | |
88 | with size | 91 | with size | |
89 | .Fa len . | 92 | .Fa len . | |
93 | Returns | |||
94 | .Dv NULL | |||
95 | on failure. | |||
90 | .It Fn prop_data_copy "prop_data_t data" | 96 | .It Fn prop_data_copy "prop_data_t data" | |
91 | Copy a data object. | 97 | Copy a data object. | |
92 | If the the data object being copied is an external data reference, | 98 | If the data object being copied is an external data reference, | |
93 | then the copy also references the same external data. | 99 | then the copy also references the same external data. | |
100 | Returns | |||
101 | .Dv NULL | |||
102 | on failure. | |||
94 | .It Fn prop_data_size "prop_data_t data" | 103 | .It Fn prop_data_size "prop_data_t data" | |
95 | Returns the size of the data object. | 104 | Returns the size of the data object. | |
105 | If the supplied object isn't a data object, zero is returned. | |||
96 | .It Fn prop_data_data "prop_data_t data" | 106 | .It Fn prop_data_data "prop_data_t data" | |
97 | Returns a copy of the data object's contents. | 107 | Returns a copy of the data object's contents. | |
98 | The caller is responsible for freeing the returned buffer. | 108 | The caller is responsible for freeing the returned buffer. | |
109 | If the supplied object isn't a data object or | |||
110 | if the data container is empty, | |||
111 | .Dv NULL | |||
112 | is returned. | |||
99 | .Pp | 113 | .Pp | |
100 | In user space, the buffer is allocated using | 114 | In user space, the buffer is allocated using | |
101 | .Xr malloc 3 . | 115 | .Xr malloc 3 . | |
102 | In the kernel, the buffer is allocated using | 116 | In the kernel, the buffer is allocated using | |
103 | .Xr malloc 9 | 117 | .Xr malloc 9 | |
104 | using the malloc type | 118 | using the malloc type | |
105 | .Dv M_TEMP . | 119 | .Dv M_TEMP . | |
106 | .It Fn prop_data_data_nocopy "prop_data_t data" | 120 | .It Fn prop_data_data_nocopy "prop_data_t data" | |
107 | Returns an immutable reference to the contents of the data object. | 121 | Returns an immutable reference to the contents of the data object. | |
122 | If the supplied object isn't a data object, | |||
123 | .Dv NULL | |||
124 | is returned. | |||
108 | .It Fn prop_data_equals "prop_data_t dat1" "prop_data_t dat2" | 125 | .It Fn prop_data_equals "prop_data_t dat1" "prop_data_t dat2" | |
109 | Returns | 126 | Returns | |
110 | .Dv true | 127 | .Dv true | |
111 | if the two data objects are equivalent. | 128 | if the two data objects are equivalent. | |
129 | If at least one of the supplied objects isn't a data object, | |||
130 | .Dv false | |||
131 | is returned. | |||
112 | .It Fn prop_data_equals_data "prop_data_t data" "const void *blob" "size_t len" | 132 | .It Fn prop_data_equals_data "prop_data_t data" "const void *blob" "size_t len" | |
113 | Returns | 133 | Returns | |
114 | .Dv true | 134 | .Dv true | |
115 | if the data object's value is equivalent to | 135 | if the data object's value is equivalent to | |
116 | .Fa blob | 136 | .Fa blob | |
117 | with size | 137 | with size | |
118 | .Fa len . | 138 | .Fa len . | |
139 | If the supplied object isn't a data object, | |||
140 | .Dv false | |||
141 | is returned. | |||
119 | .El | 142 | .El | |
120 | .Sh SEE ALSO | 143 | .Sh SEE ALSO | |
121 | .Xr prop_array 3 , | 144 | .Xr prop_array 3 , | |
122 | .Xr prop_bool 3 , | 145 | .Xr prop_bool 3 , | |
123 | .Xr prop_dictionary 3 , | 146 | .Xr prop_dictionary 3 , | |
124 | .Xr prop_number 3 , | 147 | .Xr prop_number 3 , | |
125 | .Xr prop_object 3 , | 148 | .Xr prop_object 3 , | |
126 | .Xr prop_string 3 , | 149 | .Xr prop_string 3 , | |
127 | .Xr proplib 3 | 150 | .Xr proplib 3 | |
128 | .Sh HISTORY | 151 | .Sh HISTORY | |
129 | The | 152 | The | |
130 | .Nm proplib | 153 | .Nm proplib | |
131 | property container object library first appeared in | 154 | property container object library first appeared in |
--- src/common/lib/libprop/prop_string.3 2007/08/16 16:31:00 1.4
+++ src/common/lib/libprop/prop_string.3 2008/03/23 00:12:45 1.4.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_string.3,v 1.4 2007/08/16 16:31:00 thorpej Exp $ | 1 | .\" prop_string.3,v 1.4 2007/08/16 16:31:00 thorpej Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd April 22, 2006 | 37 | .Dd January 21, 2008 | |
38 | .Dt PROP_STRING 3 | 38 | .Dt PROP_STRING 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm prop_string , | 41 | .Nm prop_string , | |
42 | .Nm prop_string_create , | 42 | .Nm prop_string_create , | |
43 | .Nm prop_string_create_cstring , | 43 | .Nm prop_string_create_cstring , | |
44 | .Nm prop_string_create_cstring_nocopy , | 44 | .Nm prop_string_create_cstring_nocopy , | |
45 | .Nm prop_string_copy , | 45 | .Nm prop_string_copy , | |
46 | .Nm prop_string_copy_mutable , | 46 | .Nm prop_string_copy_mutable , | |
47 | .Nm prop_string_size , | 47 | .Nm prop_string_size , | |
48 | .Nm prop_string_mutable , | 48 | .Nm prop_string_mutable , | |
49 | .Nm prop_string_cstring , | 49 | .Nm prop_string_cstring , | |
50 | .Nm prop_string_cstring_nocopy , | 50 | .Nm prop_string_cstring_nocopy , | |
@@ -81,57 +81,83 @@ | @@ -81,57 +81,83 @@ | |||
81 | .Fn prop_string_append_cstring "prop_string_t string" "const char *cstring" | 81 | .Fn prop_string_append_cstring "prop_string_t string" "const char *cstring" | |
82 | .\" | 82 | .\" | |
83 | .Ft bool | 83 | .Ft bool | |
84 | .Fn prop_string_equals "prop_string_t str1" "prop_string_t str2" | 84 | .Fn prop_string_equals "prop_string_t str1" "prop_string_t str2" | |
85 | .Ft bool | 85 | .Ft bool | |
86 | .Fn prop_string_equals_cstring "prop_string_t string" "const char *cstring" | 86 | .Fn prop_string_equals_cstring "prop_string_t string" "const char *cstring" | |
87 | .Sh DESCRIPTION | 87 | .Sh DESCRIPTION | |
88 | The | 88 | The | |
89 | .Nm prop_string | 89 | .Nm prop_string | |
90 | family of functions operate on a string value property object type. | 90 | family of functions operate on a string value property object type. | |
91 | .Bl -tag -width "xxxxx" | 91 | .Bl -tag -width "xxxxx" | |
92 | .It Fn prop_string_create "void" | 92 | .It Fn prop_string_create "void" | |
93 | Create an empty mutable string. | 93 | Create an empty mutable string. | |
94 | Returns | |||
95 | .Dv NULL | |||
96 | on failure. | |||
94 | .It Fn prop_string_create_cstring "const char *cstring" | 97 | .It Fn prop_string_create_cstring "const char *cstring" | |
95 | Create a mutable string that contains a copy of | 98 | Create a mutable string that contains a copy of | |
96 | .Fa cstring . | 99 | .Fa cstring . | |
100 | Returns | |||
101 | .Dv NULL | |||
102 | on failure. | |||
97 | .It Fn prop_string_create_cstring_nocopy "const char *cstring" | 103 | .It Fn prop_string_create_cstring_nocopy "const char *cstring" | |
98 | Create an immutable string that contains a reference to | 104 | Create an immutable string that contains a reference to | |
99 | .Fa cstring . | 105 | .Fa cstring . | |
106 | Returns | |||
107 | .Dv NULL | |||
108 | on failure. | |||
100 | .It Fn prop_string_copy "prop_string_t string" | 109 | .It Fn prop_string_copy "prop_string_t string" | |
101 | Copy a string. | 110 | Copy a string. | |
102 | If the the string being copied is an immutable external C string reference, | 111 | If the the string being copied is an immutable external C string reference, | |
103 | then the copy is also immutable and references the same external C string. | 112 | then the copy is also immutable and references the same external C string. | |
113 | Returns | |||
114 | .Dv NULL | |||
115 | on failure. | |||
104 | .It Fn prop_string_copy_mutable "prop_string_t string" | 116 | .It Fn prop_string_copy_mutable "prop_string_t string" | |
105 | Copy a string, always creating a mutable copy. | 117 | Copy a string, always creating a mutable copy. | |
118 | Returns | |||
119 | .Dv NULL | |||
120 | on failure. | |||
106 | .It Fn prop_string_size "prop_string_t string" | 121 | .It Fn prop_string_size "prop_string_t string" | |
107 | Returns the size of the string, not including the terminating NUL. | 122 | Returns the size of the string, not including the terminating NUL. | |
123 | If the supplied object isn't a string, zero is returned. | |||
108 | .It Fn prop_string_mutable "prop_string_t string" | 124 | .It Fn prop_string_mutable "prop_string_t string" | |
109 | Returns | 125 | Returns | |
110 | .Dv true | 126 | .Dv true | |
111 | if the string is mutable. | 127 | if the string is mutable. | |
128 | If the supplied object isn't a string, | |||
129 | .Dv false | |||
130 | is returned. | |||
112 | .It Fn prop_string_cstring "prop_string_t string" | 131 | .It Fn prop_string_cstring "prop_string_t string" | |
113 | Returns a copy of the string's contents as a C string. | 132 | Returns a copy of the string's contents as a C string. | |
114 | The caller is responsible for freeing the returned buffer. | 133 | The caller is responsible for freeing the returned buffer. | |
115 | .Pp | 134 | .Pp | |
116 | In user space, the buffer is allocated using | 135 | In user space, the buffer is allocated using | |
117 | .Xr malloc 3 . | 136 | .Xr malloc 3 . | |
118 | In the kernel, the buffer is allocated using | 137 | In the kernel, the buffer is allocated using | |
119 | .Xr malloc 9 | 138 | .Xr malloc 9 | |
120 | using the malloc type | 139 | using the malloc type | |
121 | .Dv M_TEMP . | 140 | .Dv M_TEMP . | |
141 | .Pp | |||
142 | Returns | |||
143 | .Dv NULL | |||
144 | on failure. | |||
122 | .It Fn prop_string_cstring_nocopy "prop_string_t string" | 145 | .It Fn prop_string_cstring_nocopy "prop_string_t string" | |
123 | Returns an immutable reference to the contents of the string as a | 146 | Returns an immutable reference to the contents of the string as a | |
124 | C string. | 147 | C string. | |
148 | If the supplied object isn't a string, | |||
149 | .Dv NULL | |||
150 | is returned. | |||
125 | .It Fn prop_string_append "prop_string_t str1" "prop_string_t str2" | 151 | .It Fn prop_string_append "prop_string_t str1" "prop_string_t str2" | |
126 | Append the contents of | 152 | Append the contents of | |
127 | .Fa str2 | 153 | .Fa str2 | |
128 | to | 154 | to | |
129 | .Fa str1 , | 155 | .Fa str1 , | |
130 | which must be mutable. | 156 | which must be mutable. | |
131 | Returns | 157 | Returns | |
132 | .Dv true | 158 | .Dv true | |
133 | upon success and | 159 | upon success and | |
134 | .Dv false | 160 | .Dv false | |
135 | otherwise. | 161 | otherwise. | |
136 | .It Fn prop_string_append_cstring "prop_string_t string" "const char *cstring" | 162 | .It Fn prop_string_append_cstring "prop_string_t string" "const char *cstring" | |
137 | Append the C string | 163 | Append the C string |
--- src/common/lib/libprop/prop_data.c 2007/11/06 23:07:24 1.8.2.1
+++ src/common/lib/libprop/prop_data.c 2008/03/23 00:12:45 1.8.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prop_data.c,v 1.8.2.1 2007/11/06 23:07:24 matt Exp $ */ | 1 | /* prop_data.c,v 1.8.2.1 2007/11/06 23:07:24 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -118,54 +118,54 @@ _prop_data_externalize(struct _prop_obje | @@ -118,54 +118,54 @@ _prop_data_externalize(struct _prop_obje | |||
118 | 118 | |||
119 | if (_prop_object_externalize_start_tag(ctx, "data") == false) | 119 | if (_prop_object_externalize_start_tag(ctx, "data") == false) | |
120 | return (false); | 120 | return (false); | |
121 | 121 | |||
122 | for (src = pd->pd_immutable, srclen = pd->pd_size; | 122 | for (src = pd->pd_immutable, srclen = pd->pd_size; | |
123 | srclen > 2; srclen -= 3) { | 123 | srclen > 2; srclen -= 3) { | |
124 | input[0] = *src++; | 124 | input[0] = *src++; | |
125 | input[1] = *src++; | 125 | input[1] = *src++; | |
126 | input[2] = *src++; | 126 | input[2] = *src++; | |
127 | 127 | |||
128 | output[0] = (uint32_t)input[0] >> 2; | 128 | output[0] = (uint32_t)input[0] >> 2; | |
129 | output[1] = ((uint32_t)(input[0] & 0x03) << 4) + | 129 | output[1] = ((uint32_t)(input[0] & 0x03) << 4) + | |
130 | ((uint32_t)input[1] >> 4); | 130 | ((uint32_t)input[1] >> 4); | |
131 | output[2] = ((u_int32_t)(input[1] & 0x0f) << 2) + | 131 | output[2] = ((uint32_t)(input[1] & 0x0f) << 2) + | |
132 | ((uint32_t)input[2] >> 6); | 132 | ((uint32_t)input[2] >> 6); | |
133 | output[3] = input[2] & 0x3f; | 133 | output[3] = input[2] & 0x3f; | |
134 | _PROP_ASSERT(output[0] < 64); | 134 | _PROP_ASSERT(output[0] < 64); | |
135 | _PROP_ASSERT(output[1] < 64); | 135 | _PROP_ASSERT(output[1] < 64); | |
136 | _PROP_ASSERT(output[2] < 64); | 136 | _PROP_ASSERT(output[2] < 64); | |
137 | _PROP_ASSERT(output[3] < 64); | 137 | _PROP_ASSERT(output[3] < 64); | |
138 | 138 | |||
139 | if (_prop_object_externalize_append_char(ctx, | 139 | if (_prop_object_externalize_append_char(ctx, | |
140 | _prop_data_base64[output[0]]) == false || | 140 | _prop_data_base64[output[0]]) == false || | |
141 | _prop_object_externalize_append_char(ctx, | 141 | _prop_object_externalize_append_char(ctx, | |
142 | _prop_data_base64[output[1]]) == false || | 142 | _prop_data_base64[output[1]]) == false || | |
143 | _prop_object_externalize_append_char(ctx, | 143 | _prop_object_externalize_append_char(ctx, | |
144 | _prop_data_base64[output[2]]) == false || | 144 | _prop_data_base64[output[2]]) == false || | |
145 | _prop_object_externalize_append_char(ctx, | 145 | _prop_object_externalize_append_char(ctx, | |
146 | _prop_data_base64[output[3]]) == false) | 146 | _prop_data_base64[output[3]]) == false) | |
147 | return (false); | 147 | return (false); | |
148 | } | 148 | } | |
149 | 149 | |||
150 | if (srclen != 0) { | 150 | if (srclen != 0) { | |
151 | input[0] = input[1] = input[2] = '\0'; | 151 | input[0] = input[1] = input[2] = '\0'; | |
152 | for (i = 0; i < srclen; i++) | 152 | for (i = 0; i < srclen; i++) | |
153 | input[i] = *src++; | 153 | input[i] = *src++; | |
154 | 154 | |||
155 | output[0] = (uint32_t)input[0] >> 2; | 155 | output[0] = (uint32_t)input[0] >> 2; | |
156 | output[1] = ((uint32_t)(input[0] & 0x03) << 4) + | 156 | output[1] = ((uint32_t)(input[0] & 0x03) << 4) + | |
157 | ((uint32_t)input[1] >> 4); | 157 | ((uint32_t)input[1] >> 4); | |
158 | output[2] = ((u_int32_t)(input[1] & 0x0f) << 2) + | 158 | output[2] = ((uint32_t)(input[1] & 0x0f) << 2) + | |
159 | ((uint32_t)input[2] >> 6); | 159 | ((uint32_t)input[2] >> 6); | |
160 | _PROP_ASSERT(output[0] < 64); | 160 | _PROP_ASSERT(output[0] < 64); | |
161 | _PROP_ASSERT(output[1] < 64); | 161 | _PROP_ASSERT(output[1] < 64); | |
162 | _PROP_ASSERT(output[2] < 64); | 162 | _PROP_ASSERT(output[2] < 64); | |
163 | 163 | |||
164 | if (_prop_object_externalize_append_char(ctx, | 164 | if (_prop_object_externalize_append_char(ctx, | |
165 | _prop_data_base64[output[0]]) == false || | 165 | _prop_data_base64[output[0]]) == false || | |
166 | _prop_object_externalize_append_char(ctx, | 166 | _prop_object_externalize_append_char(ctx, | |
167 | _prop_data_base64[output[1]]) == false || | 167 | _prop_data_base64[output[1]]) == false || | |
168 | _prop_object_externalize_append_char(ctx, | 168 | _prop_object_externalize_append_char(ctx, | |
169 | srclen == 1 ? _prop_data_pad64 | 169 | srclen == 1 ? _prop_data_pad64 | |
170 | : _prop_data_base64[output[2]]) == false || | 170 | : _prop_data_base64[output[2]]) == false || | |
171 | _prop_object_externalize_append_char(ctx, | 171 | _prop_object_externalize_append_char(ctx, |
--- src/common/lib/libprop/prop_dictionary.3 2008/01/09 01:21:35 1.8.2.2
+++ src/common/lib/libprop/prop_dictionary.3 2008/03/23 00:12:45 1.8.2.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_dictionary.3,v 1.8.2.2 2008/01/09 01:21:35 matt Exp $ | 1 | .\" prop_dictionary.3,v 1.8.2.2 2008/01/09 01:21:35 matt Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd January 4, 2008 | 37 | .Dd January 21, 2008 | |
38 | .Dt PROP_DICTIONARY 3 | 38 | .Dt PROP_DICTIONARY 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm prop_dictionary , | 41 | .Nm prop_dictionary , | |
42 | .Nm prop_dictionary_create , | 42 | .Nm prop_dictionary_create , | |
43 | .Nm prop_dictionary_create_with_capacity , | 43 | .Nm prop_dictionary_create_with_capacity , | |
44 | .Nm prop_dictionary_copy , | 44 | .Nm prop_dictionary_copy , | |
45 | .Nm prop_dictionary_copy_mutable , | 45 | .Nm prop_dictionary_copy_mutable , | |
46 | .Nm prop_dictionary_count , | 46 | .Nm prop_dictionary_count , | |
47 | .Nm prop_dictionary_ensure_capacity , | 47 | .Nm prop_dictionary_ensure_capacity , | |
48 | .Nm prop_dictionary_iterator , | 48 | .Nm prop_dictionary_iterator , | |
49 | .Nm prop_dictionary_all_keys , | 49 | .Nm prop_dictionary_all_keys , | |
50 | .Nm prop_dictionary_make_immutable , | 50 | .Nm prop_dictionary_make_immutable , | |
@@ -132,30 +132,36 @@ | @@ -132,30 +132,36 @@ | |||
132 | "const char *path" | 132 | "const char *path" | |
133 | .Ft prop_dictionary_t | 133 | .Ft prop_dictionary_t | |
134 | .Fn prop_dictionary_internalize_from_file "const char *path" | 134 | .Fn prop_dictionary_internalize_from_file "const char *path" | |
135 | .\" | 135 | .\" | |
136 | .Sh DESCRIPTION | 136 | .Sh DESCRIPTION | |
137 | The | 137 | The | |
138 | .Nm prop_dictionary | 138 | .Nm prop_dictionary | |
139 | family of functions operate on the dictionary property collection object type. | 139 | family of functions operate on the dictionary property collection object type. | |
140 | A dictionary is an unordered set of objects stored as key-value pairs. | 140 | A dictionary is an unordered set of objects stored as key-value pairs. | |
141 | .Bl -tag -width "xxxxx" | 141 | .Bl -tag -width "xxxxx" | |
142 | .It Fn prop_dictionary_create "void" | 142 | .It Fn prop_dictionary_create "void" | |
143 | Create an empty dictionary. | 143 | Create an empty dictionary. | |
144 | The dictionary initially has no capacity. | 144 | The dictionary initially has no capacity. | |
145 | Returns | |||
146 | .Dv NULL | |||
147 | on failure. | |||
145 | .It Fn prop_dictionary_create_with_capacity "unsigned int capacity" | 148 | .It Fn prop_dictionary_create_with_capacity "unsigned int capacity" | |
146 | Create a dictionary with the capacity to store | 149 | Create a dictionary with the capacity to store | |
147 | .Fa capacity | 150 | .Fa capacity | |
148 | objects. | 151 | objects. | |
152 | Returns | |||
153 | .Dv NULL | |||
154 | on failure. | |||
149 | .It Fn prop_dictionary_copy "prop_dictionary_t dict" | 155 | .It Fn prop_dictionary_copy "prop_dictionary_t dict" | |
150 | Copy a dictionary. | 156 | Copy a dictionary. | |
151 | The new dictionary has an initial capacity equal to the number of objects | 157 | The new dictionary has an initial capacity equal to the number of objects | |
152 | stored in the dictionary being copied. | 158 | stored in the dictionary being copied. | |
153 | The new dictionary contains references to the original dictionary's objects, | 159 | The new dictionary contains references to the original dictionary's objects, | |
154 | not copies of those objects | 160 | not copies of those objects | |
155 | .Pq i.e. a shallow copy is made . | 161 | .Pq i.e. a shallow copy is made . | |
156 | If the original dictionary is immutable, the resulting dictionary is also | 162 | If the original dictionary is immutable, the resulting dictionary is also | |
157 | immutable. | 163 | immutable. | |
158 | .It Fn prop_dictionary_copy_mutable "prop_dictionary_t dict" | 164 | .It Fn prop_dictionary_copy_mutable "prop_dictionary_t dict" | |
159 | Like | 165 | Like | |
160 | .Fn prop_dictionary_copy , | 166 | .Fn prop_dictionary_copy , | |
161 | except the resulting dictionary is always mutable. | 167 | except the resulting dictionary is always mutable. | |
@@ -163,42 +169,51 @@ except the resulting dictionary is alway | @@ -163,42 +169,51 @@ except the resulting dictionary is alway | |||
163 | Returns the number of objects stored in the dictionary. | 169 | Returns the number of objects stored in the dictionary. | |
164 | .It Fn prop_dictionary_ensure_capacity "prop_dictionary_t dict" | 170 | .It Fn prop_dictionary_ensure_capacity "prop_dictionary_t dict" | |
165 | Ensure that the dictionary has a total capacity of | 171 | Ensure that the dictionary has a total capacity of | |
166 | .Fa capacity , | 172 | .Fa capacity , | |
167 | including objects already stored in the dictionary. | 173 | including objects already stored in the dictionary. | |
168 | Returns | 174 | Returns | |
169 | .Dv true | 175 | .Dv true | |
170 | if the capacity of the dictionary is greater or equal to | 176 | if the capacity of the dictionary is greater or equal to | |
171 | .Fa capacity | 177 | .Fa capacity | |
172 | or if the expansion of the dictionary's capacity was successful | 178 | or if the expansion of the dictionary's capacity was successful | |
173 | and | 179 | and | |
174 | .Dv false | 180 | .Dv false | |
175 | otherwise. | 181 | otherwise. | |
182 | If the supplied object isn't a dictionary, | |||
183 | .Dv false | |||
184 | is returned. | |||
176 | .It Fn prop_dictionary_iterator "prop_dictionary_t dict" | 185 | .It Fn prop_dictionary_iterator "prop_dictionary_t dict" | |
177 | Create an iterator for the dictionary. | 186 | Create an iterator for the dictionary. | |
178 | The dictionary is retained by the iterator. | 187 | The dictionary is retained by the iterator. | |
179 | A dictionary iterator returns the key symbols used to look up objects stored | 188 | A dictionary iterator returns the key symbols used to look up objects stored | |
180 | in the dictionary; to get the object itself, a dictionary lookup using this | 189 | in the dictionary; to get the object itself, a dictionary lookup using this | |
181 | key symbol must be performed. | 190 | key symbol must be performed. | |
182 | Storing to or removing from the dictionary invalidates any active iterators for | 191 | Storing to or removing from the dictionary invalidates any active iterators for | |
183 | the dictionary. | 192 | the dictionary. | |
193 | Returns | |||
194 | .Dv NULL | |||
195 | on failure. | |||
184 | .It Fn prop_dictionary_all_keys "prop_dictionary_t dict" | 196 | .It Fn prop_dictionary_all_keys "prop_dictionary_t dict" | |
185 | Return an array of all of the dictionary key symbols | 197 | Return an array of all of the dictionary key symbols | |
186 | .Pq prop_dictionary_keysym_t | 198 | .Pq prop_dictionary_keysym_t | |
187 | in the dictionary. | 199 | in the dictionary. | |
188 | This provides a way to iterate over the items in the dictionary while | 200 | This provides a way to iterate over the items in the dictionary while | |
189 | retaining the ability to mutate the dictionary; instead of iterating | 201 | retaining the ability to mutate the dictionary; instead of iterating | |
190 | over the dictionary itself, iterate over the array of keys. | 202 | over the dictionary itself, iterate over the array of keys. | |
191 | The caller is responsible for releasing the array. | 203 | The caller is responsible for releasing the array. | |
204 | Returns | |||
205 | .Dv NULL | |||
206 | on failure. | |||
192 | .It Fn prop_dictionary_make_immutable "prop_dictionary_t dict" | 207 | .It Fn prop_dictionary_make_immutable "prop_dictionary_t dict" | |
193 | Make | 208 | Make | |
194 | .Fa dict | 209 | .Fa dict | |
195 | immutable. | 210 | immutable. | |
196 | .It Fn prop_dictionary_mutable "prop_dictionary_t dict" | 211 | .It Fn prop_dictionary_mutable "prop_dictionary_t dict" | |
197 | Returns | 212 | Returns | |
198 | .Dv true | 213 | .Dv true | |
199 | if the dictionary is mutable. | 214 | if the dictionary is mutable. | |
200 | .It Fn prop_dictionary_get "prop_dictionary_t dict" "const char *key" | 215 | .It Fn prop_dictionary_get "prop_dictionary_t dict" "const char *key" | |
201 | Return the object stored in the dictionary with the key | 216 | Return the object stored in the dictionary with the key | |
202 | .Fa key . | 217 | .Fa key . | |
203 | If no object is stored with the specified key, | 218 | If no object is stored with the specified key, | |
204 | .Dv NULL | 219 | .Dv NULL | |
@@ -290,26 +305,29 @@ Externalizes a dictionary and writes it | @@ -290,26 +305,29 @@ Externalizes a dictionary and writes it | |||
290 | .Fa path . | 305 | .Fa path . | |
291 | The file is saved with the mode | 306 | The file is saved with the mode | |
292 | .Dv 0666 | 307 | .Dv 0666 | |
293 | as modified by the process's file creation mask | 308 | as modified by the process's file creation mask | |
294 | .Pq see Xr umask 3 | 309 | .Pq see Xr umask 3 | |
295 | and is written atomically. | 310 | and is written atomically. | |
296 | Returns | 311 | Returns | |
297 | .Dv false | 312 | .Dv false | |
298 | if externalizing or writing the dictionary fails for any reason. | 313 | if externalizing or writing the dictionary fails for any reason. | |
299 | .It Fn prop_dictionary_internalize_from_file "const char *path" | 314 | .It Fn prop_dictionary_internalize_from_file "const char *path" | |
300 | Reads the XML property list contained in the file specified by | 315 | Reads the XML property list contained in the file specified by | |
301 | .Fa path , | 316 | .Fa path , | |
302 | internalizes it, and returns the corresponding array. | 317 | internalizes it, and returns the corresponding array. | |
318 | Returns | |||
319 | .Dv NULL | |||
320 | on failure. | |||
303 | .El | 321 | .El | |
304 | .Sh SEE ALSO | 322 | .Sh SEE ALSO | |
305 | .Xr prop_array 3 , | 323 | .Xr prop_array 3 , | |
306 | .Xr prop_bool 3 , | 324 | .Xr prop_bool 3 , | |
307 | .Xr prop_data 3 , | 325 | .Xr prop_data 3 , | |
308 | .Xr prop_number 3 , | 326 | .Xr prop_number 3 , | |
309 | .Xr prop_object 3 , | 327 | .Xr prop_object 3 , | |
310 | .Xr prop_string 3 , | 328 | .Xr prop_string 3 , | |
311 | .Xr proplib 3 | 329 | .Xr proplib 3 | |
312 | .Sh HISTORY | 330 | .Sh HISTORY | |
313 | The | 331 | The | |
314 | .Nm proplib | 332 | .Nm proplib | |
315 | property container object library first appeared in | 333 | property container object library first appeared in |
--- src/common/lib/libprop/prop_dictionary.c 2007/11/06 23:07:25 1.19.2.1
+++ src/common/lib/libprop/prop_dictionary.c 2008/03/23 00:12:45 1.19.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prop_dictionary.c,v 1.19.2.1 2007/11/06 23:07:25 matt Exp $ */ | 1 | /* prop_dictionary.c,v 1.19.2.1 2007/11/06 23:07:25 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -686,26 +686,40 @@ prop_dictionary_copy_mutable(prop_dictio | @@ -686,26 +686,40 @@ prop_dictionary_copy_mutable(prop_dictio | |||
686 | prop_dictionary_t pd; | 686 | prop_dictionary_t pd; | |
687 | 687 | |||
688 | if (! prop_object_is_dictionary(opd)) | 688 | if (! prop_object_is_dictionary(opd)) | |
689 | return (NULL); | 689 | return (NULL); | |
690 | 690 | |||
691 | pd = prop_dictionary_copy(opd); | 691 | pd = prop_dictionary_copy(opd); | |
692 | if (pd != NULL) | 692 | if (pd != NULL) | |
693 | pd->pd_flags &= ~PD_F_IMMUTABLE; | 693 | pd->pd_flags &= ~PD_F_IMMUTABLE; | |
694 | 694 | |||
695 | return (pd); | 695 | return (pd); | |
696 | } | 696 | } | |
697 | 697 | |||
698 | /* | 698 | /* | |
699 | * prop_dictionary_make_immutable -- | |||
700 | * Set the immutable flag on that dictionary. | |||
701 | */ | |||
702 | void | |||
703 | prop_dictionary_make_immutable(prop_dictionary_t pd) | |||
704 | { | |||
705 | ||||
706 | _PROP_RWLOCK_WRLOCK(pd->pd_rwlock); | |||
707 | if (prop_dictionary_is_immutable(pd) == false) | |||
708 | pd->pd_flags |= PD_F_IMMUTABLE; | |||
709 | _PROP_RWLOCK_UNLOCK(pd->pd_rwlock); | |||
710 | } | |||
711 | ||||
712 | /* | |||
699 | * prop_dictionary_count -- | 713 | * prop_dictionary_count -- | |
700 | * Return the number of objects stored in the dictionary. | 714 | * Return the number of objects stored in the dictionary. | |
701 | */ | 715 | */ | |
702 | unsigned int | 716 | unsigned int | |
703 | prop_dictionary_count(prop_dictionary_t pd) | 717 | prop_dictionary_count(prop_dictionary_t pd) | |
704 | { | 718 | { | |
705 | unsigned int rv; | 719 | unsigned int rv; | |
706 | 720 | |||
707 | if (! prop_object_is_dictionary(pd)) | 721 | if (! prop_object_is_dictionary(pd)) | |
708 | return (0); | 722 | return (0); | |
709 | 723 | |||
710 | _PROP_RWLOCK_RDLOCK(pd->pd_rwlock); | 724 | _PROP_RWLOCK_RDLOCK(pd->pd_rwlock); | |
711 | rv = pd->pd_count; | 725 | rv = pd->pd_count; |
--- src/common/lib/libprop/prop_number.3 2007/08/16 16:31:00 1.7
+++ src/common/lib/libprop/prop_number.3 2008/03/23 00:12:45 1.7.2.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_number.3,v 1.7 2007/08/16 16:31:00 thorpej Exp $ | 1 | .\" prop_number.3,v 1.7 2007/08/16 16:31:00 thorpej Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd October 11, 2006 | 37 | .Dd January 21, 2008 | |
38 | .Dt PROP_NUMBER 3 | 38 | .Dt PROP_NUMBER 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm prop_number , | 41 | .Nm prop_number , | |
42 | .Nm prop_number_create_integer , | 42 | .Nm prop_number_create_integer , | |
43 | .Nm prop_number_create_unsigned_integer , | 43 | .Nm prop_number_create_unsigned_integer , | |
44 | .Nm prop_number_copy , | 44 | .Nm prop_number_copy , | |
45 | .Nm prop_number_size , | 45 | .Nm prop_number_size , | |
46 | .Nm prop_number_unsigned , | 46 | .Nm prop_number_unsigned , | |
47 | .Nm prop_number_integer_value , | 47 | .Nm prop_number_integer_value , | |
48 | .Nm prop_number_unsigned_integer_value , | 48 | .Nm prop_number_unsigned_integer_value , | |
49 | .Nm prop_number_equals , | 49 | .Nm prop_number_equals , | |
50 | .Nm prop_number_equals_integer , | 50 | .Nm prop_number_equals_integer , | |
@@ -121,57 +121,90 @@ then the number is signed. | @@ -121,57 +121,90 @@ then the number is signed. | |||
121 | If the first two characters of the number are | 121 | If the first two characters of the number are | |
122 | .Sq 0x | 122 | .Sq 0x | |
123 | then the number is unsigned. | 123 | then the number is unsigned. | |
124 | .It | 124 | .It | |
125 | If the number value fits into the range of a signed number then the | 125 | If the number value fits into the range of a signed number then the | |
126 | number is signed. | 126 | number is signed. | |
127 | .It | 127 | .It | |
128 | In all other cases, the number is unsigned. | 128 | In all other cases, the number is unsigned. | |
129 | .El | 129 | .El | |
130 | .Bl -tag -width "xxxxx" | 130 | .Bl -tag -width "xxxxx" | |
131 | .It Fn prop_number_create_integer "int64_t val" | 131 | .It Fn prop_number_create_integer "int64_t val" | |
132 | Create a numeric value object with the signed value | 132 | Create a numeric value object with the signed value | |
133 | .Fa val . | 133 | .Fa val . | |
134 | Returns | |||
135 | .Dv NULL | |||
136 | on failure. | |||
134 | .It Fn prop_number_create_unsigned_integer "uint64_t val" | 137 | .It Fn prop_number_create_unsigned_integer "uint64_t val" | |
135 | Create a numeric value object with the unsigned value | 138 | Create a numeric value object with the unsigned value | |
136 | .Fa val . | 139 | .Fa val . | |
140 | Returns | |||
141 | .Dv NULL | |||
142 | on failure. | |||
137 | .It Fn prop_number_copy "prop_number_t number" | 143 | .It Fn prop_number_copy "prop_number_t number" | |
138 | Copy a numeric value object. | 144 | Copy a numeric value object. | |
145 | If the supplied object isn't a numeric value, | |||
146 | .Dv NULL | |||
147 | is returned. | |||
139 | .It Fn prop_number_size "prop_number_t number" | 148 | .It Fn prop_number_size "prop_number_t number" | |
140 | Returns 8, 16, 32, or 64, representing the number of bits required to | 149 | Returns 8, 16, 32, or 64, representing the number of bits required to | |
141 | hold the value of the object. | 150 | hold the value of the object. | |
151 | If the supplied object isn't a numeric value, | |||
152 | .Dv NULL | |||
153 | is returned. | |||
142 | .It Fn prop_number_unsigned "prop_number_t number" | 154 | .It Fn prop_number_unsigned "prop_number_t number" | |
143 | Returns | 155 | Returns | |
144 | .Dv true | 156 | .Dv true | |
145 | if the numeric value object has an unsigned value. | 157 | if the numeric value object has an unsigned value. | |
146 | .It Fn prop_number_integer_value "prop_number_t number" | 158 | .It Fn prop_number_integer_value "prop_number_t number" | |
147 | Returns the signed integer value of the numeric value object. | 159 | Returns the signed integer value of the numeric value object. | |
160 | If the supplied object isn't a numeric value, zero is returned. Thus, | |||
161 | it is not possible to distinguish between ``not a prop_number_t'' | |||
162 | and ``prop_number_t has a value of 0''. | |||
148 | .It Fn prop_number_unsigned_integer_value "prop_number_t number" | 163 | .It Fn prop_number_unsigned_integer_value "prop_number_t number" | |
149 | Returns the unsigned integer value of the numeric value object. | 164 | Returns the unsigned integer value of the numeric value object. | |
165 | If the supplied object isn't a numeric value, zero is returned. Thus, | |||
166 | it is not possible to distinguish between ``not a prop_number_t'' | |||
167 | and ``prop_number_t has a value of 0''. | |||
150 | .It Fn prop_number_equals "prop_number_t num1" "prop_number_t num2" | 168 | .It Fn prop_number_equals "prop_number_t num1" "prop_number_t num2" | |
151 | Returns | 169 | Returns | |
152 | .Dv true | 170 | .Dv true | |
153 | if the two numeric value objects are equivalent. | 171 | if the two numeric value objects are equivalent. | |
172 | If at least one of the supplied objects isn't a numeric value, | |||
173 | .Dv false | |||
174 | is returned. | |||
154 | .It Fn prop_number_equals_integer "prop_number_t number" "int64_t val" | 175 | .It Fn prop_number_equals_integer "prop_number_t number" "int64_t val" | |
155 | Returns | 176 | Returns | |
156 | .Dv true | 177 | .Dv true | |
157 | if the object's value is equivalent to the signed value | 178 | if the object's value is equivalent to the signed value | |
158 | .Fa val . | 179 | .Fa val . | |
180 | If the supplied object isn't a numerical value or if | |||
181 | .Fa val | |||
182 | exceeds | |||
183 | .Dv INT64_MAX , | |||
184 | .Dv false | |||
185 | is returned. | |||
159 | .It Fn prop_number_equals_unsigned_integer "prop_number_t number" \ | 186 | .It Fn prop_number_equals_unsigned_integer "prop_number_t number" \ | |
160 | "uint64_t val" | 187 | "uint64_t val" | |
161 | Returns | 188 | Returns | |
162 | .Dv true | 189 | .Dv true | |
163 | if the object's value is equivalent to the unsigned value | 190 | if the object's value is equivalent to the unsigned value | |
164 | .Fa val . | 191 | .Fa val . | |
192 | If the supplied object isn't a numerical value or if | |||
193 | .Fa val | |||
194 | exceeds | |||
195 | .Dv INT64_MAX , | |||
196 | .Dv false | |||
197 | is returned. | |||
165 | .El | 198 | .El | |
166 | .Sh SEE ALSO | 199 | .Sh SEE ALSO | |
167 | .Xr prop_array 3 , | 200 | .Xr prop_array 3 , | |
168 | .Xr prop_bool 3 , | 201 | .Xr prop_bool 3 , | |
169 | .Xr prop_data 3 , | 202 | .Xr prop_data 3 , | |
170 | .Xr prop_dictionary 3 , | 203 | .Xr prop_dictionary 3 , | |
171 | .Xr prop_object 3 , | 204 | .Xr prop_object 3 , | |
172 | .Xr prop_string 3 , | 205 | .Xr prop_string 3 , | |
173 | .Xr proplib 3 | 206 | .Xr proplib 3 | |
174 | .Sh HISTORY | 207 | .Sh HISTORY | |
175 | The | 208 | The | |
176 | .Nm proplib | 209 | .Nm proplib | |
177 | property container object library first appeared in | 210 | property container object library first appeared in |
--- src/common/lib/libprop/prop_object.c 2007/11/06 23:07:26 1.15.2.1
+++ src/common/lib/libprop/prop_object.c 2008/03/23 00:12:45 1.15.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prop_object.c,v 1.15.2.1 2007/11/06 23:07:26 matt Exp $ */ | 1 | /* prop_object.c,v 1.15.2.1 2007/11/06 23:07:26 matt Exp */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -837,59 +837,56 @@ _prop_object_externalize_file_dirname(co | @@ -837,59 +837,56 @@ _prop_object_externalize_file_dirname(co | |||
837 | /* | 837 | /* | |
838 | * _prop_object_externalize_write_file -- | 838 | * _prop_object_externalize_write_file -- | |
839 | * Write an externalized dictionary to the specified file. | 839 | * Write an externalized dictionary to the specified file. | |
840 | * The file is written atomically from the caller's perspective, | 840 | * The file is written atomically from the caller's perspective, | |
841 | * and the mode set to 0666 modified by the caller's umask. | 841 | * and the mode set to 0666 modified by the caller's umask. | |
842 | */ | 842 | */ | |
843 | bool | 843 | bool | |
844 | _prop_object_externalize_write_file(const char *fname, const char *xml, | 844 | _prop_object_externalize_write_file(const char *fname, const char *xml, | |
845 | size_t len) | 845 | size_t len) | |
846 | { | 846 | { | |
847 | char tname[PATH_MAX]; | 847 | char tname[PATH_MAX]; | |
848 | int fd; | 848 | int fd; | |
849 | int save_errno; | 849 | int save_errno; | |
850 | mode_t myumask; | |||
850 | 851 | |||
851 | if (len > SSIZE_MAX) { | 852 | if (len > SSIZE_MAX) { | |
852 | errno = EFBIG; | 853 | errno = EFBIG; | |
853 | return (false); | 854 | return (false); | |
854 | } | 855 | } | |
855 | 856 | |||
856 | /* | 857 | /* | |
857 | * Get the directory name where the file is to be written | 858 | * Get the directory name where the file is to be written | |
858 | * and create the temporary file. | 859 | * and create the temporary file. | |
859 | * | |||
860 | * We don't use mkstemp() because mkstemp() always creates the | |||
861 | * file with mode 0600. We do, however, use mktemp() safely. | |||
862 | */ | 860 | */ | |
863 | again: | |||
864 | _prop_object_externalize_file_dirname(fname, tname); | 861 | _prop_object_externalize_file_dirname(fname, tname); | |
865 | if (strlcat(tname, "/.plistXXXXXX", sizeof(tname)) >= sizeof(tname)) { | 862 | if (strlcat(tname, "/.plistXXXXXX", sizeof(tname)) >= sizeof(tname)) { | |
866 | errno = ENAMETOOLONG; | 863 | errno = ENAMETOOLONG; | |
867 | return (false); | 864 | return (false); | |
868 | } | 865 | } | |
869 | if (mktemp(tname) == NULL) | 866 | if ((fd = mkstemp(tname)) == -1) | |
870 | return (false); | 867 | return (false); | |
871 | if ((fd = open(tname, O_CREAT|O_RDWR|O_EXCL, 0666)) == -1) { | |||
872 | if (errno == EEXIST) | |||
873 | goto again; | |||
874 | return (false); | |||
875 | } | |||
876 | 868 | |||
877 | if (write(fd, xml, len) != (ssize_t)len) | 869 | if (write(fd, xml, len) != (ssize_t)len) | |
878 | goto bad; | 870 | goto bad; | |
879 | 871 | |||
880 | if (fsync(fd) == -1) | 872 | if (fsync(fd) == -1) | |
881 | goto bad; | 873 | goto bad; | |
882 | 874 | |||
875 | myumask = umask(0); | |||
876 | (void)umask(myumask); | |||
877 | if (fchmod(fd, 0666 & ~myumask) == -1) | |||
878 | goto bad; | |||
879 | ||||
883 | (void) close(fd); | 880 | (void) close(fd); | |
884 | fd = -1; | 881 | fd = -1; | |
885 | 882 | |||
886 | if (rename(tname, fname) == -1) | 883 | if (rename(tname, fname) == -1) | |
887 | goto bad; | 884 | goto bad; | |
888 | 885 | |||
889 | return (true); | 886 | return (true); | |
890 | 887 | |||
891 | bad: | 888 | bad: | |
892 | save_errno = errno; | 889 | save_errno = errno; | |
893 | if (fd != -1) | 890 | if (fd != -1) | |
894 | (void) close(fd); | 891 | (void) close(fd); | |
895 | (void) unlink(tname); | 892 | (void) unlink(tname); |
--- src/common/lib/libprop/prop_send_ioctl.3 2007/05/10 22:15:47 1.3
+++ src/common/lib/libprop/prop_send_ioctl.3 2008/03/23 00:12:45 1.3.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_send_ioctl.3,v 1.3 2007/05/10 22:15:47 xtraeme Exp $ | 1 | .\" prop_send_ioctl.3,v 1.3 2007/05/10 22:15:47 xtraeme Exp | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | .\" | 24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 25 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 26 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 27 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 28 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 29 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | .\" POSSIBILITY OF SUCH DAMAGE. | 35 | .\" POSSIBILITY OF SUCH DAMAGE. | |
36 | .\" | 36 | .\" | |
37 | .Dd May 11, 2007 | 37 | .Dd January 21, 2008 | |
38 | .Dt PROP_SEND_IOCTL 3 | 38 | .Dt PROP_SEND_IOCTL 3 | |
39 | .Os | 39 | .Os | |
40 | .Sh NAME | 40 | .Sh NAME | |
41 | .Nm prop_array_send_ioctl , | 41 | .Nm prop_array_send_ioctl , | |
42 | .Nm prop_array_recv_ioctl , | 42 | .Nm prop_array_recv_ioctl , | |
43 | .Nm prop_dictionary_send_ioctl , | 43 | .Nm prop_dictionary_send_ioctl , | |
44 | .Nm prop_dictionary_recv_ioctl , | 44 | .Nm prop_dictionary_recv_ioctl , | |
45 | .Nm prop_dictionary_sendrecv_ioctl | 45 | .Nm prop_dictionary_sendrecv_ioctl | |
46 | .Nd Send and receive propertly lists to and from the kernel using ioctl | 46 | .Nd Send and receive propertly lists to and from the kernel using ioctl | |
47 | .Sh SYNOPSIS | 47 | .Sh SYNOPSIS | |
48 | .In prop/proplib.h | 48 | .In prop/proplib.h | |
49 | .Ft int | 49 | .Ft int | |
50 | .Fn prop_array_send_ioctl "prop_array_t array" "int fd" "unsigned long cmd" | 50 | .Fn prop_array_send_ioctl "prop_array_t array" "int fd" "unsigned long cmd" | |
@@ -59,27 +59,55 @@ | @@ -59,27 +59,55 @@ | |||
59 | .Fn prop_dictionary_sendrecv_ioctl "prop_dictionary_t dict" "int fd" \ | 59 | .Fn prop_dictionary_sendrecv_ioctl "prop_dictionary_t dict" "int fd" \ | |
60 | "unsigned long cmd" "prop_dictionary_t *dictp" | 60 | "unsigned long cmd" "prop_dictionary_t *dictp" | |
61 | .Sh DESCRIPTION | 61 | .Sh DESCRIPTION | |
62 | The | 62 | The | |
63 | .Nm prop_array_send_ioctl , | 63 | .Nm prop_array_send_ioctl , | |
64 | .Nm prop_array_recv_ioctl , | 64 | .Nm prop_array_recv_ioctl , | |
65 | .Nm prop_dictionary_send_ioctl , | 65 | .Nm prop_dictionary_send_ioctl , | |
66 | .Nm prop_dictionary_recv_ioctl , | 66 | .Nm prop_dictionary_recv_ioctl , | |
67 | and | 67 | and | |
68 | .Nm prop_dictionary_sendrecv_ioctl | 68 | .Nm prop_dictionary_sendrecv_ioctl | |
69 | functions implement the user space side of a protocol for sending property | 69 | functions implement the user space side of a protocol for sending property | |
70 | lists to and from the kernel using | 70 | lists to and from the kernel using | |
71 | .Xr ioctl 2 . | 71 | .Xr ioctl 2 . | |
72 | .Sh RETURN VALUES | |||
73 | If successful, functions return zero. Otherwise, an error number is returned to indicate the error. | |||
74 | .Sh ERRORS | |||
75 | .Fn prop_array_send_ioctl | |||
76 | and | |||
77 | .Fn prop_dictionary_send_ioctl | |||
78 | will fail if: | |||
79 | .Bl -tag -width Er | |||
80 | .It Bq Er ENOMEM | |||
81 | Cannot allocate memory | |||
82 | .It Bq Er ENOTSUP | |||
83 | Not supported | |||
84 | .El | |||
85 | .Pp | |||
86 | .Fn prop_array_recv_ioctl | |||
87 | and | |||
88 | .Fn prop_dictionary_recv_ioctl | |||
89 | will fail if: | |||
90 | .Bl -tag -width Er | |||
91 | .It Bq Er EIO | |||
92 | Input/output error | |||
93 | .It Bq Er ENOTSUP | |||
94 | Not supported | |||
95 | .El | |||
72 | .Pp | 96 | .Pp | |
97 | In addition to these, | |||
98 | .Xr ioctl 2 | |||
99 | errors may be returned. | |||
100 | .Sh EXAMPLES | |||
73 | The following | 101 | The following | |
74 | .Pq simplified | 102 | .Pq simplified | |
75 | example demonstrates using | 103 | example demonstrates using | |
76 | .Fn prop_dictionary_send_ioctl | 104 | .Fn prop_dictionary_send_ioctl | |
77 | and | 105 | and | |
78 | .Fn prop_dictionary_recv_ioctl | 106 | .Fn prop_dictionary_recv_ioctl | |
79 | in an application: | 107 | in an application: | |
80 | .Bd -literal | 108 | .Bd -literal | |
81 | void | 109 | void | |
82 | foo_setprops(prop_dictionary_t dict) | 110 | foo_setprops(prop_dictionary_t dict) | |
83 | { | 111 | { | |
84 | int fd; | 112 | int fd; | |
85 | 113 |