sleep.c 612 B

123456789101112131415161718192021222324252627
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2013 K. Lange
  5. *
  6. * sleep - Do nothing, efficiently.
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <syscall.h>
  11. #include <string.h>
  12. int main(int argc, char ** argv) {
  13. int ret = 0;
  14. char * arg = strdup(argv[1]);
  15. float time = atof(arg);
  16. unsigned int seconds = (unsigned int)time;
  17. unsigned int subsecs = (unsigned int)((time - (float)seconds) * 100);
  18. ret = syscall_nanosleep(seconds, subsecs);
  19. return ret;
  20. }