Blog
Community
Development
Documentation
CNDP
22.08.0
cne_cycles.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2019-2022 Intel Corporation.
3
* Copyright (c) 2013 6WIND S.A.
4
*/
5
6
#ifndef _CNE_CYCLES_H_
7
#define _CNE_CYCLES_H_
8
13
#include <
cne_atomic.h
>
14
15
#include <
cne_common.h
>
16
17
#ifdef __cplusplus
18
extern
"C"
{
19
#endif
20
21
#define MS_PER_S 1000
22
#define US_PER_S 1000000
23
#define NS_PER_S 1000000000
24
31
static
inline
uint64_t
32
cne_rdtsc
(
void
)
33
{
34
union
{
35
uint64_t tsc_64;
36
CNE_STD_C11
37
struct
{
38
uint32_t lo_32;
39
uint32_t hi_32;
40
};
41
} tsc;
42
43
// clang-format off
44
asm
volatile
(
"rdtsc"
:
45
"=a"
(tsc.lo_32),
46
"=d"
(tsc.hi_32));
47
// clang-format on
48
return
tsc.tsc_64;
49
}
50
57
static
inline
uint64_t
58
cne_rdtsc_precise
(
void
)
59
{
60
atomic_thread_fence(CNE_MEMORY_ORDER(release));
61
return
cne_rdtsc
();
62
}
63
64
#ifdef __cplusplus
65
}
66
#endif
67
68
#endif
/* _CNE_CYCLES_H_ */
cne_atomic.h
cne_common.h
CNE_STD_C11
#define CNE_STD_C11
Definition:
cne_common.h:91
cne_rdtsc_precise
static uint64_t cne_rdtsc_precise(void)
Definition:
cne_cycles.h:58
cne_rdtsc
static uint64_t cne_rdtsc(void)
Definition:
cne_cycles.h:32
lib
include
cne_cycles.h
Generated by
1.9.1