Created
May 3, 2017 18:03
-
-
Save bitsmanent/7dda96e85c6c733a74191ada7805cd6a to your computer and use it in GitHub Desktop.
POSIX compliant replacement for usleep(2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int | |
| sleepu(double usec) { | |
| struct timespec req, rem; | |
| int r; | |
| req.tv_sec = 0; | |
| req.tv_nsec = usec * 1000; | |
| while((r = nanosleep(&req, &rem)) == -1 && errno == EINTR) | |
| req = rem; | |
| return r; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment