Sun Jan 4 18:21:38 2009 UTC ()
Opt for libc versions in case of _KERNEL && !_RUMPKERNEL.
(kernel version uses sti/cli and is not PIC)


(pooka)
diff -r1.14 -r1.15 src/common/lib/libc/arch/i386/atomic/atomic.S

cvs diff -r1.14 -r1.15 src/common/lib/libc/arch/i386/atomic/atomic.S (expand / switch to unified diff)

--- src/common/lib/libc/arch/i386/atomic/atomic.S 2008/12/19 11:21:24 1.14
+++ src/common/lib/libc/arch/i386/atomic/atomic.S 2009/01/04 18:21:38 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: atomic.S,v 1.14 2008/12/19 11:21:24 ad Exp $ */ 1/* $NetBSD: atomic.S,v 1.15 2009/01/04 18:21:38 pooka 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.
@@ -21,27 +21,31 @@ @@ -21,27 +21,31 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <machine/asm.h> 32#include <machine/asm.h>
33 33
34#ifdef _KERNEL 34#if defined(_KERNEL) && !defined(_RUMPKERNEL)
 35#define _HARDKERNEL
 36#endif
 37
 38#ifdef _HARDKERNEL
35#define LOCK(n) .Lpatch/**/n: lock 39#define LOCK(n) .Lpatch/**/n: lock
36#define ALIAS(f, t) STRONG_ALIAS(f,t) 40#define ALIAS(f, t) STRONG_ALIAS(f,t)
37#define ENDLABEL(a) _ALIGN_TEXT; LABEL(a) 41#define ENDLABEL(a) _ALIGN_TEXT; LABEL(a)
38#else 42#else
39#define LOCK(n) lock 43#define LOCK(n) lock
40#define ALIAS(f, t) WEAK_ALIAS(f,t) 44#define ALIAS(f, t) WEAK_ALIAS(f,t)
41#define ENDLABEL(a) /* nothing */ 45#define ENDLABEL(a) /* nothing */
42#endif 46#endif
43 47
44 .text 48 .text
45 49
46ENTRY(_atomic_add_32) 50ENTRY(_atomic_add_32)
47 movl 4(%esp), %edx 51 movl 4(%esp), %edx
@@ -160,27 +164,27 @@ ENDLABEL(membar_consumer_end) @@ -160,27 +164,27 @@ ENDLABEL(membar_consumer_end)
160 164
161ENTRY(_membar_producer) 165ENTRY(_membar_producer)
162 /* A store is enough */ 166 /* A store is enough */
163 movl $0, -4(%esp) 167 movl $0, -4(%esp)
164 ret 168 ret
165ENDLABEL(membar_producer_end) 169ENDLABEL(membar_producer_end)
166 170
167ENTRY(_membar_sync) 171ENTRY(_membar_sync)
168 LOCK(14) 172 LOCK(14)
169 addl $0, -4(%esp) 173 addl $0, -4(%esp)
170 ret 174 ret
171ENDLABEL(membar_sync_end) 175ENDLABEL(membar_sync_end)
172 176
173#ifdef _KERNEL 177#ifdef _HARDKERNEL
174ENTRY(_atomic_cas_64) 178ENTRY(_atomic_cas_64)
175 pushf 179 pushf
176 cli 180 cli
177 pushl %edi 181 pushl %edi
178 pushl %ebx 182 pushl %ebx
179 movl 12(%esp), %edi 183 movl 12(%esp), %edi
180 movl 16(%esp), %eax 184 movl 16(%esp), %eax
181 movl 20(%esp), %edx 185 movl 20(%esp), %edx
182 movl 24(%esp), %ebx 186 movl 24(%esp), %ebx
183 movl 28(%esp), %ecx 187 movl 28(%esp), %ecx
184 cmpl 0(%edi), %eax 188 cmpl 0(%edi), %eax
185 jne 2f 189 jne 2f
186 cmpl 4(%edi), %edx 190 cmpl 4(%edi), %edx
@@ -233,27 +237,27 @@ atomic_lockpatch: @@ -233,27 +237,27 @@ atomic_lockpatch:
233ENTRY(_atomic_cas_64) 237ENTRY(_atomic_cas_64)
234 pushl %edi 238 pushl %edi
235 pushl %ebx 239 pushl %ebx
236 movl 12(%esp), %edi 240 movl 12(%esp), %edi
237 movl 16(%esp), %eax 241 movl 16(%esp), %eax
238 movl 20(%esp), %edx 242 movl 20(%esp), %edx
239 movl 24(%esp), %ebx 243 movl 24(%esp), %ebx
240 movl 28(%esp), %ecx 244 movl 28(%esp), %ecx
241 lock 245 lock
242 cmpxchg8b (%edi) 246 cmpxchg8b (%edi)
243 popl %ebx 247 popl %ebx
244 popl %edi 248 popl %edi
245 ret 249 ret
246#endif /* _KERNEL */ 250#endif /* _HARDKERNEL */
247 251
248ALIAS(atomic_add_32,_atomic_add_32) 252ALIAS(atomic_add_32,_atomic_add_32)
249ALIAS(atomic_add_int,_atomic_add_32) 253ALIAS(atomic_add_int,_atomic_add_32)
250ALIAS(atomic_add_long,_atomic_add_32) 254ALIAS(atomic_add_long,_atomic_add_32)
251ALIAS(atomic_add_ptr,_atomic_add_32) 255ALIAS(atomic_add_ptr,_atomic_add_32)
252 256
253ALIAS(atomic_add_32_nv,_atomic_add_32_nv) 257ALIAS(atomic_add_32_nv,_atomic_add_32_nv)
254ALIAS(atomic_add_int_nv,_atomic_add_32_nv) 258ALIAS(atomic_add_int_nv,_atomic_add_32_nv)
255ALIAS(atomic_add_long_nv,_atomic_add_32_nv) 259ALIAS(atomic_add_long_nv,_atomic_add_32_nv)
256ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv) 260ALIAS(atomic_add_ptr_nv,_atomic_add_32_nv)
257 261
258ALIAS(atomic_and_32,_atomic_and_32) 262ALIAS(atomic_and_32,_atomic_and_32)
259ALIAS(atomic_and_uint,_atomic_and_32) 263ALIAS(atomic_and_uint,_atomic_and_32)