]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / cddl / contrib / opensolaris / common / atomic / amd64 / opensolaris_atomic.S
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26
27         .file   "atomic.s"
28
29 #define _ASM
30 #include <sys/asm_linkage.h>
31
32         ENTRY(atomic_add_64_nv)
33         movq    (%rdi), %rax
34 1:
35         movq    %rsi, %rcx
36         addq    %rax, %rcx
37         lock
38         cmpxchgq %rcx, (%rdi)
39         jne     1b
40         movq    %rcx, %rax
41         ret
42         SET_SIZE(atomic_add_64_nv)
43
44         ENTRY(atomic_or_8_nv)
45         movb    (%rdi), %al     // %al = old value
46 1:
47         movb    %sil, %cl
48         orb     %al, %cl        // %cl = new value
49         lock
50         cmpxchgb %cl, (%rdi)    // try to stick it in
51         jne     1b
52         movzbl  %cl, %eax       // return new value
53         ret
54         SET_SIZE(atomic_or_8_nv)
55
56         ENTRY(atomic_cas_64)
57         movq    %rsi, %rax
58         lock
59         cmpxchgq %rdx, (%rdi)
60         ret
61         SET_SIZE(atomic_cas_64)
62
63         ENTRY(membar_producer)
64         sfence
65         ret
66         SET_SIZE(membar_producer)