Make OS::delay_usec() more reliable on UNIX

Implemented with `nanosleep()`. `usleep()` is deprecated.
Also loops to ensure that __at least__ the requested time is waited, accounting for spurious interruptions.

May help in situations like reattempting to connect to the debugger.
This commit is contained in:
Pedro J. Estébanez 2017-08-22 18:02:12 +02:00
parent b4ad899ef6
commit a560a62118

View File

@ -315,7 +315,9 @@ OS::TimeZoneInfo OS_Unix::get_time_zone_info() const {
void OS_Unix::delay_usec(uint32_t p_usec) const { void OS_Unix::delay_usec(uint32_t p_usec) const {
usleep(p_usec); struct timespec rem = { p_usec / 1000000, (p_usec % 1000000) * 1000 };
while (nanosleep(&rem, &rem) == EINTR) {
}
} }
uint64_t OS_Unix::get_ticks_usec() const { uint64_t OS_Unix::get_ticks_usec() const {