1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright(c) 2007-2022 Intel Corporation */ 3 /* $FreeBSD$ */ 4 #include "qat_utils.h" 5 6 #ifdef __x86_64__ 7 __inline int64_t 8 qatUtilsAtomicGet(QatUtilsAtomic *pAtomicVar) 9 { 10 return ((int64_t)atomic64_read((QatUtilsAtomic *)pAtomicVar)); 11 } 12 13 __inline void 14 qatUtilsAtomicSet(int64_t inValue, QatUtilsAtomic *pAtomicVar) 15 { 16 atomic64_set((QatUtilsAtomic *)pAtomicVar, inValue); 17 } 18 19 __inline int64_t 20 qatUtilsAtomicAdd(int64_t inValue, QatUtilsAtomic *pAtomicVar) 21 { 22 return atomic64_add_return((long)inValue, (QatUtilsAtomic *)pAtomicVar); 23 } 24 25 __inline int64_t 26 qatUtilsAtomicSub(int64_t inValue, QatUtilsAtomic *pAtomicVar) 27 { 28 return atomic64_sub_return((long)inValue, (QatUtilsAtomic *)pAtomicVar); 29 } 30 31 __inline int64_t 32 qatUtilsAtomicInc(QatUtilsAtomic *pAtomicVar) 33 { 34 return atomic64_inc_return((QatUtilsAtomic *)pAtomicVar); 35 } 36 37 __inline int64_t 38 qatUtilsAtomicDec(QatUtilsAtomic *pAtomicVar) 39 { 40 return atomic64_dec_return((QatUtilsAtomic *)pAtomicVar); 41 } 42 #else 43 __inline int64_t 44 qatUtilsAtomicGet(QatUtilsAtomic *pAtomicVar) 45 { 46 return ((int64_t)atomic_read((QatUtilsAtomic *)pAtomicVar)); 47 } 48 49 __inline void 50 qatUtilsAtomicSet(int64_t inValue, QatUtilsAtomic *pAtomicVar) 51 { 52 atomic_set((QatUtilsAtomic *)pAtomicVar, inValue); 53 } 54 55 __inline int64_t 56 qatUtilsAtomicAdd(int64_t inValue, QatUtilsAtomic *pAtomicVar) 57 { 58 return atomic_add_return(inValue, (QatUtilsAtomic *)pAtomicVar); 59 } 60 61 __inline int64_t 62 qatUtilsAtomicSub(int64_t inValue, QatUtilsAtomic *pAtomicVar) 63 { 64 return atomic_sub_return(inValue, (QatUtilsAtomic *)pAtomicVar); 65 } 66 67 __inline int64_t 68 qatUtilsAtomicInc(QatUtilsAtomic *pAtomicVar) 69 { 70 return atomic_inc_return((QatUtilsAtomic *)pAtomicVar); 71 } 72 73 __inline int64_t 74 qatUtilsAtomicDec(QatUtilsAtomic *pAtomicVar) 75 { 76 return atomic_dec_return((QatUtilsAtomic *)pAtomicVar); 77 } 78 #endif 79