32 lines
348 B
C
32 lines
348 B
C
|
#include <stdlib.h>
|
||
|
#include <sys/time.h>
|
||
|
|
||
|
|
||
|
long usecs (){
|
||
|
struct timeval t;
|
||
|
|
||
|
gettimeofday(&t,NULL);
|
||
|
return t.tv_sec*1000000+t.tv_usec;
|
||
|
}
|
||
|
|
||
|
|
||
|
void mysleep(double sec){
|
||
|
|
||
|
long s, e;
|
||
|
s=0; e=0;
|
||
|
s = usecs();
|
||
|
while(((double) e-s)/1000000 < sec)
|
||
|
{
|
||
|
e = usecs();
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
int func(){
|
||
|
mysleep(0.0000001);
|
||
|
return 1;
|
||
|
}
|
||
|
|