Mercurial > hg > toybox
comparison toys/other/usleep.c @ 694:786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 13 Nov 2012 17:14:08 -0600 |
parents | 6df4ccc0acbe |
children |
comparison
equal
deleted
inserted
replaced
693:4a5a250e0633 | 694:786841fdb1e0 |
---|---|
1 /* vi: set sw=4 ts=4: | 1 /* usleep.c - Wait for a number of microseconds. |
2 * | |
3 * usleep.c - Wait for a number of microseconds. | |
4 * | 2 * |
5 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> | 3 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> |
6 | 4 |
7 USE_USLEEP(NEWTOY(usleep, "<1", TOYFLAG_BIN)) | 5 USE_USLEEP(NEWTOY(usleep, "<1", TOYFLAG_BIN)) |
8 | 6 |
9 config USLEEP | 7 config USLEEP |
10 bool "usleep" | 8 bool "usleep" |
11 default y | 9 default y |
12 help | 10 help |
13 usage: usleep MICROSECONDS | 11 usage: usleep MICROSECONDS |
14 | 12 |
15 Pause for MICROSECONDS microseconds. | 13 Pause for MICROSECONDS microseconds. |
16 | |
17 */ | 14 */ |
18 | 15 |
19 #include "toys.h" | 16 #include "toys.h" |
20 | 17 |
21 void usleep_main(void) | 18 void usleep_main(void) |
22 { | 19 { |
23 struct timespec tv; | 20 struct timespec tv; |
24 long delay = atol(*toys.optargs); | 21 long delay = atol(*toys.optargs); |
25 | |
26 tv.tv_sec = delay/1000000; | |
27 tv.tv_nsec = (delay%1000000) * 1000; | |
28 toys.exitval = !!nanosleep(&tv, NULL); | |
29 | 22 |
23 tv.tv_sec = delay/1000000; | |
24 tv.tv_nsec = (delay%1000000) * 1000; | |
25 toys.exitval = !!nanosleep(&tv, NULL); | |
30 } | 26 } |