2018-08-15 04:07:33 +03:00
|
|
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
|
|
|
* This file is part of ToaruOS and is released under the terms
|
2018-05-04 07:01:55 +03:00
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
|
|
|
* Copyright (C) 2013 K. Lange
|
2018-08-15 04:07:33 +03:00
|
|
|
*
|
|
|
|
* sleep - Do nothing, efficiently.
|
2018-05-04 07:01:55 +03:00
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <syscall.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
|
|
|
int ret = 0;
|
|
|
|
|
2020-12-16 04:15:03 +03:00
|
|
|
if (argc < 2) {
|
|
|
|
fprintf(stderr, "%s: missing operand\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-05-04 07:01:55 +03:00
|
|
|
char * arg = strdup(argv[1]);
|
|
|
|
|
|
|
|
float time = atof(arg);
|
|
|
|
|
|
|
|
unsigned int seconds = (unsigned int)time;
|
|
|
|
unsigned int subsecs = (unsigned int)((time - (float)seconds) * 100);
|
|
|
|
|
2021-05-31 04:47:02 +03:00
|
|
|
ret = syscall_sleep(seconds, subsecs);
|
2018-05-04 07:01:55 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|