diff options
author | Pete Batard <pbatard@gmail.com> | 2010-04-13 23:32:45 +0100 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-04-13 23:32:45 +0100 |
commit | 511f5b9fdf032fc6b3d4b926538705fe96db1d4f (patch) | |
tree | a892839a85f674177475dd49e374a6cc47372bba /libusb | |
parent | 26a0c962b13088896a91052e78a23303aa085260 (diff) | |
download | libusb-511f5b9fdf032fc6b3d4b926538705fe96db1d4f.tar.gz |
set default calling convention for Windows platform (core)
no calling convention is set on non Windows platforms as using
__attribute__((cdecl)) is source of potential warnings.
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/core.c | 52 | ||||
-rw-r--r-- | libusb/descriptor.c | 12 | ||||
-rw-r--r-- | libusb/io.c | 38 | ||||
-rw-r--r-- | libusb/libusb.h | 146 | ||||
-rw-r--r-- | libusb/sync.c | 6 |
5 files changed, 131 insertions, 123 deletions
diff --git a/libusb/core.c b/libusb/core.c index 6391bea..d0013ec 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -590,7 +590,7 @@ struct libusb_device *usbi_get_device_by_session_id(struct libusb_context *ctx, * \returns the number of devices in the outputted list, or LIBUSB_ERROR_NO_MEM * on memory allocation failure. */ -API_EXPORTED ssize_t libusb_get_device_list(libusb_context *ctx, +API_EXPORTED ssize_t LIBUSB_API libusb_get_device_list(libusb_context *ctx, libusb_device ***list) { struct discovered_devs *discdevs = discovered_devs_alloc(); @@ -636,7 +636,7 @@ out: * \param list the list to free * \param unref_devices whether to unref the devices in the list */ -API_EXPORTED void libusb_free_device_list(libusb_device **list, +API_EXPORTED void LIBUSB_API libusb_free_device_list(libusb_device **list, int unref_devices) { if (!list) @@ -657,7 +657,7 @@ API_EXPORTED void libusb_free_device_list(libusb_device **list, * \param dev a device * \returns the bus number */ -API_EXPORTED uint8_t libusb_get_bus_number(libusb_device *dev) +API_EXPORTED uint8_t LIBUSB_API libusb_get_bus_number(libusb_device *dev) { return dev->bus_number; } @@ -667,7 +667,7 @@ API_EXPORTED uint8_t libusb_get_bus_number(libusb_device *dev) * \param dev a device * \returns the device address */ -API_EXPORTED uint8_t libusb_get_device_address(libusb_device *dev) +API_EXPORTED uint8_t LIBUSB_API libusb_get_device_address(libusb_device *dev) { return dev->device_address; } @@ -713,7 +713,7 @@ static const struct libusb_endpoint_descriptor *find_endpoint( * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist * \returns LIBUSB_ERROR_OTHER on other failure */ -API_EXPORTED int libusb_get_max_packet_size(libusb_device *dev, +API_EXPORTED int LIBUSB_API libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint) { struct libusb_config_descriptor *config; @@ -762,7 +762,7 @@ API_EXPORTED int libusb_get_max_packet_size(libusb_device *dev, * \returns LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist * \returns LIBUSB_ERROR_OTHER on other failure */ -API_EXPORTED int libusb_get_max_iso_packet_size(libusb_device *dev, +API_EXPORTED int LIBUSB_API libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint) { struct libusb_config_descriptor *config; @@ -798,7 +798,7 @@ API_EXPORTED int libusb_get_max_iso_packet_size(libusb_device *dev, * \param dev the device to reference * \returns the same device */ -API_EXPORTED libusb_device *libusb_ref_device(libusb_device *dev) +API_EXPORTED libusb_device* LIBUSB_API libusb_ref_device(libusb_device *dev) { usbi_mutex_lock(&dev->lock); dev->refcnt++; @@ -811,7 +811,7 @@ API_EXPORTED libusb_device *libusb_ref_device(libusb_device *dev) * causes the reference count to reach zero, the device shall be destroyed. * \param dev the device to unreference */ -API_EXPORTED void libusb_unref_device(libusb_device *dev) +API_EXPORTED void LIBUSB_API libusb_unref_device(libusb_device *dev) { int refcnt; @@ -900,7 +900,7 @@ void usbi_fd_notification(struct libusb_context *ctx) * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_open(libusb_device *dev, libusb_device_handle **handle) +API_EXPORTED int LIBUSB_API libusb_open(libusb_device *dev, libusb_device_handle **handle) { struct libusb_context *ctx = DEVICE_CTX(dev); struct libusb_device_handle *_handle; @@ -964,7 +964,7 @@ API_EXPORTED int libusb_open(libusb_device *dev, libusb_device_handle **handle) * \param product_id the idProduct value to search for * \returns a handle for the first found device, or NULL on error or if the * device could not be found. */ -API_EXPORTED libusb_device_handle *libusb_open_device_with_vid_pid( +API_EXPORTED libusb_device_handle* LIBUSB_API libusb_open_device_with_vid_pid( libusb_context *ctx, uint16_t vendor_id, uint16_t product_id) { struct libusb_device **devs; @@ -1023,7 +1023,7 @@ static void do_close(struct libusb_context *ctx, * * \param dev_handle the handle to close */ -API_EXPORTED void libusb_close(libusb_device_handle *dev_handle) +API_EXPORTED void LIBUSB_API libusb_close(libusb_device_handle *dev_handle) { struct libusb_context *ctx; unsigned char dummy = 1; @@ -1084,7 +1084,7 @@ API_EXPORTED void libusb_close(libusb_device_handle *dev_handle) * \param dev_handle a device handle * \returns the underlying device */ -API_EXPORTED libusb_device *libusb_get_device(libusb_device_handle *dev_handle) +API_EXPORTED libusb_device* LIBUSB_API libusb_get_device(libusb_device_handle *dev_handle) { return dev_handle->dev; } @@ -1109,7 +1109,7 @@ API_EXPORTED libusb_device *libusb_get_device(libusb_device_handle *dev_handle) * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_get_configuration(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_get_configuration(libusb_device_handle *dev, int *config) { int r = LIBUSB_ERROR_NOT_SUPPORTED; @@ -1178,7 +1178,7 @@ API_EXPORTED int libusb_get_configuration(libusb_device_handle *dev, * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_set_configuration(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_set_configuration(libusb_device_handle *dev, int configuration) { usbi_dbg("configuration %d", configuration); @@ -1209,7 +1209,7 @@ API_EXPORTED int libusb_set_configuration(libusb_device_handle *dev, * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns a LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_claim_interface(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_claim_interface(libusb_device_handle *dev, int interface_number) { int r = 0; @@ -1246,7 +1246,7 @@ out: * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_release_interface(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_release_interface(libusb_device_handle *dev, int interface_number) { int r; @@ -1291,7 +1291,7 @@ out: * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_set_interface_alt_setting(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_set_interface_alt_setting(libusb_device_handle *dev, int interface_number, int alternate_setting) { usbi_dbg("interface %d altsetting %d", @@ -1326,7 +1326,7 @@ API_EXPORTED int libusb_set_interface_alt_setting(libusb_device_handle *dev, * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_clear_halt(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint) { usbi_dbg("endpoint %x", endpoint); @@ -1352,7 +1352,7 @@ API_EXPORTED int libusb_clear_halt(libusb_device_handle *dev, * device has been disconnected * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_reset_device(libusb_device_handle *dev) +API_EXPORTED int LIBUSB_API libusb_reset_device(libusb_device_handle *dev) { usbi_dbg(""); return usbi_backend->reset_device(dev); @@ -1371,7 +1371,7 @@ API_EXPORTED int libusb_reset_device(libusb_device_handle *dev) * \returns another LIBUSB_ERROR code on other failure * \see libusb_detach_kernel_driver() */ -API_EXPORTED int libusb_kernel_driver_active(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_kernel_driver_active(libusb_device_handle *dev, int interface_number) { usbi_dbg("interface %d", interface_number); @@ -1394,7 +1394,7 @@ API_EXPORTED int libusb_kernel_driver_active(libusb_device_handle *dev, * \returns another LIBUSB_ERROR code on other failure * \see libusb_kernel_driver_active() */ -API_EXPORTED int libusb_detach_kernel_driver(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number) { usbi_dbg("interface %d", interface_number); @@ -1419,7 +1419,7 @@ API_EXPORTED int libusb_detach_kernel_driver(libusb_device_handle *dev, * \returns another LIBUSB_ERROR code on other failure * \see libusb_kernel_driver_active() */ -API_EXPORTED int libusb_attach_kernel_driver(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number) { usbi_dbg("interface %d", interface_number); @@ -1458,7 +1458,7 @@ API_EXPORTED int libusb_attach_kernel_driver(libusb_device_handle *dev, * \param ctx the context to operate on, or NULL for the default context * \param level debug level to set */ -API_EXPORTED void libusb_set_debug(libusb_context *ctx, int level) +API_EXPORTED void LIBUSB_API libusb_set_debug(libusb_context *ctx, int level) { USBI_GET_CONTEXT(ctx); // ctx can be NULL if called before libusb_init @@ -1475,7 +1475,7 @@ API_EXPORTED void libusb_set_debug(libusb_context *ctx, int level) * Only valid on return code 0. * \returns 0 on success, or a LIBUSB_ERROR code on failure */ -API_EXPORTED int libusb_init(libusb_context **context) +API_EXPORTED int LIBUSB_API libusb_init(libusb_context **context) { char *dbg = getenv("LIBUSB_DEBUG"); struct libusb_context *ctx; @@ -1548,7 +1548,7 @@ err: * before your application terminates. * \param ctx the context to deinitialize, or NULL for the default context */ -API_EXPORTED void libusb_exit(struct libusb_context *ctx) +API_EXPORTED void LIBUSB_API libusb_exit(struct libusb_context *ctx) { USBI_GET_CONTEXT(ctx); usbi_dbg(""); @@ -1642,7 +1642,7 @@ void usbi_log(struct libusb_context *ctx, enum usbi_log_level level, * \param errcode the error code whose description is desired * \returns a short description of the error code in English */ -API_EXPORTED const char* libusb_strerror(enum libusb_error errcode) +API_EXPORTED const char* LIBUSB_API libusb_strerror(enum libusb_error errcode) { switch (errcode) { diff --git a/libusb/descriptor.c b/libusb/descriptor.c index 57e99ed..d5d9a75 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c @@ -429,7 +429,7 @@ err: * \param desc output location for the descriptor data * \returns 0 on success or a LIBUSB_ERROR code on failure */ -API_EXPORTED int libusb_get_device_descriptor(libusb_device *dev, +API_EXPORTED int LIBUSB_API libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc) { unsigned char raw_desc[DEVICE_DESC_LENGTH]; @@ -465,7 +465,7 @@ API_EXPORTED int libusb_get_device_descriptor(libusb_device *dev, * \returns another LIBUSB_ERROR code on error * \see libusb_get_config_descriptor */ -API_EXPORTED int libusb_get_active_config_descriptor(libusb_device *dev, +API_EXPORTED int LIBUSB_API libusb_get_active_config_descriptor(libusb_device *dev, struct libusb_config_descriptor **config) { struct libusb_config_descriptor *_config = malloc(sizeof(*_config)); @@ -530,7 +530,7 @@ err: * \see libusb_get_active_config_descriptor() * \see libusb_get_config_descriptor_by_value() */ -API_EXPORTED int libusb_get_config_descriptor(libusb_device *dev, +API_EXPORTED int LIBUSB_API libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config) { struct libusb_config_descriptor *_config; @@ -629,7 +629,7 @@ int usbi_get_config_index_by_value(struct libusb_device *dev, * \see libusb_get_active_config_descriptor() * \see libusb_get_config_descriptor() */ -API_EXPORTED int libusb_get_config_descriptor_by_value(libusb_device *dev, +API_EXPORTED int LIBUSB_API libusb_get_config_descriptor_by_value(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config) { int idx; @@ -650,7 +650,7 @@ API_EXPORTED int libusb_get_config_descriptor_by_value(libusb_device *dev, * * \param config the configuration descriptor to free */ -API_EXPORTED void libusb_free_config_descriptor( +API_EXPORTED void LIBUSB_API libusb_free_config_descriptor( struct libusb_config_descriptor *config) { if (!config) @@ -672,7 +672,7 @@ API_EXPORTED void libusb_free_config_descriptor( * \param length size of data buffer * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure */ -API_EXPORTED int libusb_get_string_descriptor_ascii(libusb_device_handle *dev, +API_EXPORTED int LIBUSB_API libusb_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_t desc_index, unsigned char *data, int length) { unsigned char tbuf[255]; /* Some devices choke on size > 255 */ diff --git a/libusb/io.c b/libusb/io.c index 92bc831..3ddd947 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1171,7 +1171,7 @@ out: * \param iso_packets number of isochronous packet descriptors to allocate * \returns a newly allocated transfer, or NULL on error */ -API_EXPORTED struct libusb_transfer *libusb_alloc_transfer(int iso_packets) +API_EXPORTED struct libusb_transfer* LIBUSB_API libusb_alloc_transfer(int iso_packets) { size_t os_alloc_size = usbi_backend->transfer_priv_size + (usbi_backend->add_iso_packet_size * iso_packets); @@ -1206,7 +1206,7 @@ API_EXPORTED struct libusb_transfer *libusb_alloc_transfer(int iso_packets) * * \param transfer the transfer to free */ -API_EXPORTED void libusb_free_transfer(struct libusb_transfer *transfer) +API_EXPORTED void LIBUSB_API libusb_free_transfer(struct libusb_transfer *transfer) { struct usbi_transfer *itransfer; if (!transfer) @@ -1230,7 +1230,7 @@ API_EXPORTED void libusb_free_transfer(struct libusb_transfer *transfer) * \returns LIBUSB_ERROR_BUSY if the transfer has already been submitted. * \returns another LIBUSB_ERROR code on other failure */ -API_EXPORTED int libusb_submit_transfer(struct libusb_transfer *transfer) +API_EXPORTED int LIBUSB_API libusb_submit_transfer(struct libusb_transfer *transfer) { struct libusb_context *ctx = TRANSFER_CTX(transfer); struct usbi_transfer *itransfer = @@ -1286,7 +1286,7 @@ out: * cancelled. * \returns a LIBUSB_ERROR code on failure */ -API_EXPORTED int libusb_cancel_transfer(struct libusb_transfer *transfer) +API_EXPORTED int LIBUSB_API libusb_cancel_transfer(struct libusb_transfer *transfer) { struct usbi_transfer *itransfer = __LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer); @@ -1458,7 +1458,7 @@ int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer) * \returns 1 if the lock was not obtained (i.e. another thread holds the lock) * \see \ref mtasync */ -API_EXPORTED int libusb_try_lock_events(libusb_context *ctx) +API_EXPORTED int LIBUSB_API libusb_try_lock_events(libusb_context *ctx) { int r; USBI_GET_CONTEXT(ctx); @@ -1499,7 +1499,7 @@ API_EXPORTED int libusb_try_lock_events(libusb_context *ctx) * \param ctx the context to operate on, or NULL for the default context * \see \ref mtasync */ -API_EXPORTED void libusb_lock_events(libusb_context *ctx) +API_EXPORTED void LIBUSB_API libusb_lock_events(libusb_context *ctx) { USBI_GET_CONTEXT(ctx); usbi_mutex_lock(&ctx->events_lock); @@ -1514,7 +1514,7 @@ API_EXPORTED void libusb_lock_events(libusb_context *ctx) * \param ctx the context to operate on, or NULL for the default context * \see \ref mtasync */ -API_EXPORTED void libusb_unlock_events(libusb_context *ctx) +API_EXPORTED void LIBUSB_API libusb_unlock_events(libusb_context *ctx) { USBI_GET_CONTEXT(ctx); ctx->event_handler_active = 0; @@ -1549,7 +1549,7 @@ API_EXPORTED void libusb_unlock_events(libusb_context *ctx) * \returns 0 if this thread must give up the events lock * \see \ref fullstory "Multi-threaded I/O: the full story" */ -API_EXPORTED int libusb_event_handling_ok(libusb_context *ctx) +API_EXPORTED int LIBUSB_API libusb_event_handling_ok(libusb_context *ctx) { int r; USBI_GET_CONTEXT(ctx); @@ -1577,7 +1577,7 @@ API_EXPORTED int libusb_event_handling_ok(libusb_context *ctx) * \returns 0 if there are no threads currently handling events * \see \ref mtasync */ -API_EXPORTED int libusb_event_handler_active(libusb_context *ctx) +API_EXPORTED int LIBUSB_API libusb_event_handler_active(libusb_context *ctx) { int r; USBI_GET_CONTEXT(ctx); @@ -1614,7 +1614,7 @@ API_EXPORTED int libusb_event_handler_active(libusb_context *ctx) * \param ctx the context to operate on, or NULL for the default context * \see \ref mtasync */ -API_EXPORTED void libusb_lock_event_waiters(libusb_context *ctx) +API_EXPORTED void LIBUSB_API libusb_lock_event_waiters(libusb_context *ctx) { USBI_GET_CONTEXT(ctx); usbi_mutex_lock(&ctx->event_waiters_lock); @@ -1625,7 +1625,7 @@ API_EXPORTED void libusb_lock_event_waiters(libusb_context *ctx) * \param ctx the context to operate on, or NULL for the default context * \see \ref mtasync */ -API_EXPORTED void libusb_unlock_event_waiters(libusb_context *ctx) +API_EXPORTED void LIBUSB_API libusb_unlock_event_waiters(libusb_context *ctx) { USBI_GET_CONTEXT(ctx); usbi_mutex_unlock(&ctx->event_waiters_lock); @@ -1656,7 +1656,7 @@ API_EXPORTED void libusb_unlock_event_waiters(libusb_context *ctx) * \returns 1 if the timeout expired * \see \ref mtasync */ -API_EXPORTED int libusb_wait_for_event(libusb_context *ctx, struct timeval *tv) +API_EXPORTED int LIBUSB_API libusb_wait_for_event(libusb_context *ctx, struct timeval *tv) { struct timespec timeout; int r; @@ -1936,7 +1936,7 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv, * non-blocking mode * \returns 0 on success, or a LIBUSB_ERROR code on failure */ -API_EXPORTED int libusb_handle_events_timeout(libusb_context *ctx, +API_EXPORTED int LIBUSB_API libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv) { int r; @@ -1990,7 +1990,7 @@ retry: * \param ctx the context to operate on, or NULL for the default context * \returns 0 on success, or a LIBUSB_ERROR code on failure */ -API_EXPORTED int libusb_handle_events(libusb_context *ctx) +API_EXPORTED int LIBUSB_API libusb_handle_events(libusb_context *ctx) { struct timeval tv; tv.tv_sec = 60; @@ -2015,7 +2015,7 @@ API_EXPORTED int libusb_handle_events(libusb_context *ctx) * \returns 0 on success, or a LIBUSB_ERROR code on failure * \see \ref mtasync */ -API_EXPORTED int libusb_handle_events_locked(libusb_context *ctx, +API_EXPORTED int LIBUSB_API libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv) { int r; @@ -2059,7 +2059,7 @@ API_EXPORTED int libusb_handle_events_locked(libusb_context *ctx, * or through regular activity on the file descriptors. * \see \ref pollmain "Polling libusb file descriptors for event handling" */ -API_EXPORTED int libusb_pollfds_handle_timeouts(libusb_context *ctx) +API_EXPORTED int LIBUSB_API libusb_pollfds_handle_timeouts(libusb_context *ctx) { #if defined(USBI_OS_HANDLES_TIMEOUT) return 1; @@ -2099,7 +2099,7 @@ API_EXPORTED int libusb_pollfds_handle_timeouts(libusb_context *ctx) * \returns 0 if there are no pending timeouts, 1 if a timeout was returned, * or LIBUSB_ERROR_OTHER on failure */ -API_EXPORTED int libusb_get_next_timeout(libusb_context *ctx, +API_EXPORTED int LIBUSB_API libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv) { #ifndef USBI_OS_HANDLES_TIMEOUT @@ -2185,7 +2185,7 @@ API_EXPORTED int libusb_get_next_timeout(libusb_context *ctx, * \param user_data User data to be passed back to callbacks (useful for * passing context information) */ -API_EXPORTED void libusb_set_pollfd_notifiers(libusb_context *ctx, +API_EXPORTED void LIBUSB_API libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data) { @@ -2254,7 +2254,7 @@ void usbi_remove_pollfd(struct libusb_context *ctx, int fd) * \returns a NULL-terminated list of libusb_pollfd structures, or NULL on * error */ -API_EXPORTED const struct libusb_pollfd **libusb_get_pollfds( +API_EXPORTED const struct libusb_pollfd** LIBUSB_API libusb_get_pollfds( libusb_context *ctx) { #ifndef OS_WINDOWS diff --git a/libusb/libusb.h b/libusb/libusb.h index 6a455f8..b21a93f 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -44,6 +44,14 @@ #undef interface #endif +#if !defined(LIBUSB_API) +#if defined(_WINDOWS_) +#define LIBUSB_API WINAPI +#else +#define LIBUSB_API +#endif +#endif + #ifdef __cplusplus extern "C" { #endif @@ -793,51 +801,51 @@ struct libusb_transfer { ; }; -int libusb_init(libusb_context **ctx); -void libusb_exit(libusb_context *ctx); -void libusb_set_debug(libusb_context *ctx, int level); -const char* libusb_strerror(enum libusb_error errcode); +int LIBUSB_API libusb_init(libusb_context **ctx); +void LIBUSB_API libusb_exit(libusb_context *ctx); +void LIBUSB_API libusb_set_debug(libusb_context *ctx, int level); +const char* LIBUSB_API libusb_strerror(enum libusb_error errcode); -ssize_t libusb_get_device_list(libusb_context *ctx, +ssize_t LIBUSB_API libusb_get_device_list(libusb_context *ctx, libusb_device ***list); -void libusb_free_device_list(libusb_device **list, int unref_devices); -libusb_device *libusb_ref_device(libusb_device *dev); -void libusb_unref_device(libusb_device *dev); +void LIBUSB_API libusb_free_device_list(libusb_device **list, int unref_devices); +libusb_device* LIBUSB_API libusb_ref_device(libusb_device *dev); +void LIBUSB_API libusb_unref_device(libusb_device *dev); -int libusb_get_configuration(libusb_device_handle *dev, int *config); -int libusb_get_device_descriptor(libusb_device *dev, +int LIBUSB_API libusb_get_configuration(libusb_device_handle *dev, int *config); +int LIBUSB_API libusb_get_device_descriptor(libusb_device *dev, struct libusb_device_descriptor *desc); -int libusb_get_active_config_descriptor(libusb_device *dev, +int LIBUSB_API libusb_get_active_config_descriptor(libusb_device *dev, struct libusb_config_descriptor **config); -int libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index, +int LIBUSB_API libusb_get_config_descriptor(libusb_device *dev, uint8_t config_index, struct libusb_config_descriptor **config); -int libusb_get_config_descriptor_by_value(libusb_device *dev, +int LIBUSB_API libusb_get_config_descriptor_by_value(libusb_device *dev, uint8_t bConfigurationValue, struct libusb_config_descriptor **config); -void libusb_free_config_descriptor(struct libusb_config_descriptor *config); -uint8_t libusb_get_bus_number(libusb_device *dev); -uint8_t libusb_get_device_address(libusb_device *dev); -int libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint); -int libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint); +void LIBUSB_API libusb_free_config_descriptor(struct libusb_config_descriptor *config); +uint8_t LIBUSB_API libusb_get_bus_number(libusb_device *dev); +uint8_t LIBUSB_API libusb_get_device_address(libusb_device *dev); +int LIBUSB_API libusb_get_max_packet_size(libusb_device *dev, unsigned char endpoint); +int LIBUSB_API libusb_get_max_iso_packet_size(libusb_device *dev, unsigned char endpoint); -int libusb_open(libusb_device *dev, libusb_device_handle **handle); -void libusb_close(libusb_device_handle *dev_handle); -libusb_device *libusb_get_device(libusb_device_handle *dev_handle); +int LIBUSB_API libusb_open(libusb_device *dev, libusb_device_handle **handle); +void LIBUSB_API libusb_close(libusb_device_handle *dev_handle); +libusb_device* LIBUSB_API libusb_get_device(libusb_device_handle *dev_handle); -int libusb_set_configuration(libusb_device_handle *dev, int configuration); -int libusb_claim_interface(libusb_device_handle *dev, int interface_number); -int libusb_release_interface(libusb_device_handle *dev, int interface_number); +int LIBUSB_API libusb_set_configuration(libusb_device_handle *dev, int configuration); +int LIBUSB_API libusb_claim_interface(libusb_device_handle *dev, int interface_number); +int LIBUSB_API libusb_release_interface(libusb_device_handle *dev, int interface_number); -libusb_device_handle *libusb_open_device_with_vid_pid(libusb_context *ctx, +libusb_device_handle* LIBUSB_API libusb_open_device_with_vid_pid(libusb_context *ctx, uint16_t vendor_id, uint16_t product_id); -int libusb_set_interface_alt_setting(libusb_device_handle *dev, +int LIBUSB_API libusb_set_interface_alt_setting(libusb_device_handle *dev, int interface_number, int alternate_setting); -int libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint); -int libusb_reset_device(libusb_device_handle *dev); +int LIBUSB_API libusb_clear_halt(libusb_device_handle *dev, unsigned char endpoint); +int LIBUSB_API libusb_reset_device(libusb_device_handle *dev); -int libusb_kernel_driver_active(libusb_device_handle *dev, int interface_number); -int libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number); -int libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number); +int LIBUSB_API libusb_kernel_driver_active(libusb_device_handle *dev, int interface_number); +int LIBUSB_API libusb_detach_kernel_driver(libusb_device_handle *dev, int interface_number); +int LIBUSB_API libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number); /* async I/O */ @@ -853,7 +861,7 @@ int libusb_attach_kernel_driver(libusb_device_handle *dev, int interface_number) * \param transfer a transfer * \returns pointer to the first byte of the data section */ -static inline unsigned char *libusb_control_transfer_get_data( +static inline unsigned char* LIBUSB_API libusb_control_transfer_get_data( struct libusb_transfer *transfer) { return transfer->buffer + LIBUSB_CONTROL_SETUP_SIZE; @@ -871,7 +879,7 @@ static inline unsigned char *libusb_control_transfer_get_data( * \param transfer a transfer * \returns a casted pointer to the start of the transfer data buffer */ -static inline struct libusb_control_setup *libusb_control_transfer_get_setup( +static inline struct libusb_control_setup* LIBUSB_API libusb_control_transfer_get_setup( struct libusb_transfer *transfer) { return (struct libusb_control_setup *) transfer->buffer; @@ -899,7 +907,7 @@ static inline struct libusb_control_setup *libusb_control_transfer_get_setup( * \ref libusb_control_setup::wLength "wLength" field of * \ref libusb_control_setup */ -static inline void libusb_fill_control_setup(unsigned char *buffer, +static inline void LIBUSB_API libusb_fill_control_setup(unsigned char *buffer, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint16_t wLength) { @@ -911,10 +919,10 @@ static inline void libusb_fill_control_setup(unsigned char *buffer, setup->wLength = libusb_cpu_to_le16(wLength); } -struct libusb_transfer *libusb_alloc_transfer(int iso_packets); -int libusb_submit_transfer(struct libusb_transfer *transfer); -int libusb_cancel_transfer(struct libusb_transfer *transfer); -void libusb_free_transfer(struct libusb_transfer *transfer); +struct libusb_transfer* LIBUSB_API libusb_alloc_transfer(int iso_packets); +int LIBUSB_API libusb_submit_transfer(struct libusb_transfer *transfer); +int LIBUSB_API libusb_cancel_transfer(struct libusb_transfer *transfer); +void LIBUSB_API libusb_free_transfer(struct libusb_transfer *transfer); /** \ingroup asyncio * Helper function to populate the required \ref libusb_transfer fields @@ -943,7 +951,7 @@ void libusb_free_transfer(struct libusb_transfer *transfer); * \param user_data user data to pass to callback function * \param timeout timeout for the transfer in milliseconds */ -static inline void libusb_fill_control_transfer( +static inline void LIBUSB_API libusb_fill_control_transfer( struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char *buffer, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) @@ -974,7 +982,7 @@ static inline void libusb_fill_control_transfer( * \param user_data user data to pass to callback function * \param timeout timeout for the transfer in milliseconds */ -static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer, +static inline void LIBUSB_API libusb_fill_bulk_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) @@ -1002,7 +1010,7 @@ static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer, * \param user_data user data to pass to callback function * \param timeout timeout for the transfer in milliseconds */ -static inline void libusb_fill_interrupt_transfer( +static inline void LIBUSB_API libusb_fill_interrupt_transfer( struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) @@ -1031,7 +1039,7 @@ static inline void libusb_fill_interrupt_transfer( * \param user_data user data to pass to callback function * \param timeout timeout for the transfer in milliseconds */ -static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer, +static inline void LIBUSB_API libusb_fill_iso_transfer(struct libusb_transfer *transfer, libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *buffer, int length, int num_iso_packets, libusb_transfer_cb_fn callback, void *user_data, unsigned int timeout) @@ -1055,7 +1063,7 @@ static inline void libusb_fill_iso_transfer(struct libusb_transfer *transfer, * \param length the length to set in each isochronous packet descriptor * \see libusb_get_max_packet_size() */ -static inline void libusb_set_iso_packet_lengths( +static inline void LIBUSB_API libusb_set_iso_packet_lengths( struct libusb_transfer *transfer, unsigned int length) { int i; @@ -1079,7 +1087,7 @@ static inline void libusb_set_iso_packet_lengths( * or NULL if the packet does not exist. * \see libusb_get_iso_packet_buffer_simple() */ -static inline unsigned char *libusb_get_iso_packet_buffer( +static inline unsigned char* LIBUSB_API libusb_get_iso_packet_buffer( struct libusb_transfer *transfer, unsigned int packet) { int i; @@ -1121,7 +1129,7 @@ static inline unsigned char *libusb_get_iso_packet_buffer( * or NULL if the packet does not exist. * \see libusb_get_iso_packet_buffer() */ -static inline unsigned char *libusb_get_iso_packet_buffer_simple( +static inline unsigned char* LIBUSB_API libusb_get_iso_packet_buffer_simple( struct libusb_transfer *transfer, unsigned int packet) { int _packet; @@ -1141,15 +1149,15 @@ static inline unsigned char *libusb_get_iso_packet_buffer_simple( /* sync I/O */ -int libusb_control_transfer(libusb_device_handle *dev_handle, +int LIBUSB_API libusb_control_transfer(libusb_device_handle *dev_handle, uint8_t request_type, uint8_t request, uint16_t value, uint16_t index, unsigned char *data, uint16_t length, unsigned int timeout); -int libusb_bulk_transfer(libusb_device_handle *dev_handle, +int LIBUSB_API libusb_bulk_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout); -int libusb_interrupt_transfer(libusb_device_handle *dev_handle, +int LIBUSB_API libusb_interrupt_transfer(libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *actual_length, unsigned int timeout); @@ -1165,7 +1173,7 @@ int libusb_interrupt_transfer(libusb_device_handle *dev_handle, * \param length size of data buffer * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure */ -static inline int libusb_get_descriptor(libusb_device_handle *dev, +static inline int LIBUSB_API libusb_get_descriptor(libusb_device_handle *dev, uint8_t desc_type, uint8_t desc_index, unsigned char *data, int length) { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, @@ -1187,7 +1195,7 @@ static inline int libusb_get_descriptor(libusb_device_handle *dev, * \returns number of bytes returned in data, or LIBUSB_ERROR code on failure * \see libusb_get_string_descriptor_ascii() */ -static inline int libusb_get_string_descriptor(libusb_device_handle *dev, +static inline int LIBUSB_API libusb_get_string_descriptor(libusb_device_handle *dev, uint8_t desc_index, uint16_t langid, unsigned char *data, int length) { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN, @@ -1196,25 +1204,25 @@ static inline int libusb_get_string_descriptor(libusb_device_handle *dev, langid, data, (uint16_t)length, 1000); } -int libusb_get_string_descriptor_ascii(libusb_device_handle *dev, +int LIBUSB_API libusb_get_string_descriptor_ascii(libusb_device_handle *dev, uint8_t index, unsigned char *data, int length); /* polling and timeouts */ -int libusb_try_lock_events(libusb_context *ctx); -void libusb_lock_events(libusb_context *ctx); -void libusb_unlock_events(libusb_context *ctx); -int libusb_event_handling_ok(libusb_context *ctx); -int libusb_event_handler_active(libusb_context *ctx); -void libusb_lock_event_waiters(libusb_context *ctx); -void libusb_unlock_event_waiters(libusb_context *ctx); -int libusb_wait_for_event(libusb_context *ctx, struct timeval *tv); - -int libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv); -int libusb_handle_events(libusb_context *ctx); -int libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv); -int libusb_pollfds_handle_timeouts(libusb_context *ctx); -int libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv); +int LIBUSB_API libusb_try_lock_events(libusb_context *ctx); +void LIBUSB_API libusb_lock_events(libusb_context *ctx); +void LIBUSB_API libusb_unlock_events(libusb_context *ctx); +int LIBUSB_API libusb_event_handling_ok(libusb_context *ctx); +int LIBUSB_API libusb_event_handler_active(libusb_context *ctx); +void LIBUSB_API libusb_lock_event_waiters(libusb_context *ctx); +void LIBUSB_API libusb_unlock_event_waiters(libusb_context *ctx); +int LIBUSB_API libusb_wait_for_event(libusb_context *ctx, struct timeval *tv); + +int LIBUSB_API libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv); +int LIBUSB_API libusb_handle_events(libusb_context *ctx); +int LIBUSB_API libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv); +int LIBUSB_API libusb_pollfds_handle_timeouts(libusb_context *ctx); +int LIBUSB_API libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv); /** \ingroup poll * File descriptor for polling @@ -1240,7 +1248,7 @@ struct libusb_pollfd { * libusb_set_pollfd_notifiers() call * \see libusb_set_pollfd_notifiers() */ -typedef void (*libusb_pollfd_added_cb)(int fd, short events, void *user_data); +typedef void (LIBUSB_API *libusb_pollfd_added_cb)(int fd, short events, void *user_data); /** \ingroup poll * Callback function, invoked when a file descriptor should be removed from @@ -1251,10 +1259,10 @@ typedef void (*libusb_pollfd_added_cb)(int fd, short events, void *user_data); * libusb_set_pollfd_notifiers() call * \see libusb_set_pollfd_notifiers() */ -typedef void (*libusb_pollfd_removed_cb)(int fd, void *user_data); +typedef void (LIBUSB_API *libusb_pollfd_removed_cb)(int fd, void *user_data); -const struct libusb_pollfd **libusb_get_pollfds(libusb_context *ctx); -void libusb_set_pollfd_notifiers(libusb_context *ctx, +const struct libusb_pollfd** LIBUSB_API libusb_get_pollfds(libusb_context *ctx); +void LIBUSB_API libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data); diff --git a/libusb/sync.c b/libusb/sync.c index 289baaa..a626aa9 100644 --- a/libusb/sync.c +++ b/libusb/sync.c @@ -68,7 +68,7 @@ static void ctrl_transfer_cb(struct libusb_transfer *transfer) * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failures */ -API_EXPORTED int libusb_control_transfer(libusb_device_handle *dev_handle, +API_EXPORTED int LIBUSB_API libusb_control_transfer(libusb_device_handle *dev_handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, unsigned char *data, uint16_t wLength, unsigned int timeout) { @@ -251,7 +251,7 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle, * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other failures */ -API_EXPORTED int libusb_bulk_transfer(struct libusb_device_handle *dev_handle, +API_EXPORTED int LIBUSB_API libusb_bulk_transfer(struct libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout) { @@ -300,7 +300,7 @@ API_EXPORTED int libusb_bulk_transfer(struct libusb_device_handle *dev_handle, * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected * \returns another LIBUSB_ERROR code on other error */ -API_EXPORTED int libusb_interrupt_transfer( +API_EXPORTED int LIBUSB_API libusb_interrupt_transfer( struct libusb_device_handle *dev_handle, unsigned char endpoint, unsigned char *data, int length, int *transferred, unsigned int timeout) { |