aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Hampson <ahampson@google.com>2013-02-01 09:21:35 -0800
committerAdam Hampson <ahampson@google.com>2013-02-01 15:36:38 -0800
commita361c7f29c5b6ec9aa2b2e3e552b335a13c42cae (patch)
tree429e03d0f199846e5016fbe12b07478612f397f3
parent3dd6b0719cb1b8105377280758190d9def84ff3a (diff)
downloadlibusb_aah-a361c7f29c5b6ec9aa2b2e3e552b335a13c42cae.tar.gz
Remove large inline functions from the library header
The libusb_get_iso_packet_buffer() and libusb_get_iso_packet_buffer_simple() functions are now exported library functions. Change-Id: I9ffd656e27f303d0e68f3cbc228699d93bc7c9a7 Signed-off-by: Adam Hampson <ahampson@google.com>
-rw-r--r--libusb/io.c76
-rw-r--r--libusb/libusb.h78
2 files changed, 80 insertions, 74 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 0b876d1..f50bdf3 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1053,6 +1053,82 @@ printf("completed!\n");
}
#endif
+/** \ingroup asyncio
+ * Convenience function to locate the position of an isochronous packet
+ * within the buffer of an isochronous transfer.
+ *
+ * This is a thorough function which loops through all preceding packets,
+ * accumulating their lengths to find the position of the specified packet.
+ * Typically you will assign equal lengths to each packet in the transfer,
+ * and hence the above method is sub-optimal. You may wish to use
+ * libusb_get_iso_packet_buffer_simple() instead.
+ *
+ * \param transfer a transfer
+ * \param packet the packet to return the address of
+ * \returns the base address of the packet buffer inside the transfer buffer,
+ * or NULL if the packet does not exist.
+ * \see libusb_get_iso_packet_buffer_simple()
+ */
+unsigned char *libusb_get_iso_packet_buffer(
+ struct libusb_transfer *transfer, unsigned int packet)
+{
+ int i;
+ size_t offset = 0;
+ int _packet;
+
+ /* oops..slight bug in the API. packet is an unsigned int, but we use
+ * signed integers almost everywhere else. range-check and convert to
+ * signed to avoid compiler warnings. FIXME for libusb-2. */
+ if (packet > INT_MAX)
+ return NULL;
+ _packet = packet;
+
+ if (_packet >= transfer->num_iso_packets)
+ return NULL;
+
+ for (i = 0; i < _packet; i++)
+ offset += transfer->iso_packet_desc[i].length;
+
+ return transfer->buffer + offset;
+}
+
+/** \ingroup asyncio
+ * Convenience function to locate the position of an isochronous packet
+ * within the buffer of an isochronous transfer, for transfers where each
+ * packet is of identical size.
+ *
+ * This function relies on the assumption that every packet within the transfer
+ * is of identical size to the first packet. Calculating the location of
+ * the packet buffer is then just a simple calculation:
+ * <tt>buffer + (packet_size * packet)</tt>
+ *
+ * Do not use this function on transfers other than those that have identical
+ * packet lengths for each packet.
+ *
+ * \param transfer a transfer
+ * \param packet the packet to return the address of
+ * \returns the base address of the packet buffer inside the transfer buffer,
+ * or NULL if the packet does not exist.
+ * \see libusb_get_iso_packet_buffer()
+ */
+unsigned char *libusb_get_iso_packet_buffer_simple(
+ struct libusb_transfer *transfer, unsigned int packet)
+{
+ int _packet;
+
+ /* oops..slight bug in the API. packet is an unsigned int, but we use
+ * signed integers almost everywhere else. range-check and convert to
+ * signed to avoid compiler warnings. FIXME for libusb-2. */
+ if (packet > INT_MAX)
+ return NULL;
+ _packet = packet;
+
+ if (_packet >= transfer->num_iso_packets)
+ return NULL;
+
+ return transfer->buffer + (transfer->iso_packet_desc[0].length * _packet);
+}
+
int usbi_io_init(struct libusb_context *ctx)
{
int r;
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 58b406f..5ad470e 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -1234,81 +1234,11 @@ static inline void libusb_set_iso_packet_lengths(
transfer->iso_packet_desc[i].length = length;
}
-/** \ingroup asyncio
- * Convenience function to locate the position of an isochronous packet
- * within the buffer of an isochronous transfer.
- *
- * This is a thorough function which loops through all preceding packets,
- * accumulating their lengths to find the position of the specified packet.
- * Typically you will assign equal lengths to each packet in the transfer,
- * and hence the above method is sub-optimal. You may wish to use
- * libusb_get_iso_packet_buffer_simple() instead.
- *
- * \param transfer a transfer
- * \param packet the packet to return the address of
- * \returns the base address of the packet buffer inside the transfer buffer,
- * or NULL if the packet does not exist.
- * \see libusb_get_iso_packet_buffer_simple()
- */
-static inline unsigned char *libusb_get_iso_packet_buffer(
- struct libusb_transfer *transfer, unsigned int packet)
-{
- int i;
- size_t offset = 0;
- int _packet;
-
- /* oops..slight bug in the API. packet is an unsigned int, but we use
- * signed integers almost everywhere else. range-check and convert to
- * signed to avoid compiler warnings. FIXME for libusb-2. */
- if (packet > INT_MAX)
- return NULL;
- _packet = packet;
-
- if (_packet >= transfer->num_iso_packets)
- return NULL;
-
- for (i = 0; i < _packet; i++)
- offset += transfer->iso_packet_desc[i].length;
-
- return transfer->buffer + offset;
-}
+unsigned char * LIBUSB_CALL libusb_get_iso_packet_buffer(
+ struct libusb_transfer *transfer, unsigned int packet);
-/** \ingroup asyncio
- * Convenience function to locate the position of an isochronous packet
- * within the buffer of an isochronous transfer, for transfers where each
- * packet is of identical size.
- *
- * This function relies on the assumption that every packet within the transfer
- * is of identical size to the first packet. Calculating the location of
- * the packet buffer is then just a simple calculation:
- * <tt>buffer + (packet_size * packet)</tt>
- *
- * Do not use this function on transfers other than those that have identical
- * packet lengths for each packet.
- *
- * \param transfer a transfer
- * \param packet the packet to return the address of
- * \returns the base address of the packet buffer inside the transfer 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(
- struct libusb_transfer *transfer, unsigned int packet)
-{
- int _packet;
-
- /* oops..slight bug in the API. packet is an unsigned int, but we use
- * signed integers almost everywhere else. range-check and convert to
- * signed to avoid compiler warnings. FIXME for libusb-2. */
- if (packet > INT_MAX)
- return NULL;
- _packet = packet;
-
- if (_packet >= transfer->num_iso_packets)
- return NULL;
-
- return transfer->buffer + (transfer->iso_packet_desc[0].length * _packet);
-}
+unsigned char * LIBUSB_CALL libusb_get_iso_packet_buffer_simple(
+ struct libusb_transfer *transfer, unsigned int packet);
/* sync I/O */