2 * SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (C) IBM Corporation 2014.
6 #ifndef _RTE_SPINLOCK_PPC_64_H_
7 #define _RTE_SPINLOCK_PPC_64_H_
13 #include <rte_common.h>
14 #include <rte_pause.h>
15 #include "generic/rte_spinlock.h"
17 /* Fixme: Use intrinsics to implement the spinlock on Power architecture */
19 #ifndef RTE_FORCE_INTRINSICS
22 rte_spinlock_lock(rte_spinlock_t *sl)
24 while (__sync_lock_test_and_set(&sl->locked, 1))
30 rte_spinlock_unlock(rte_spinlock_t *sl)
32 __sync_lock_release(&sl->locked);
36 rte_spinlock_trylock(rte_spinlock_t *sl)
38 return __sync_lock_test_and_set(&sl->locked, 1) == 0;
43 static inline int rte_tm_supported(void)
49 rte_spinlock_lock_tm(rte_spinlock_t *sl)
51 rte_spinlock_lock(sl); /* fall-back */
55 rte_spinlock_trylock_tm(rte_spinlock_t *sl)
57 return rte_spinlock_trylock(sl);
61 rte_spinlock_unlock_tm(rte_spinlock_t *sl)
63 rte_spinlock_unlock(sl);
67 rte_spinlock_recursive_lock_tm(rte_spinlock_recursive_t *slr)
69 rte_spinlock_recursive_lock(slr); /* fall-back */
73 rte_spinlock_recursive_unlock_tm(rte_spinlock_recursive_t *slr)
75 rte_spinlock_recursive_unlock(slr);
79 rte_spinlock_recursive_trylock_tm(rte_spinlock_recursive_t *slr)
81 return rte_spinlock_recursive_trylock(slr);
88 #endif /* _RTE_SPINLOCK_PPC_64_H_ */