1168482Spjd/* 2168482Spjd * CDDL HEADER START 3168482Spjd * 4168482Spjd * The contents of this file are subject to the terms of the 5185029Spjd * Common Development and Distribution License (the "License"). 6185029Spjd * You may not use this file except in compliance with the License. 7168482Spjd * 8168482Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9168482Spjd * or http://www.opensolaris.org/os/licensing. 10168482Spjd * See the License for the specific language governing permissions 11168482Spjd * and limitations under the License. 12168482Spjd * 13168482Spjd * When distributing Covered Code, include this CDDL HEADER in each 14168482Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15168482Spjd * If applicable, add the following below this CDDL HEADER, with the 16168482Spjd * fields enclosed by brackets "[]" replaced with your own identifying 17168482Spjd * information: Portions Copyright [yyyy] [name of copyright owner] 18168482Spjd * 19168482Spjd * CDDL HEADER END 20168482Spjd */ 21185029Spjd 22168482Spjd/* 23219089Spjd * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 24168482Spjd */ 25168482Spjd 26185029Spjd .file "atomic.s" 27168482Spjd 28168482Spjd#define _ASM 29168482Spjd#include <sys/asm_linkage.h> 30168482Spjd 31168482Spjd ENTRY(atomic_add_64_nv) 32219089Spjd mov %rsi, %rax // %rax = delta addend 33168482Spjd lock 34219089Spjd xaddq %rsi, (%rdi) // %rsi = old value, (%rdi) = sum 35219089Spjd addq %rsi, %rax // new value = original value + delta 36168482Spjd ret 37168482Spjd SET_SIZE(atomic_add_64_nv) 38168482Spjd 39168482Spjd ENTRY(atomic_or_8_nv) 40168675Spjd movb (%rdi), %al // %al = old value 41168482Spjd1: 42168482Spjd movb %sil, %cl 43168675Spjd orb %al, %cl // %cl = new value 44168482Spjd lock 45168675Spjd cmpxchgb %cl, (%rdi) // try to stick it in 46168482Spjd jne 1b 47168675Spjd movzbl %cl, %eax // return new value 48168482Spjd ret 49170431Spjd SET_SIZE(atomic_or_8_nv) 50168482Spjd 51219089Spjd ENTRY(atomic_cas_32) 52219089Spjd movl %esi, %eax 53219089Spjd lock 54219089Spjd cmpxchgl %edx, (%rdi) 55219089Spjd ret 56219089Spjd SET_SIZE(atomic_cas_32) 57219089Spjd 58168482Spjd ENTRY(atomic_cas_64) 59168482Spjd movq %rsi, %rax 60168482Spjd lock 61168482Spjd cmpxchgq %rdx, (%rdi) 62168482Spjd ret 63168482Spjd SET_SIZE(atomic_cas_64) 64168482Spjd 65168482Spjd ENTRY(membar_producer) 66168482Spjd sfence 67168482Spjd ret 68168482Spjd SET_SIZE(membar_producer) 69