-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflycore.c
38 lines (34 loc) · 814 Bytes
/
flycore.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "flycore.h"
#include <sys/time.h>
#include <sys/select.h>
#include <time.h>
#include <stdio.h>
/*seconds: the seconds; mseconds: the micro seconds*/
void flymsleep(unsigned long msec){
struct timeval tv;
tv.tv_sec=msec/1000;
tv.tv_usec=(msec%1000)*1000;
int err;
do{
err=select(0,NULL,NULL,NULL,&tv);
}while(err<0 && errno==EINTR);
}
void flyusleep(unsigned long usec){
struct timeval tv;
tv.tv_sec=usec/1000000;
tv.tv_usec=usec%1000000;
int err;
do{
err=select(0,NULL,NULL,NULL,&tv);
}while(err<0 && errno==EINTR);
}
void flysleep(unsigned long sec,unsigned long usec)
{
struct timeval tv;
tv.tv_sec = sec;
tv.tv_usec= usec;
int err;
do{
err=select(0,NULL,NULL,NULL,&tv);
}while(err<0 && errno==EINTR);
}