Merge pull request #75 from ros2/fix_time_arm32
Avoid overflow on 32-bit machines when working with large ns values
This commit is contained in:
commit
0abda63db3
1 changed files with 2 additions and 2 deletions
|
@ -66,7 +66,7 @@ rcl_system_time_now(rcl_time_point_value_t * now)
|
||||||
RCL_SET_ERROR_MSG("unexpected negative time");
|
RCL_SET_ERROR_MSG("unexpected negative time");
|
||||||
return RCL_RET_ERROR;
|
return RCL_RET_ERROR;
|
||||||
}
|
}
|
||||||
*now = RCL_S_TO_NS(timespec_now.tv_sec) + timespec_now.tv_nsec;
|
*now = RCL_S_TO_NS((uint64_t)timespec_now.tv_sec) + timespec_now.tv_nsec;
|
||||||
return RCL_RET_OK;
|
return RCL_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ rcl_steady_time_now(rcl_time_point_value_t * now)
|
||||||
RCL_SET_ERROR_MSG("unexpected negative time");
|
RCL_SET_ERROR_MSG("unexpected negative time");
|
||||||
return RCL_RET_ERROR;
|
return RCL_RET_ERROR;
|
||||||
}
|
}
|
||||||
*now = RCL_S_TO_NS(timespec_now.tv_sec) + timespec_now.tv_nsec;
|
*now = RCL_S_TO_NS((uint64_t)timespec_now.tv_sec) + timespec_now.tv_nsec;
|
||||||
return RCL_RET_OK;
|
return RCL_RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue