Skip to content

Commit 52a46e4

Browse files
riptlripatel-fd
authored andcommitted
Permit fd_tickcount stutter
Support slow clocks, such as Arm cntvct_el0, by allowing back to back fd_tickcount() calls to return the same value.
1 parent 89e6b43 commit 52a46e4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/util/clock/fd_clock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,11 @@ fd_clock_joint_read( fd_clock_func_t clock_x, void const * args_x,
355355
x[ FD_CLOCK_JOINT_READ_CNT ] = clock_x( args_x );
356356

357357
ulong best_idx = 0UL;
358-
long best_dx = x[1] - x[0]; if( FD_UNLIKELY( best_dx<=0L ) ) return FD_CLOCK_ERR_X;
358+
long best_dx = x[1] - x[0]; if( FD_UNLIKELY( best_dx<0L ) ) return FD_CLOCK_ERR_X;
359359

360360
for( ulong idx=1UL; idx<FD_CLOCK_JOINT_READ_CNT; idx++ ) {
361-
long dy = y[ idx ] - y[ idx-1UL ]; if( FD_UNLIKELY( dy<=0L ) ) return FD_CLOCK_ERR_Y;
362-
long dx = x[ idx+1UL ] - x[ idx ]; if( FD_UNLIKELY( dx<=0L ) ) return FD_CLOCK_ERR_X;
361+
long dy = y[ idx ] - y[ idx-1UL ]; if( FD_UNLIKELY( dy<0L ) ) return FD_CLOCK_ERR_Y;
362+
long dx = x[ idx+1UL ] - x[ idx ]; if( FD_UNLIKELY( dx<0L ) ) return FD_CLOCK_ERR_X;
363363
best_idx = fd_ulong_if( best_dx<dx, best_idx, idx );
364364
best_dx = fd_long_min( best_dx, dx );
365365
}

src/util/clock/test_clock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ main( int argc,
131131

132132
init_w = (double)(init_x1-init_x0) / (double)(init_y1-init_y0);
133133

134-
FD_LOG_NOTICE(( "Joint read 1 (x %li ticks, y %li ns, dx %li ticks) w %e GHz", init_x1, init_y1, init_dx, init_w ));
134+
FD_LOG_NOTICE(( "Joint read 1 (x %li ticks, y %li ns, dx %li ticks) w %e MHz", init_x1, init_y1, init_dx, init_w*1e3 ));
135135

136136
FD_LOG_NOTICE(( "Creating clock" ));
137137

src/util/test_util_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ main( int argc,
425425
long tic = fd_tickcount();
426426
for( ulong iter=0UL; iter<1000000UL; iter++ ) {
427427
long toc = fd_tickcount();
428-
FD_TEST( (toc - tic) > 0L );
428+
FD_TEST( (toc - tic) >= 0L );
429429
tic = toc;
430430
}
431431

0 commit comments

Comments
 (0)