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