Merge pull request #42740 from lolleko/fix-nanosleep-usage

Fix nanosleep usage
This commit is contained in:
Rémi Verschelde 2021-01-11 14:42:10 +01:00 committed by GitHub
commit f414a323b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -234,8 +234,11 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const {
}
void OS_Unix::delay_usec(uint32_t p_usec) const {
struct timespec rem = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 };
while (nanosleep(&rem, &rem) == EINTR) {
struct timespec requested = { static_cast<time_t>(p_usec / 1000000), (static_cast<long>(p_usec) % 1000000) * 1000 };
struct timespec remaining;
while (nanosleep(&requested, &remaining) == -1 && errno == EINTR) {
requested.tv_sec = remaining.tv_sec;
requested.tv_nsec = remaining.tv_nsec;
}
}