annotate toys/other/usleep.c @ 944:b4faf2ae39e8

This inlines CRC64, and nothing more. The functions involved were called only once.
author Isaac Dunham <idunham@lavabit.com>
date Sat, 06 Jul 2013 11:26:15 -0500
parents 786841fdb1e0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
1 /* usleep.c - Wait for a number of microseconds.
648
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
2 *
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
3 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
4
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
5 USE_USLEEP(NEWTOY(usleep, "<1", TOYFLAG_BIN))
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
6
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
7 config USLEEP
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
8 bool "usleep"
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
9 default y
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
10 help
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
11 usage: usleep MICROSECONDS
648
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
12
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
13 Pause for MICROSECONDS microseconds.
648
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
14 */
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
15
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
16 #include "toys.h"
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
17
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
18 void usleep_main(void)
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
19 {
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
20 struct timespec tv;
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
21 long delay = atol(*toys.optargs);
648
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
22
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
23 tv.tv_sec = delay/1000000;
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
24 tv.tv_nsec = (delay%1000000) * 1000;
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.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
25 toys.exitval = !!nanosleep(&tv, NULL);
648
131571cf708c Adding usleep
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
26 }