1*09ff5f3bSriastradh/* $NetBSD: atomic_inc.S,v 1.8 2022/04/06 22:47:57 riastradh Exp $ */ 2f1d10eabSad 3f1d10eabSad/*- 4f1d10eabSad * Copyright (c) 2007 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_inc_32) 37f1d10eabSad ld [%o0], %o2 38f1d10eabSad1: add %o2, 1, %o3 39f1d10eabSad cas [%o0], %o2, %o3 40f1d10eabSad cmp %o2, %o3 41f1d10eabSad bne,a,pn %icc, 1b 42f1d10eabSad mov %o3, %o2 43f1d10eabSad retl 44f1d10eabSad add %o2, 1, %o0 45f1d10eabSadATOMIC_OP_ALIAS(atomic_inc_32,_atomic_inc_32) 46f1d10eabSadATOMIC_OP_ALIAS(atomic_inc_uint,_atomic_inc_32) 47f1d10eabSadSTRONG_ALIAS(_atomic_inc_uint,_atomic_inc_32) 48f1d10eabSad 49f1d10eabSadATOMIC_OP_ALIAS(atomic_inc_32_nv,_atomic_inc_32) 50f1d10eabSadSTRONG_ALIAS(_atomic_inc_32_nv,_atomic_inc_32) 51f1d10eabSadATOMIC_OP_ALIAS(atomic_inc_uint_nv,_atomic_inc_32) 52f1d10eabSadSTRONG_ALIAS(_atomic_inc_uint_nv,_atomic_inc_32) 53f1d10eabSad 546740bb54SchsENTRY(_atomic_inc_64) 55f1d10eabSad ldx [%o0], %o2 56f1d10eabSad1: add %o2, 1, %o3 57f1d10eabSad casx [%o0], %o2, %o3 58f1d10eabSad cmp %o2, %o3 5999adca9eSnakayama bne,a,pn %xcc, 1b 60f1d10eabSad mov %o3, %o2 612c01e1e1Snakayama#ifdef __arch64__ 62f1d10eabSad retl 63f1d10eabSad add %o2, 1, %o0 642c01e1e1Snakayama#else 652c01e1e1Snakayama add %o2, 1, %o0 662c01e1e1Snakayama SPLIT_RETL(%o0, %o0, %o1) 672c01e1e1Snakayama#endif 68f1d10eabSadATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64) 69f1d10eabSad 70f1d10eabSadATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64) 71f1d10eabSadSTRONG_ALIAS(_atomic_inc_64_nv,_atomic_inc_64) 7297e461c6Smrg 7397e461c6SmrgATOMIC_OP_ALIAS_SIZE(atomic_inc_ulong,_atomic_inc) 7497e461c6SmrgSTRONG_ALIAS_SIZE(_atomic_inc_ulong,_atomic_inc) 7597e461c6SmrgATOMIC_OP_ALIAS_SIZE(atomic_inc_ptr,_atomic_inc) 7697e461c6SmrgSTRONG_ALIAS_SIZE(_atomic_inc_ptr,_atomic_inc) 7797e461c6Smrg 7897e461c6SmrgATOMIC_OP_ALIAS_SIZE(atomic_inc_ulong_nv,_atomic_inc) 7997e461c6SmrgSTRONG_ALIAS_SIZE(_atomic_inc_ulong_nv,_atomic_inc) 8097e461c6SmrgATOMIC_OP_ALIAS_SIZE(atomic_inc_ptr_nv,_atomic_inc) 8197e461c6SmrgSTRONG_ALIAS_SIZE(_atomic_inc_ptr_nv,_atomic_inc) 82