summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-30 23:27:19 +0000
committerPete Batard <pbatard@gmail.com>2010-01-30 23:27:19 +0000
commita2773d1edf7c6dba9cb257467ccd8b7840acd2f5 (patch)
treeb1da75f45a33e6659ee40bb2aa6a3e5f4a53c55c
parent76eef888a1925838d59330ddc34956674b89bd7b (diff)
downloadlibusb-a2773d1edf7c6dba9cb257467ccd8b7840acd2f5.tar.gz
r128: additional cygwin fixes for concurrency
-rw-r--r--libusb/os/windows_usb.c4
-rw-r--r--libusb/os/windows_usb.h2
2 files changed, 4 insertions, 2 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 1b71c42..7719d01 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -363,7 +363,7 @@ static int windows_init(struct libusb_context *ctx)
struct windows_hcd_priv** _hcd_cur;
TCHAR sem_name[11+1+8]; // strlen(libusb_init)+'\0'+(32-bit hex PID)
- sprintf(sem_name, "libusb_init%08X", GetCurrentProcessId()&0xFFFFFFFF);
+ sprintf(sem_name, "libusb_init%08X", (unsigned int)GetCurrentProcessId()&0xFFFFFFFF);
semaphore = CreateSemaphore(NULL, 1, 1, sem_name);
if (semaphore == NULL) {
usbi_err(ctx, "could not create semaphore: %s", windows_error_str(0));
@@ -1403,7 +1403,7 @@ static void windows_exit(void)
HANDLE semaphore;
TCHAR sem_name[11+1+8]; // strlen(libusb_init)+'\0'+(32-bit hex PID)
- sprintf(sem_name, "libusb_init%08X", GetCurrentProcessId()&0xFFFFFFFF);
+ sprintf(sem_name, "libusb_init%08X", (unsigned int)GetCurrentProcessId()&0xFFFFFFFF);
semaphore = CreateSemaphore(NULL, 1, 1, sem_name);
if (semaphore == NULL) {
return;
diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h
index e2801db..3f1d121 100644
--- a/libusb/os/windows_usb.h
+++ b/libusb/os/windows_usb.h
@@ -49,6 +49,8 @@
// cygwin produces a warning unless these prototypes are defined
extern int _snprintf(char *buffer, size_t count, const char *format, ...);
extern char *_strdup(const char *strSource);
+// _beginthreadex is MSVCRT => unavailable for cygwin. Fallback to using CreateThread
+#define _beginthreadex(a, b, c, d, e, f) CreateThread(a, b, (LPTHREAD_START_ROUTINE)c, d, e, f)
#endif
#define safe_free(p) do {if (p != NULL) {free(p); p = NULL;}} while(0)
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)