xref: /dpdk/lib/eal/ppc/include/rte_cycles.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * Copyright (C) IBM Corporation 2014.
4  */
5 
6 #ifndef _RTE_CYCLES_PPC_64_H_
7 #define _RTE_CYCLES_PPC_64_H_
8 
9 #include <features.h>
10 #ifdef __GLIBC__
11 #include <sys/platform/ppc.h>
12 #endif
13 
14 #include "generic/rte_cycles.h"
15 
16 #include <rte_byteorder.h>
17 #include <rte_common.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * Read the time base register.
25  *
26  * @return
27  *   The time base for this lcore.
28  */
29 static inline uint64_t
30 rte_rdtsc(void)
31 {
32 #ifdef __GLIBC__
33 	return __ppc_get_timebase();
34 #else
35 	return __builtin_ppc_get_timebase();
36 #endif
37 }
38 
39 static inline uint64_t
40 rte_rdtsc_precise(void)
41 {
42 	rte_mb();
43 	return rte_rdtsc();
44 }
45 
46 static inline uint64_t
47 rte_get_tsc_cycles(void) { return rte_rdtsc(); }
48 
49 #ifdef __cplusplus
50 }
51 #endif
52 
53 #endif /* _RTE_CYCLES_PPC_64_H_ */
54