+#ifdef _WIN32
+SR_PRIV gpointer usb_thread(gpointer data)
+{
+ struct sr_context *ctx = data;
+
+ while (ctx->usb_thread_running) {
+ g_mutex_lock(&ctx->usb_mutex);
+ libusb_wait_for_event(ctx->libusb_ctx, NULL);
+ SetEvent(ctx->usb_event);
+ g_mutex_unlock(&ctx->usb_mutex);
+ g_thread_yield();
+ }
+
+ return NULL;
+}
+
+SR_PRIV int usb_callback(int fd, int revents, void *cb_data)
+{
+ struct sr_context *ctx = cb_data;
+ int ret;
+
+ g_mutex_lock(&ctx->usb_mutex);
+ ret = ctx->usb_cb(fd, revents, ctx->usb_cb_data);
+
+ if (ctx->usb_thread_running) {
+ ResetEvent(ctx->usb_event);
+ g_mutex_unlock(&ctx->usb_mutex);
+ }
+
+ return ret;
+}
+#endif
+