1*09ff5f3bSriastradh/* $NetBSD: atomic_cas.S,v 1.8 2022/04/06 22:47:57 riastradh Exp $ */ 2f1d10eabSad 3f1d10eabSad/*- 4646fc3baSad * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. 5f1d10eabSad * All rights reserved. 6f1d10eabSad * 7f1d10eabSad * This code is derived from software contributed to The NetBSD Foundation 8f1d10eabSad * by Jason R. Thorpe. 9f1d10eabSad * 10f1d10eabSad * Redistribution and use in source and binary forms, with or without 11f1d10eabSad * modification, are permitted provided that the following conditions 12f1d10eabSad * are met: 13f1d10eabSad * 1. Redistributions of source code must retain the above copyright 14f1d10eabSad * notice, this list of conditions and the following disclaimer. 15f1d10eabSad * 2. Redistributions in binary form must reproduce the above copyright 16f1d10eabSad * notice, this list of conditions and the following disclaimer in the 17f1d10eabSad * documentation and/or other materials provided with the distribution. 18f1d10eabSad * 19f1d10eabSad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20f1d10eabSad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21f1d10eabSad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22f1d10eabSad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23f1d10eabSad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24f1d10eabSad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25f1d10eabSad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26f1d10eabSad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27f1d10eabSad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28f1d10eabSad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29f1d10eabSad * POSSIBILITY OF SUCH DAMAGE. 30f1d10eabSad */ 31f1d10eabSad 32f1d10eabSad#include "atomic_op_asm.h" 33f1d10eabSad 34f1d10eabSad .text 35f1d10eabSad 366740bb54SchsENTRY(_atomic_cas_32) 37f1d10eabSad cas [%o0], %o1, %o2 38f1d10eabSad retl 39f1d10eabSad mov %o2, %o0 40646fc3baSad 41f1d10eabSadATOMIC_OP_ALIAS(atomic_cas_32,_atomic_cas_32) 42f1d10eabSadATOMIC_OP_ALIAS(atomic_cas_uint,_atomic_cas_32) 43f1d10eabSadSTRONG_ALIAS(_atomic_cas_uint,_atomic_cas_32) 44f1d10eabSad 45646fc3baSadATOMIC_OP_ALIAS(atomic_cas_32_ni,_atomic_cas_32) 46646fc3baSadSTRONG_ALIAS(_atomic_cas_32_ni,_atomic_cas_32) 47646fc3baSadATOMIC_OP_ALIAS(atomic_cas_uint_ni,_atomic_cas_32) 48646fc3baSadSTRONG_ALIAS(_atomic_cas_uint_ni,_atomic_cas_32) 49646fc3baSad 506740bb54SchsENTRY(_atomic_cas_64) 512c01e1e1Snakayama#ifndef __arch64__ 522c01e1e1Snakayama COMBINE(%o1, %o2, %o1) 532c01e1e1Snakayama COMBINE(%o3, %o4, %o2) 542c01e1e1Snakayama#endif 55f1d10eabSad casx [%o0], %o1, %o2 562c01e1e1Snakayama#ifdef __arch64__ 57f1d10eabSad retl 58f1d10eabSad mov %o2, %o0 592c01e1e1Snakayama#else 602c01e1e1Snakayama SPLIT_RETL(%o2, %o0, %o1) 612c01e1e1Snakayama#endif 6297e461c6Smrg 63646fc3baSadATOMIC_OP_ALIAS(atomic_cas_64,_atomic_cas_64) 6497e461c6SmrgATOMIC_OP_ALIAS_SIZE(atomic_cas_ulong,_atomic_cas) 6597e461c6SmrgSTRONG_ALIAS_SIZE(_atomic_cas_ulong,_atomic_cas) 6697e461c6SmrgATOMIC_OP_ALIAS_SIZE(atomic_cas_ptr,_atomic_cas) 6797e461c6SmrgSTRONG_ALIAS_SIZE(_atomic_cas_ptr,_atomic_cas) 68646fc3baSad 69646fc3baSadATOMIC_OP_ALIAS(atomic_cas_64_ni,_atomic_cas_64) 70646fc3baSadSTRONG_ALIAS_SIZE(_atomic_cas_64_ni,_atomic_cas) 71646fc3baSadATOMIC_OP_ALIAS_SIZE(atomic_cas_ulong_ni,_atomic_cas) 72646fc3baSadSTRONG_ALIAS_SIZE(_atomic_cas_ulong_ni,_atomic_cas) 73646fc3baSadATOMIC_OP_ALIAS_SIZE(atomic_cas_ptr_ni,_atomic_cas) 74646fc3baSadSTRONG_ALIAS_SIZE(_atomic_cas_ptr_ni,_atomic_cas) 752c01e1e1Snakayama 762c01e1e1Snakayama#if !defined(__arch64__) && defined(CRT_ALIAS) 772c01e1e1SnakayamaCRT_ALIAS(__sync_val_compare_and_swap_8,_atomic_cas_64) 782c01e1e1Snakayama#endif 79