1*09ff5f3bSriastradh/* $NetBSD: atomic_and.S,v 1.12 2022/04/06 22:47:56 riastradh Exp $ */ 2935eacf3Sad 3935eacf3Sad/*- 4935eacf3Sad * Copyright (c) 2007 The NetBSD Foundation, Inc. 5935eacf3Sad * All rights reserved. 6935eacf3Sad * 7935eacf3Sad * This code is derived from software contributed to The NetBSD Foundation 8935eacf3Sad * by Jason R. Thorpe. 9935eacf3Sad * 10935eacf3Sad * Redistribution and use in source and binary forms, with or without 11935eacf3Sad * modification, are permitted provided that the following conditions 12935eacf3Sad * are met: 13935eacf3Sad * 1. Redistributions of source code must retain the above copyright 14935eacf3Sad * notice, this list of conditions and the following disclaimer. 15935eacf3Sad * 2. Redistributions in binary form must reproduce the above copyright 16935eacf3Sad * notice, this list of conditions and the following disclaimer in the 17935eacf3Sad * documentation and/or other materials provided with the distribution. 18935eacf3Sad * 19935eacf3Sad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20935eacf3Sad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21935eacf3Sad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22935eacf3Sad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23935eacf3Sad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24935eacf3Sad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25935eacf3Sad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26935eacf3Sad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27935eacf3Sad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28935eacf3Sad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29935eacf3Sad * POSSIBILITY OF SUCH DAMAGE. 30935eacf3Sad */ 31935eacf3Sad 32935eacf3Sad#include "atomic_op_asm.h" 33935eacf3Sad 34935eacf3Sad .text 35935eacf3Sad 366740bb54SchsENTRY(_atomic_and_32) 3707a0a325Smatt movl 4(%sp), %a0 3807a0a325Smatt movl 8(%sp), %d0 3965726debSmatt andl %d0, (%a0) 40935eacf3Sad rts 4165726debSmattEND(_atomic_and_32) 42935eacf3SadATOMIC_OP_ALIAS(atomic_and_32,_atomic_and_32) 43935eacf3SadATOMIC_OP_ALIAS(atomic_and_uint,_atomic_and_32) 44935eacf3SadSTRONG_ALIAS(_atomic_and_uint,_atomic_and_32) 45935eacf3SadATOMIC_OP_ALIAS(atomic_and_ulong,_atomic_and_32) 46935eacf3SadSTRONG_ALIAS(_atomic_and_ulong,_atomic_and_32) 4729d1edb6SadATOMIC_OP_ALIAS(atomic_and_ptr,_atomic_and_32) 4829d1edb6SadSTRONG_ALIAS(_atomic_and_ptr,_atomic_and_32) 49935eacf3Sad 506740bb54SchsENTRY(_atomic_and_32_nv) 5107a0a325Smatt movl 4(%sp), %a0 5207a0a325Smatt1: movl (%a0), %d0 53935eacf3Sad movl %d0, %d1 5407a0a325Smatt andl 8(%sp), %d0 5565726debSmatt casl %d1, %d0, (%a0) 56935eacf3Sad bne 1b 57ce6031c2Smartin movl %d0, %a0 58935eacf3Sad rts 5965726debSmattEND(_atomic_and_32_nv) 60935eacf3SadATOMIC_OP_ALIAS(atomic_and_32_nv,_atomic_and_32_nv) 61935eacf3SadATOMIC_OP_ALIAS(atomic_and_uint_nv,_atomic_and_32_nv) 62935eacf3SadSTRONG_ALIAS(_atomic_and_uint_nv,_atomic_and_32_nv) 63935eacf3SadATOMIC_OP_ALIAS(atomic_and_ulong_nv,_atomic_and_32_nv) 64935eacf3SadSTRONG_ALIAS(_atomic_and_ulong_nv,_atomic_and_32_nv) 6529d1edb6SadATOMIC_OP_ALIAS(atomic_and_ptr_nv,_atomic_and_32_nv) 6629d1edb6SadSTRONG_ALIAS(_atomic_and_ptr_nv,_atomic_and_32_nv) 67b290679aSmartinCRT_ALIAS(__sync_and_and_fetch_4,_atomic_and_32_nv) 68ce6031c2Smartin 69ce6031c2SmartinENTRY(__sync_fetch_and_and_4) 70ce6031c2Smartin movl 4(%sp), %a0 71ce6031c2Smartin1: movl (%a0), %d0 72ce6031c2Smartin movl %d0, %d1 73ce6031c2Smartin andl 8(%sp), %d1 74ce6031c2Smartin casl %d0, %d1, (%a0) 75ce6031c2Smartin bne 1b 76ce6031c2Smartin movl %d0, %a0 77ce6031c2Smartin rts 78ce6031c2SmartinEND(__sync_fetch_and_and_4) 79ce6031c2Smartin 80ce6031c2Smartin 81ce6031c2SmartinENTRY(_atomic_and_16_nv) 82ce6031c2Smartin movl 4(%sp), %a0 83ce6031c2Smartin1: movw (%a0), %d0 84ce6031c2Smartin movw %d0, %d1 85ce6031c2Smartin andw 8(%sp), %d0 86ce6031c2Smartin casw %d1, %d0, (%a0) 87ce6031c2Smartin bne 1b 88ce6031c2Smartin rts 89ce6031c2SmartinEND(_atomic_and_16_nv) 90ce6031c2Smartin 91b290679aSmartinCRT_ALIAS(__sync_and_and_fetch_2,_atomic_and_16_nv) 92ce6031c2Smartin 93ce6031c2SmartinENTRY(__sync_fetch_and_and_2) 94ce6031c2Smartin movl 4(%sp), %a0 95ce6031c2Smartin1: movw (%a0), %d0 96ce6031c2Smartin movw %d0, %d1 97ce6031c2Smartin andw 8(%sp), %d1 98ce6031c2Smartin casw %d0, %d1, (%a0) 99ce6031c2Smartin bne 1b 100ce6031c2Smartin rts 101ce6031c2SmartinEND(__sync_fetch_and_and_2) 102ce6031c2Smartin 103ce6031c2Smartin 104ce6031c2SmartinENTRY(_atomic_and_8_nv) 105ce6031c2Smartin movl 4(%sp), %a0 106ce6031c2Smartin1: movb (%a0), %d0 107ce6031c2Smartin movb %d0, %d1 108ce6031c2Smartin andb 8(%sp), %d0 109ce6031c2Smartin casb %d1, %d0, (%a0) 110ce6031c2Smartin bne 1b 111ce6031c2Smartin rts 112ce6031c2SmartinEND(_atomic_and_8_nv) 113ce6031c2Smartin 114b290679aSmartinCRT_ALIAS(__sync_and_and_fetch_1,_atomic_and_8_nv) 115ce6031c2Smartin 116ce6031c2SmartinENTRY(__sync_fetch_and_and_1) 117ce6031c2Smartin movl 4(%sp), %a0 118ce6031c2Smartin1: movb (%a0), %d0 119ce6031c2Smartin movb %d0, %d1 120ce6031c2Smartin andb 8(%sp), %d1 121ce6031c2Smartin casb %d0, %d1, (%a0) 122ce6031c2Smartin bne 1b 123ce6031c2Smartin rts 124ce6031c2SmartinEND(__sync_fetch_and_and_1) 125ce6031c2Smartin 126504e8e68SjoergCRT_ALIAS(__atomic_fetch_and_1,__sync_fetch_and_and_1) 127504e8e68SjoergCRT_ALIAS(__atomic_fetch_and_2,__sync_fetch_and_and_2) 128504e8e68SjoergCRT_ALIAS(__atomic_fetch_and_4,__sync_fetch_and_and_4) 129