Allow users to implement shorter delays than a full second by implementing msleep().
Unified · Split
| @@ -2243,6 +2243,19 @@ unsigned int sleep(unsigned int seconds) · 2242 unmodified lines | |||
| 2243 | return 0; | 2243 | return 0; |
| 2244 | } | 2244 | } |
| 2245 | 2245 | ||
| 2246 | static __attribute__((unused)) | ||
| 2247 | int msleep(unsigned int msecs) | ||
| 2248 | { | ||
| 2249 | struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 }; | ||
| 2250 | |||
| 2251 | if (sys_select(0, 0, 0, 0, &my_timeval) < 0) | ||
| 2252 | return (my_timeval.tv_sec * 1000) + | ||
| 2253 | (my_timeval.tv_usec / 1000) + | ||
| 2254 | !!(my_timeval.tv_usec % 1000); | ||
| 2255 | else | ||
| 2256 | return 0; | ||
| 2257 | } | ||
| 2258 | |||
| 2246 | static __attribute__((unused)) | 2259 | static __attribute__((unused)) |
| 2247 | int stat(const char *path, struct stat *buf) | 2260 | int stat(const char *path, struct stat *buf) |
| 2248 | { | 2261 | { |