mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Moved delay mechanism into separate function
This commit is contained in:
parent
14fc053e8b
commit
13a8bc7790
3 changed files with 13 additions and 8 deletions
11
src/time.c
11
src/time.c
|
|
@ -23,6 +23,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "tio/error.h"
|
||||
#include "tio/print.h"
|
||||
|
||||
char * current_time(void)
|
||||
{
|
||||
|
|
@ -42,3 +43,13 @@ char * current_time(void)
|
|||
|
||||
return time_string;
|
||||
}
|
||||
|
||||
void delay(long ms)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
ts.tv_sec = ms / 1000;
|
||||
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue