}
/* 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;
{
struct usbi_transfer *transfer;
- 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, then we have no
/* 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 */
int timeout_ms;
usbi_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 */
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++;
}
/* 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;
usbi_dbg("remove fd %d", fd);
usbi_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;
USBI_GET_CONTEXT(ctx);
usbi_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;
while (1) {
usbi_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;
* pos - A structure pointer has a "member" element
* head - list head
* member - the list_head element in "pos"
+ * type - the type of the first parameter
*/
-#define list_for_each_entry(pos, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = list_entry(pos->member.next, typeof(*pos), member))
-
-#define list_for_each_entry_safe(pos, n, head, member) \
- for (pos = list_entry((head)->next, typeof(*pos), member), \
- n = list_entry(pos->member.next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = n, n = list_entry(n->member.next, typeof(*n), member))
+#define list_for_each_entry(pos, head, member, type) \
+ for (pos = list_entry((head)->next, type, member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, type, member))
+
+#define list_for_each_entry_safe(pos, n, head, member, type) \
+ for (pos = list_entry((head)->next, type, member), \
+ n = list_entry(pos->member.next, type, member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, type, member))
#define list_empty(entry) ((entry)->next == (entry))
IOObjectRelease (device);
usbi_mutex_lock(&ctx->open_devs_lock);
- list_for_each_entry(handle, &ctx->open_devs, list) {
+ list_for_each_entry(handle, &ctx->open_devs, list, struct libusb_device_handle) {
dpriv = (struct darwin_device_priv *)handle->dev->os_priv;
/* the device may have been opened several times. write to each handle's event descriptor */
continue;
num_ready--;
- list_for_each_entry(handle, &ctx->open_devs, list) {
+ list_for_each_entry(handle, &ctx->open_devs, list, struct libusb_device_handle) {
hpriv = (struct darwin_device_handle_priv *)handle->os_priv;
if (hpriv->fds[0] == pollfd->fd)
break;