summaryrefslogtreecommitdiff
path: root/libusb/io.c
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-14 01:34:40 +0000
committerPete Batard <pbatard@gmail.com>2010-01-14 01:34:40 +0000
commit71613013b9e7329b4e49047abdee40fea718eb96 (patch)
treeb8181552af39d2bef19b73fe232da34912eac918 /libusb/io.c
parenta32c101a47825f3c523081137d972a619a359d34 (diff)
downloadlibusb-71613013b9e7329b4e49047abdee40fea718eb96.tar.gz
svn r54: - fixes missing config_msvc.h
Diffstat (limited to 'libusb/io.c')
-rw-r--r--libusb/io.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/libusb/io.c b/libusb/io.c
index ffc0015..2e59f72 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -18,20 +18,28 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifdef _MSC_VER
+#include <config_msvc.h>
+#else
#include <config.h>
+#endif
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#if defined(_MSC_VER)
+#include <time.h>
+#else
#include <sys/time.h>
+#endif
#include <time.h>
-#include <unistd.h>
#ifdef OS_WINDOWS
#include <windows.h>
#include "os/windows_compat.h"
#else
+#include <unistd.h>
#include <poll.h>
#define write_for_poll write
#define read_for_poll read
@@ -1114,7 +1122,7 @@ static int add_to_flying_list(struct usbi_transfer *transfer)
}
/* otherwise, find appropriate place in list */
- list_for_each_entry(cur, &ctx->flying_transfers, list) {
+ list_for_each_entry(cur, &ctx->flying_transfers, list, struct usbi_transfer) {
/* find first timeout that occurs after the transfer in question */
struct timeval *cur_tv = &cur->timeout;
@@ -1714,7 +1722,7 @@ static int handle_timeouts_locked(struct libusb_context *ctx)
/* iterate through flying transfers list, finding all transfers that
* have expired timeouts */
- list_for_each_entry(transfer, &ctx->flying_transfers, list) {
+ list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
struct timeval *cur_tv = &transfer->timeout;
/* if we've reached transfers of infinite timeout, we're all done */
@@ -1785,7 +1793,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
int timeout_ms;
pthread_mutex_lock(&ctx->pollfds_lock);
- list_for_each_entry(ipollfd, &ctx->pollfds, list)
+ list_for_each_entry(ipollfd, &ctx->pollfds, list, struct usbi_pollfd)
nfds++;
/* TODO: malloc when number of fd's changes, not on every poll */
@@ -1793,7 +1801,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
if (!fds)
return LIBUSB_ERROR_NO_MEM;
- list_for_each_entry(ipollfd, &ctx->pollfds, list) {
+ list_for_each_entry(ipollfd, &ctx->pollfds, list, struct usbi_pollfd) {
struct libusb_pollfd *pollfd = &ipollfd->pollfd;
int fd = pollfd->fd;
i++;
@@ -2107,7 +2115,7 @@ API_EXPORTED int libusb_get_next_timeout(libusb_context *ctx,
}
/* find next transfer which hasn't already been processed as timed out */
- list_for_each_entry(transfer, &ctx->flying_transfers, list) {
+ list_for_each_entry(transfer, &ctx->flying_transfers, list, struct usbi_transfer) {
if (!(transfer->flags & USBI_TRANSFER_TIMED_OUT)) {
found = 1;
break;
@@ -2209,7 +2217,7 @@ void usbi_remove_pollfd(struct libusb_context *ctx, int fd)
usbi_dbg("remove fd %d", fd);
pthread_mutex_lock(&ctx->pollfds_lock);
- list_for_each_entry(ipollfd, &ctx->pollfds, list)
+ list_for_each_entry(ipollfd, &ctx->pollfds, list, struct usbi_pollfd)
if (ipollfd->pollfd.fd == fd) {
found = 1;
break;
@@ -2249,14 +2257,14 @@ API_EXPORTED const struct libusb_pollfd **libusb_get_pollfds(
USBI_GET_CONTEXT(ctx);
pthread_mutex_lock(&ctx->pollfds_lock);
- list_for_each_entry(ipollfd, &ctx->pollfds, list)
+ list_for_each_entry(ipollfd, &ctx->pollfds, list, struct usbi_pollfd)
cnt++;
ret = calloc(cnt + 1, sizeof(struct libusb_pollfd *));
if (!ret)
goto out;
- list_for_each_entry(ipollfd, &ctx->pollfds, list)
+ list_for_each_entry(ipollfd, &ctx->pollfds, list, struct usbi_pollfd)
ret[i++] = (struct libusb_pollfd *) ipollfd;
ret[cnt] = NULL;
@@ -2292,7 +2300,7 @@ void usbi_handle_disconnect(struct libusb_device_handle *handle)
while (1) {
pthread_mutex_lock(&HANDLE_CTX(handle)->flying_transfers_lock);
to_cancel = NULL;
- list_for_each_entry(cur, &HANDLE_CTX(handle)->flying_transfers, list)
+ list_for_each_entry(cur, &HANDLE_CTX(handle)->flying_transfers, list, struct usbi_transfer)
if (__USBI_TRANSFER_TO_LIBUSB_TRANSFER(cur)->dev_handle == handle) {
to_cancel = cur;
break;