summaryrefslogtreecommitdiff
path: root/src/usleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usleep.c')
-rw-r--r--src/usleep.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/usleep.c b/src/usleep.c
new file mode 100644
index 0000000..9f76bcb
--- /dev/null
+++ b/src/usleep.c
@@ -0,0 +1,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