forked from lorf/csr-spi-ftdi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompat.c
34 lines (27 loc) · 992 Bytes
/
compat.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
#ifdef COMPAT_USLEEP
/*
* http://stackoverflow.com/questions/5801813/c-usleep-is-obsolete-workarounds-for-windows-mingw
*/
#include <windows.h>
#include <stdint.h>
void usleep(int64_t usec)
{
HANDLE timer;
LARGE_INTEGER ft;
ft.QuadPart = -(10*usec); /* Convert to 100 nanosecond interval, negative value indicates relative time */
timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
}
#endif /* COMPAT_USLEEP */
#ifdef COMPAT_MINGW_MS_VSNPRINTF
/*
* This fixes linking with precompiled libusb-1.0.18-win and
* libusb-1.0.19-rc1-win: "undefined reference to __ms_vsnprintf". See:
* http://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/[email protected]/
*/
#include <stdio.h>
#include <stdarg.h>
int (*__ms_vsnprintf)(char *, size_t, const char *, va_list) = &vsnprintf;
#endif /* COMPAT_MINGW_MS_VSNPRINTF */