mirror of
https://github.com/ckb-next/ckb-next.git
synced 2026-10-10 12:27:21 -04:00
Fix timespec_add overflow
This commit is contained in:
@@ -59,7 +59,7 @@ typedef unsigned int uint;
|
||||
#define ckb_info(fmt, args...) fprintf(ckb_s_out, "[I] " fmt "\n", ## args)
|
||||
|
||||
// Timespec utilities
|
||||
void timespec_add(struct timespec* timespec, long nanoseconds);
|
||||
void timespec_add(struct timespec* timespec, int64_t nanoseconds);
|
||||
#define timespec_gt(left, right) ((left).tv_sec > (right).tv_sec || ((left).tv_sec == (right).tv_sec && (left).tv_nsec > (right).tv_nsec))
|
||||
#define timespec_eq(left, right) ((left).tv_sec == (right).tv_sec && (left).tv_nsec == (right).tv_nsec)
|
||||
#define timespec_ge(left, right) ((left).tv_sec > (right).tv_sec || ((left).tv_sec == (right).tv_sec && (left).tv_nsec >= (right).tv_nsec))
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ extern int hwload_mode;
|
||||
int sighandler_pipe[2] = { 0, 0 };
|
||||
|
||||
// Timespec utility function
|
||||
void timespec_add(struct timespec* timespec, long nanoseconds){
|
||||
void timespec_add(struct timespec* timespec, int64_t nanoseconds){
|
||||
nanoseconds += timespec->tv_nsec;
|
||||
timespec->tv_sec += nanoseconds / 1000000000;
|
||||
timespec->tv_nsec = nanoseconds % 1000000000;
|
||||
|
||||
Reference in New Issue
Block a user