167754Smsmith/* $NetBSD: atomic_xor_32.S,v 1.3 2014/06/23 21:53:45 joerg Exp $ */ 267754Smsmith/*- 377424Smsmith * Copyright (c) 2008 The NetBSD Foundation, Inc. 467754Smsmith * All rights reserved. 567754Smsmith * 667754Smsmith * This code is derived from software contributed to The NetBSD Foundation 767754Smsmith * by Matt Thomas <matt@3am-software.com> 867754Smsmith * 967754Smsmith * Redistribution and use in source and binary forms, with or without 1067754Smsmith * modification, are permitted provided that the following conditions 11193267Sjkim * are met: 1270243Smsmith * 1. Redistributions of source code must retain the above copyright 1367754Smsmith * notice, this list of conditions and the following disclaimer. 1467754Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1567754Smsmith * notice, this list of conditions and the following disclaimer in the 1667754Smsmith * documentation and/or other materials provided with the distribution. 1767754Smsmith * 1867754Smsmith * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1967754Smsmith * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2067754Smsmith * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2167754Smsmith * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2267754Smsmith * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2367754Smsmith * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2467754Smsmith * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2567754Smsmith * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2667754Smsmith * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2767754Smsmith * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2867754Smsmith * POSSIBILITY OF SUCH DAMAGE. 2967754Smsmith */ 3067754Smsmith 3167754Smsmith#include "atomic_op_asm.h" 3267754Smsmith 3367754SmsmithENTRY_NP(_atomic_xor_32) 3467754Smsmith1: l.lwa r11, 0(r3) /* load old value */ 3567754Smsmith l.xor r5, r11, r4 /* calculate new value */ 3667754Smsmith l.swa 0(r3), r5 /* try to store */ 3767754Smsmith l.bnf 1b /* succeed? no, try again */ 3867754Smsmith l.nop /* -- delay slot -- */ 3967754Smsmith l.jr lr /* return old value */ 4067754Smsmith l.nop 4167754SmsmithEND(_atomic_xor_32) 4267754Smsmith 4367754SmsmithATOMIC_OP_ALIAS(atomic_xor_32,_atomic_xor_32) 4467754SmsmithATOMIC_OP_ALIAS(atomic_xor_uint,_atomic_xor_32) 4567754SmsmithATOMIC_OP_ALIAS(atomic_xor_ulong,_atomic_xor_32) 4667754SmsmithCRT_ALIAS(__sync_fetch_and_xor_4,_atomic_xor_32) 4767754SmsmithCRT_ALIAS(__atomic_fetch_xor_4,_atomic_xor_32) 4867754SmsmithSTRONG_ALIAS(_atomic_xor_uint,_atomic_xor_32) 4967754SmsmithSTRONG_ALIAS(_atomic_xor_ulong,_atomic_xor_32) 5067754Smsmith 5167754SmsmithENTRY_NP(_atomic_xor_32_nv) 5267754Smsmith1: l.lwa r5, 0(r3) /* load old value */ 5367754Smsmith l.xor r11, r5, r4 /* calculate new value */ 5467754Smsmith l.swa 0(r3), r11 /* try to store */ 5567754Smsmith l.bnf 1b /* succeed? no, try again */ 5667754Smsmith l.nop /* -- delay slot -- */ 5767754Smsmith l.jr lr /* return old value */ 5867754Smsmith l.nop 5967754SmsmithEND(_atomic_xor_32_nv) 6067754Smsmith 6167754SmsmithATOMIC_OP_ALIAS(atomic_xor_32_nv,_atomic_xor_32_nv) 6267754SmsmithATOMIC_OP_ALIAS(atomic_xor_uint_nv,_atomic_xor_32_nv) 6367754SmsmithATOMIC_OP_ALIAS(atomic_xor_ulong_nv,_atomic_xor_32_nv) 6467754SmsmithCRT_ALIAS(__sync_xor_and_fetch_4,_atomic_xor_32_nv) 6567754SmsmithSTRONG_ALIAS(_atomic_xor_uint_nv,_atomic_xor_32_nv) 6667754SmsmithSTRONG_ALIAS(_atomic_xor_ulong_nv,_atomic_xor_32_nv) 6767754Smsmith