mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 11:44:53 +08:00
fix timeouts handling on Unix systems (#142)
fixed "singed long" overflow that took place on attempt to use ~3000ms or bigger timeouts on Unix systems
This commit is contained in:
parent
c16faab6ea
commit
4d69fb2e41
@ -62,7 +62,7 @@ MillisecondTimer::MillisecondTimer (const uint32_t millis)
|
||||
int64_t tv_nsec = expiry.tv_nsec + (millis * 1e6);
|
||||
if (tv_nsec >= 1e9) {
|
||||
int64_t sec_diff = tv_nsec / static_cast<int> (1e9);
|
||||
expiry.tv_nsec = tv_nsec - static_cast<int> (1e9 * sec_diff);
|
||||
expiry.tv_nsec %= static_cast<int>(1e9);
|
||||
expiry.tv_sec += sec_diff;
|
||||
} else {
|
||||
expiry.tv_nsec = tv_nsec;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user