xref: /third_party/toybox/toys/other/usleep.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/toybox/toys/other/
10f66f451Sopenharmony_ci/* usleep.c - Wait for a number of microseconds.
20f66f451Sopenharmony_ci *
30f66f451Sopenharmony_ci * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
40f66f451Sopenharmony_ci
50f66f451Sopenharmony_ciUSE_USLEEP(NEWTOY(usleep, "<1", TOYFLAG_BIN))
60f66f451Sopenharmony_ci
70f66f451Sopenharmony_ciconfig USLEEP
80f66f451Sopenharmony_ci  bool "usleep"
90f66f451Sopenharmony_ci  default y
100f66f451Sopenharmony_ci  help
110f66f451Sopenharmony_ci    usage: usleep MICROSECONDS
120f66f451Sopenharmony_ci
130f66f451Sopenharmony_ci    Pause for MICROSECONDS microseconds.
140f66f451Sopenharmony_ci*/
150f66f451Sopenharmony_ci
160f66f451Sopenharmony_ci#include "toys.h"
170f66f451Sopenharmony_ci
180f66f451Sopenharmony_civoid usleep_main(void)
190f66f451Sopenharmony_ci{
200f66f451Sopenharmony_ci  struct timespec tv;
210f66f451Sopenharmony_ci  long delay = atol(*toys.optargs);
220f66f451Sopenharmony_ci
230f66f451Sopenharmony_ci  tv.tv_sec = delay/1000000;
240f66f451Sopenharmony_ci  tv.tv_nsec = (delay%1000000) * 1000;
250f66f451Sopenharmony_ci  toys.exitval = !!nanosleep(&tv, NULL);
260f66f451Sopenharmony_ci}
27

Indexes created Thu Nov 07 10:32:03 CST 2024