eal: move arch-specific C files
[dpdk.git] / lib / librte_eal / common / include / arch / ppc_64 / rte_spinlock.h
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * Copyright (C) IBM Corporation 2014.
4  */
5
6 #ifndef _RTE_SPINLOCK_PPC_64_H_
7 #define _RTE_SPINLOCK_PPC_64_H_
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 #include <rte_common.h>
14 #include <rte_pause.h>
15 #include "generic/rte_spinlock.h"
16
17 /* Fixme: Use intrinsics to implement the spinlock on Power architecture */
18
19 #ifndef RTE_FORCE_INTRINSICS
20
21 static inline void
22 rte_spinlock_lock(rte_spinlock_t *sl)
23 {
24         while (__sync_lock_test_and_set(&sl->locked, 1))
25                 while (sl->locked)
26                         rte_pause();
27 }
28
29 static inline void
30 rte_spinlock_unlock(rte_spinlock_t *sl)
31 {
32         __sync_lock_release(&sl->locked);
33 }
34
35 static inline int
36 rte_spinlock_trylock(rte_spinlock_t *sl)
37 {
38         return __sync_lock_test_and_set(&sl->locked, 1) == 0;
39 }
40
41 #endif
42
43 static inline int rte_tm_supported(void)
44 {
45         return 0;
46 }
47
48 static inline void
49 rte_spinlock_lock_tm(rte_spinlock_t *sl)
50 {
51         rte_spinlock_lock(sl); /* fall-back */
52 }
53
54 static inline int
55 rte_spinlock_trylock_tm(rte_spinlock_t *sl)
56 {
57         return rte_spinlock_trylock(sl);
58 }
59
60 static inline void
61 rte_spinlock_unlock_tm(rte_spinlock_t *sl)
62 {
63         rte_spinlock_unlock(sl);
64 }
65
66 static inline void
67 rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr)
68 {
69         rte_spinlock_recursive_lock(slr); /* fall-back */
70 }
71
72 static inline void
73 rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr)
74 {
75         rte_spinlock_recursive_unlock(slr);
76 }
77
78 static inline int
79 rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr)
80 {
81         return rte_spinlock_recursive_trylock(slr);
82 }
83
84 #ifdef __cplusplus
85 }
86 #endif
87
88 #endif /* _RTE_SPINLOCK_PPC_64_H_ */