Clean up some sleep code

This commit is contained in:
Justine Tunney 2022-10-08 02:40:44 -07:00
parent 9849b4c7ba
commit 672ccda37c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
35 changed files with 310 additions and 598 deletions

View file

@ -17,6 +17,8 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/struct/timespec.h"
#include "libc/sysv/consts/clock.h"
#include "libc/sysv/errfuns.h"
#include "libc/time/time.h"
/**
@ -28,7 +30,7 @@
* @norestart
*/
int usleep(uint32_t micros) {
struct timespec ts;
ts = _timespec_frommicros(micros);
return nanosleep(&ts, 0);
struct timespec ts = _timespec_frommicros(micros);
if (clock_nanosleep(CLOCK_REALTIME, 0, &ts, 0)) return eintr();
return 0;
}