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