blob: ff7fe88bbea45f9428ffcb53d2109935634be03d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/* vi: set sw=4 ts=4:
*
* usleep.c - Wait for a number of microseconds.
*
* Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
USE_USLEEP(NEWTOY(usleep, "<1", TOYFLAG_BIN))
config USLEEP
bool "usleep"
default y
help
usage: usleep MICROSECONDS
Pause for MICROSECONDS microseconds.
*/
#include "toys.h"
void usleep_main(void)
{
struct timespec tv;
long delay = atol(*toys.optargs);
tv.tv_sec = delay/1000000;
tv.tv_nsec = (delay%1000000) * 1000;
toys.exitval = !!nanosleep(&tv, NULL);
}
|