1f9f848faSopenharmony_ci/*- 2f9f848faSopenharmony_ci * Copyright (c) 2010 Isilon Systems, Inc. 3f9f848faSopenharmony_ci * Copyright (c) 2010 iX Systems, Inc. 4f9f848faSopenharmony_ci * Copyright (c) 2010 Panasas, Inc. 5f9f848faSopenharmony_ci * Copyright (c) 2013-2018 Mellanox Technologies, Ltd. 6f9f848faSopenharmony_ci * All rights reserved. 7f9f848faSopenharmony_ci * 8f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without 9f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions 10f9f848faSopenharmony_ci * are met: 11f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 12f9f848faSopenharmony_ci * notice unmodified, this list of conditions, and the following 13f9f848faSopenharmony_ci * disclaimer. 14f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 15f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer in the 16f9f848faSopenharmony_ci * documentation and/or other materials provided with the distribution. 17f9f848faSopenharmony_ci * 18f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19f9f848faSopenharmony_ci * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20f9f848faSopenharmony_ci * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21f9f848faSopenharmony_ci * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22f9f848faSopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23f9f848faSopenharmony_ci * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24f9f848faSopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25f9f848faSopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26f9f848faSopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27f9f848faSopenharmony_ci * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28f9f848faSopenharmony_ci */ 29f9f848faSopenharmony_ci 30f9f848faSopenharmony_ci#ifndef _LINUXKPI_ASM_ATOMIC_H_ 31f9f848faSopenharmony_ci#define _LINUXKPI_ASM_ATOMIC_H_ 32f9f848faSopenharmony_ci 33f9f848faSopenharmony_ci#include "los_atomic.h" 34f9f848faSopenharmony_ci 35f9f848faSopenharmony_ci#ifdef __cplusplus 36f9f848faSopenharmony_ci#if __cplusplus 37f9f848faSopenharmony_ciextern "C" { 38f9f848faSopenharmony_ci#endif /* __cplusplus */ 39f9f848faSopenharmony_ci#endif /* __cplusplus */ 40f9f848faSopenharmony_ci 41f9f848faSopenharmony_citypedef Atomic atomic_t; 42f9f848faSopenharmony_citypedef Atomic64 atomic64_t; 43f9f848faSopenharmony_ci 44f9f848faSopenharmony_ci#define ATOMIC_INIT(x) (x) 45f9f848faSopenharmony_ci#define atomic_read(v) LOS_AtomicRead(v) 46f9f848faSopenharmony_ci#define atomic_set(v, i) LOS_AtomicSet(v, i) 47f9f848faSopenharmony_ci#define atomic_inc(v) LOS_AtomicInc(v) 48f9f848faSopenharmony_ci#define atomic_dec(v) LOS_AtomicDec(v) 49f9f848faSopenharmony_ci#define atomic_add(i, v) LOS_AtomicAdd(v, i) 50f9f848faSopenharmony_ci#define atomic_sub(i, v) LOS_AtomicSub(v, i) 51f9f848faSopenharmony_ci 52f9f848faSopenharmony_ci#define atomic_add_return(i, v) LOS_AtomicAdd(v, i) 53f9f848faSopenharmony_ci#define atomic_inc_return(v) LOS_AtomicIncRet(v) 54f9f848faSopenharmony_ci#define atomic_dec_return(v) LOS_AtomicDecRet(v) 55f9f848faSopenharmony_ci#define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) 56f9f848faSopenharmony_ci 57f9f848faSopenharmony_ci#define ATOMIC64_INIT(x) (x) 58f9f848faSopenharmony_ci#define atomic64_read(v) LOS_Atomic64Read(v) 59f9f848faSopenharmony_ci#define atomic64_set(v, i) LOS_Atomic64Set(v, i) 60f9f848faSopenharmony_ci#define atomic64_inc(v) LOS_Atomic64Inc(v) 61f9f848faSopenharmony_ci#define atomic64_dec(v) LOS_Atomic64Dec(v) 62f9f848faSopenharmony_ci#define atomic64_add(i, v) LOS_Atomic64Add(v, i) 63f9f848faSopenharmony_ci#define atomic64_sub(i, v) LOS_Atomic64Sub(v, i) 64f9f848faSopenharmony_ci 65f9f848faSopenharmony_ci#define atomic64_add_return(i, v) LOS_Atomic64Add(v, i) 66f9f848faSopenharmony_ci#define atomic64_inc_return(v) LOS_Atomic64IncRet(v) 67f9f848faSopenharmony_ci#define atomic64_dec_return(v) LOS_Atomic64DecRet(v) 68f9f848faSopenharmony_ci#define atomic64_dec_and_test(v) (atomic64_dec_return(v) == 0) 69f9f848faSopenharmony_ci 70f9f848faSopenharmony_ci#ifdef __cplusplus 71f9f848faSopenharmony_ci#if __cplusplus 72f9f848faSopenharmony_ci} 73f9f848faSopenharmony_ci#endif /* __cplusplus */ 74f9f848faSopenharmony_ci#endif /* __cplusplus */ 75f9f848faSopenharmony_ci 76f9f848faSopenharmony_ci#endif /* _LINUXKPI_ASM_ATOMIC_H_ */ 77