mirror of
https://github.com/wjwwood/serial.git
synced 2026-01-22 19:54:57 +08:00
fix timeouts handling on Unix systems
fixed "singed long" overflow that took place on attempt to use ~3000ms or bigger timeouts on Unix systems
This commit is contained in:
parent
d76b7d6b7f
commit
3fa0c92456
@ -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