summaryrefslogtreecommitdiff
path: root/src/usleep.c
blob: 9f76bcb34e64f9825e32d48608fe95936fc83fcd (plain)
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
#include <windows.h>
#include <errno.h>

void usleep(unsigned long usec)
{
    int msec;

    msec=usec/1000;
    usec=usec%1000;    
    
    if(msec)
    {
	if(usec)
	    msec++;
    }
    else
    {
	LARGE_INTEGER current,freq,end;
	
	QueryPerformanceFrequency(&freq);
	QueryPerformanceCounter(&end);
	
	end.QuadPart+=(freq.QuadPart*usec)/1000000;
	while(QueryPerformanceCounter(&current) && (current.QuadPart<=end.QuadPart))
	{
	}	
    }
	
    Sleep(msec);
}
personal git repositories of Harald Welte. Your mileage may vary