1 /* 2 * osal_atomic_def.h 3 * 4 * osal driver 5 * 6 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 7 * 8 * This software is licensed under the terms of the GNU General Public 9 * License version 2, as published by the Free Software Foundation, and 10 * may be copied, distributed, and modified under those terms. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 */ 18 19 #ifndef OSAL_ATOMIC_DEF_H 20 #define OSAL_ATOMIC_DEF_H 21 22 #include <linux/atomic.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif /* __cplusplus */ 27 28 #define OsalAtomicReadWrapper(v) atomic_read((const atomic_t *)(v)) 29 #define OsalAtomicSetWrapper(v, value) atomic_set((atomic_t *)(v), value) 30 #define OsalAtomicIncWrapper(v) atomic_inc((atomic_t *)(v)) 31 #define OsalAtomicIncRetWrapper(v) atomic_inc_return((atomic_t *)(v)) 32 #define OsalAtomicDecWrapper(v) atomic_dec((atomic_t *)(v)) 33 #define OsalAtomicDecRetWrapper(v) atomic_dec_return((atomic_t *)(v)) 34 35 #define OsalTestBitWrapper(nr, addr) test_bit(nr, addr) 36 #define OsalTestSetBitWrapper(nr, addr) test_and_change_bit(nr, addr) 37 #define OsalTestClearBitWrapper(nr, addr) test_and_clear_bit(nr, addr) 38 #define OsalClearBitWrapper(nr, addr) clear_bit(nr, addr) 39 40 #ifdef __cplusplus 41 } 42 #endif /* __cplusplus */ 43 44 #endif /* OSAL_ATOMIC_DEF_H */ 45 46