File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111#include "core.h"
1212
13+ #if defined(__APPLE__)
14+ #include <mach/mach_time.h>
15+
16+ static uint64_t get_timebase_numer(void) {
17+ mach_timebase_info_data_t info;
18+ mach_timebase_info(&info);
19+ return info.numer;
20+ }
21+
22+ static uint64_t get_timebase_denom(void) {
23+ mach_timebase_info_data_t info;
24+ mach_timebase_info(&info);
25+ return info.denom;
26+ }
27+ #endif
28+
1329struct InstrumentHooks {
1430 uint64_t _unused;
1531};
@@ -66,7 +82,13 @@ void instrument_hooks_set_feature(uint64_t feature, bool enabled) {
6682 (void)enabled;
6783}
6884
69- uint64_t instrument_hooks_current_timestamp(void) { return 0; }
85+ uint64_t instrument_hooks_current_timestamp(void) {
86+ #if defined(__APPLE__)
87+ return mach_absolute_time() * get_timebase_numer() / get_timebase_denom();
88+ #else
89+ return 0;
90+ #endif
91+ }
7092
7193uint8_t instrument_hooks_add_marker(InstrumentHooks *hooks, int32_t pid,
7294 uint8_t marker_type, uint64_t timestamp) {
Original file line number Diff line number Diff line change 33
44#include "core.h"
55
6+ #if defined(__APPLE__ )
7+ #include <mach/mach_time.h>
8+
9+ static uint64_t get_timebase_numer (void ) {
10+ mach_timebase_info_data_t info ;
11+ mach_timebase_info (& info );
12+ return info .numer ;
13+ }
14+
15+ static uint64_t get_timebase_denom (void ) {
16+ mach_timebase_info_data_t info ;
17+ mach_timebase_info (& info );
18+ return info .denom ;
19+ }
20+ #endif
21+
622struct InstrumentHooks {
723 uint64_t _unused ;
824};
@@ -59,7 +75,13 @@ void instrument_hooks_set_feature(uint64_t feature, bool enabled) {
5975 (void )enabled ;
6076}
6177
62- uint64_t instrument_hooks_current_timestamp (void ) { return 0 ; }
78+ uint64_t instrument_hooks_current_timestamp (void ) {
79+ #if defined(__APPLE__ )
80+ return mach_absolute_time () * get_timebase_numer () / get_timebase_denom ();
81+ #else
82+ return 0 ;
83+ #endif
84+ }
6385
6486uint8_t instrument_hooks_add_marker (InstrumentHooks * hooks , int32_t pid ,
6587 uint8_t marker_type , uint64_t timestamp ) {
You can’t perform that action at this time.
0 commit comments