diff options
author | Pete Batard <pbatard@gmail.com> | 2010-01-28 23:18:52 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-01-28 23:18:52 +0000 |
commit | 47c83183c080c866c54bcf886e535ff7db907bb8 (patch) | |
tree | bdc1368e54dd601ec679f392e843a6700c4684f9 /libusb | |
parent | 37b685c3558513e32b30418c9fbc057d83a7ff53 (diff) | |
download | libusb-47c83183c080c866c54bcf886e535ff7db907bb8.tar.gz |
r122: fixed poll conflict on cygwin (all compat functions renamed to _libusb_####)
- fixed sscanf_s undefined for non MS compilers
- fixed cygiwn warnings in windows_usb.c
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/core.c | 17 | ||||
-rw-r--r-- | libusb/io.c | 19 | ||||
-rw-r--r-- | libusb/os/windows_compat.c | 10 | ||||
-rw-r--r-- | libusb/os/windows_compat.h | 10 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 7 |
5 files changed, 31 insertions, 32 deletions
diff --git a/libusb/core.c b/libusb/core.c index 1eb4f80..013bc77 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -35,10 +35,11 @@ #else #include <unistd.h> #include <poll.h> -#define write_for_poll write -#define read_for_poll read -#define close_for_poll close -#define pipe_for_poll pipe +#define _libusb_write write +#define _libusb_read read +#define _libusb_close close +#define _libusb_pipe pipe +#define _libusb_poll poll #endif #include "libusb.h" @@ -919,7 +920,7 @@ API_EXPORTED int libusb_open(libusb_device *dev, libusb_device_handle **handle) pthread_mutex_unlock(&ctx->pollfd_modify_lock); /* write some data on control pipe to interrupt event handlers */ - r = write_for_poll(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + r = _libusb_write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); if (r <= 0) { usbi_warn(ctx, "internal signalling write failed"); pthread_mutex_lock(&ctx->pollfd_modify_lock); @@ -932,7 +933,7 @@ API_EXPORTED int libusb_open(libusb_device *dev, libusb_device_handle **handle) libusb_lock_events(ctx); /* read the dummy data */ - r = read_for_poll(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); + r = _libusb_read(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); if (r <= 0) usbi_warn(ctx, "internal signalling read failed"); @@ -1046,7 +1047,7 @@ API_EXPORTED void libusb_close(libusb_device_handle *dev_handle) pthread_mutex_unlock(&ctx->pollfd_modify_lock); /* write some data on control pipe to interrupt event handlers */ - r = write_for_poll(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + r = _libusb_write(ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); if (r <= 0) { usbi_warn(ctx, "internal signalling write failed, closing anyway"); do_close(ctx, dev_handle); @@ -1060,7 +1061,7 @@ API_EXPORTED void libusb_close(libusb_device_handle *dev_handle) libusb_lock_events(ctx); /* read the dummy data */ - r = read_for_poll(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); + r = _libusb_read(ctx->ctrl_pipe[0], &dummy, sizeof(dummy)); if (r <= 0) usbi_warn(ctx, "internal signalling read failed, closing anyway"); diff --git a/libusb/io.c b/libusb/io.c index c93b074..69c52c4 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -41,10 +41,11 @@ #else #include <unistd.h> #include <poll.h> -#define write_for_poll write -#define read_for_poll read -#define close_for_poll close -#define pipe_for_poll pipe +#define _libusb_write write +#define _libusb_read read +#define _libusb_close close +#define _libusb_pipe pipe +#define _libusb_poll poll #endif #ifdef USBI_TIMERFD_AVAILABLE @@ -1027,7 +1028,7 @@ int usbi_io_init(struct libusb_context *ctx) list_init(&ctx->pollfds); /* FIXME should use an eventfd on kernels that support it */ - r = pipe_for_poll(ctx->ctrl_pipe); + r = _libusb_pipe(ctx->ctrl_pipe); if (r < 0) return LIBUSB_ERROR_OTHER; @@ -1057,12 +1058,12 @@ int usbi_io_init(struct libusb_context *ctx) void usbi_io_exit(struct libusb_context *ctx) { usbi_remove_pollfd(ctx, ctx->ctrl_pipe[0]); - close_for_poll(ctx->ctrl_pipe[0]); - close_for_poll(ctx->ctrl_pipe[1]); + _libusb_close(ctx->ctrl_pipe[0]); + _libusb_close(ctx->ctrl_pipe[1]); #ifdef USBI_TIMERFD_AVAILABLE if (usbi_using_timerfd(ctx)) { usbi_remove_pollfd(ctx, ctx->timerfd); - close(ctx->timerfd); + _libusb_close(ctx->timerfd); } #endif pthread_mutex_destroy(&ctx->flying_transfers_lock); @@ -1882,7 +1883,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv) timeout_ms++; usbi_dbg("poll() %d fds with timeout in %dms", nfds, timeout_ms); - r = poll(fds, nfds, timeout_ms); + r = _libusb_poll(fds, nfds, timeout_ms); usbi_dbg("poll() returned %d", r); if (r == 0) { free(fds); diff --git a/libusb/os/windows_compat.c b/libusb/os/windows_compat.c index 180ff0c..58b91d3 100644 --- a/libusb/os/windows_compat.c +++ b/libusb/os/windows_compat.c @@ -268,7 +268,7 @@ __inline void _init_read_marker(int index) /* * Create an async I/O anonymous pipe (that can be used for sync as well) */ -int pipe_for_poll(int filedes[2]) +int _libusb_pipe(int filedes[2]) { int i, j; HANDLE handle[2]; @@ -526,7 +526,7 @@ struct winfd overlapped_to_winfd(OVERLAPPED* overlapped) * Currently, this function only accepts one of POLLIN or POLLOUT per fd * (but you can create multiple fds from the same handle for read and write) */ -int poll(struct pollfd *fds, unsigned int nfds, int timeout) +int _libusb_poll(struct pollfd *fds, unsigned int nfds, int timeout) { unsigned i, triggered = 0; int index, object_index; @@ -635,7 +635,7 @@ int poll(struct pollfd *fds, unsigned int nfds, int timeout) * * Note that this function will also close the associated handle */ -int close_for_poll(int fd) +int _libusb_close(int fd) { int index; HANDLE handle; @@ -667,7 +667,7 @@ int close_for_poll(int fd) * - binary mode only * - no append mode */ -ssize_t write_for_poll(int fd, const void *buf, size_t count) +ssize_t _libusb_write(int fd, const void *buf, size_t count) { int index; DWORD wr_count; @@ -743,7 +743,7 @@ out: * synchronous read for custom poll (works on Windows file handles that * have been opened with the FILE_FLAG_OVERLAPPED flag) */ -ssize_t read_for_poll(int fd, void *buf, size_t count) +ssize_t _libusb_read(int fd, void *buf, size_t count) { int index; DWORD rd_count; diff --git a/libusb/os/windows_compat.h b/libusb/os/windows_compat.h index f40f5de..5192a3e 100644 --- a/libusb/os/windows_compat.h +++ b/libusb/os/windows_compat.h @@ -62,11 +62,11 @@ struct winfd { }; extern const struct winfd INVALID_WINFD; -int pipe_for_poll(int pipefd[2]); -int poll(struct pollfd *fds, unsigned int nfds, int timeout); -ssize_t write_for_poll(int fd, const void *buf, size_t count); -ssize_t read_for_poll(int fd, void *buf, size_t count); -int close_for_poll(int fd); +int _libusb_pipe(int pipefd[2]); +int _libusb_poll(struct pollfd *fds, unsigned int nfds, int timeout); +ssize_t _libusb_write(int fd, const void *buf, size_t count); +ssize_t _libusb_read(int fd, void *buf, size_t count); +int _libusb_close(int fd); void init_polling(void); void exit_polling(void); diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 42d88da..d33fbc9 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -160,6 +160,7 @@ static inline BOOLEAN guid_eq(const GUID *guid1, const GUID *guid2) { return false; } +#if 0 static char* guid_to_string(const GUID guid) { static char guid_string[GUID_STRING_LENGTH]; @@ -170,6 +171,7 @@ static char guid_string[GUID_STRING_LENGTH]; guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); return guid_string; } +#endif /* * Converts a windows error to human readable string @@ -3236,7 +3238,6 @@ static int hid_submit_bulk_transfer(struct usbi_transfer *itransfer) { bool direction_in, ret; int current_interface; DWORD size; - int r = LIBUSB_ERROR_INVALID_PARAM; CHECK_HID_AVAILABLE; @@ -3284,9 +3285,7 @@ static int hid_abort_transfers(struct usbi_transfer *itransfer) { struct libusb_transfer *transfer = __USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); struct windows_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer); - struct libusb_context *ctx = DEVICE_CTX(transfer->dev_handle->dev); struct windows_device_handle_priv *handle_priv = (struct windows_device_handle_priv *)transfer->dev_handle->os_priv; - struct windows_device_priv *priv = __device_priv(transfer->dev_handle->dev); HANDLE hid_handle; int current_interface; @@ -3301,9 +3300,7 @@ static int hid_abort_transfers(struct usbi_transfer *itransfer) static int hid_reset_device(struct libusb_device_handle *dev_handle) { - struct libusb_context *ctx = DEVICE_CTX(dev_handle->dev); struct windows_device_handle_priv *handle_priv = (struct windows_device_handle_priv *)dev_handle->os_priv; - struct windows_device_priv *priv = __device_priv(dev_handle->dev); HANDLE hid_handle; int current_interface; |