PERFORCE change 164521 for review

Sylvestre Gallon syl at FreeBSD.org
Tue Jun 16 18:11:00 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164521

Change 164521 by syl at syl_atuin on 2009/06/16 18:10:15

	Add debug code in libusb10_io.c

Affected files ...

.. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#12 edit

Differences ...

==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#12 (text+ko) ====

@@ -213,6 +213,8 @@
 	int ret;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_try_lock_events enter");
+
 	pthread_mutex_lock(&ctx->pollfd_modify_lock);
 	ret = ctx->pollfd_modify;
 	pthread_mutex_unlock(&ctx->pollfd_modify_lock);
@@ -226,6 +228,8 @@
 		return (1);
 	
 	ctx->event_handler_active = 1;
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_try_lock_events leave");
 	return (0);
 }
 
@@ -233,20 +237,28 @@
 libusb_lock_events(libusb_context * ctx)
 {
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_events enter");
+
 	pthread_mutex_lock(&ctx->events_lock);
 	ctx->event_handler_active = 1;
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_events leave");
 }
 
 void
 libusb_unlock_events(libusb_context * ctx)
 {
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_events enter");
+
 	ctx->event_handler_active = 0;
 	pthread_mutex_unlock(&ctx->events_lock);
 
 	pthread_mutex_lock(&ctx->event_waiters_lock);
 	pthread_cond_broadcast(&ctx->event_waiters_cond);
 	pthread_mutex_unlock(&ctx->event_waiters_lock);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_events leave");
 }
 
 int
@@ -255,12 +267,16 @@
 	int ret;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handling_ok enter");
+
 	pthread_mutex_lock(&ctx->pollfd_modify_lock);
 	ret = ctx->pollfd_modify;
 	pthread_mutex_unlock(&ctx->pollfd_modify_lock);
 
 	if (ret != 0)
 		return (0);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handling_ok leave");
 	return (1);
 }
 
@@ -270,12 +286,16 @@
 	int ret;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handler_active enter");
+
 	pthread_mutex_lock(&ctx->pollfd_modify_lock);
 	ret = ctx->pollfd_modify;
 	pthread_mutex_unlock(&ctx->pollfd_modify_lock);
 
 	if (ret != 0)
 		return (1);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_event_handler_active leave");
 	return (ctx->event_handler_active);
 }
 
@@ -283,14 +303,22 @@
 libusb_lock_event_waiters(libusb_context * ctx)
 {
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_event_waiters enter");
+
 	pthread_mutex_lock(&ctx->event_waiters_lock);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_lock_event_waiters leave");
 }
 
 void
 libusb_unlock_event_waiters(libusb_context * ctx)
 {
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_event_waiters enter");
+
 	pthread_mutex_unlock(&ctx->event_waiters_lock);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unlock_event_waiters leave");
 }
 
 int
@@ -300,6 +328,8 @@
 	struct timespec ts;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event enter");
+
 	if (tv == NULL) {
 		pthread_cond_wait(&ctx->event_waiters_cond, 
 		    &ctx->event_waiters_lock);
@@ -322,6 +352,8 @@
 
 	if (ret == ETIMEDOUT)
 		return (1);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_wait_for_event leave");
 	return (0);
 }
 
@@ -333,6 +365,8 @@
 	int ret;
 	
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout enter");
+
 	ret = get_next_timeout(ctx, tv, &poll_timeout);
 	if (ret != 0) {
 		return handle_timeouts(ctx);
@@ -357,6 +391,8 @@
 		return ret;
 	else if (ret == 1)
 		return (handle_timeouts(ctx));
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout leave");
 	return (0);
 }
 
@@ -364,10 +400,17 @@
 libusb_handle_events(libusb_context * ctx)
 {
 	struct timeval tv;
+	int ret;
 
+	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events enter");
+
 	tv.tv_sec = 2;
 	tv.tv_usec = 0;
-	return (libusb_handle_events_timeout(ctx, &tv));
+	ret = libusb_handle_events_timeout(ctx, &tv);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events leave");
+	return (ret);
 }
 
 int
@@ -377,12 +420,17 @@
 	struct timeval poll_tv;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_locked enter");
+
 	ret = get_next_timeout(ctx, tv, &poll_tv);
 	if (ret != 0) {
 		return handle_timeouts(ctx);
 	}
 
-	return (handle_events(ctx, &poll_tv));
+	ret = handle_events(ctx, &poll_tv);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_locked leave");
+	return (ret);
 }
 
 int
@@ -396,6 +444,8 @@
 	int ret;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_next_timeout enter");
+
 	found = 0;
 	pthread_mutex_lock(&ctx->flying_transfers_lock);
 	if (USB_LIST_EMPTY(&ctx->flying_transfers)) {
@@ -429,6 +479,7 @@
 	else
 		timersub(next_tv, &cur_tv, tv);
 
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_next_timeout leave");
 	return (1);
 }
 
@@ -438,9 +489,13 @@
     void *user_data)
 {
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_pollfd_notifiers enter");
+
 	ctx->fd_added_cb = added_cb;
 	ctx->fd_removed_cb = removed_cb;
 	ctx->fd_cb_user_data = user_data;
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_pollfd_notifiers leave");
 }
 
 struct libusb_pollfd **
@@ -451,6 +506,8 @@
 	int i;
 
 	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_pollfds enter");
+
 	i = 0;
 	pthread_mutex_lock(&ctx->pollfds_lock);
 	LIST_FOREACH_ENTRY(pollfd, &ctx->pollfds, list)
@@ -467,6 +524,7 @@
 		ret[i++] = (struct libusb_pollfd *) pollfd;
 	ret[i] = NULL;
 
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_pollfds leave");
 	return (ret);
 }
 
@@ -487,10 +545,15 @@
 {
 	struct libusb_transfer *xfer;
 	struct libusb_control_setup *ctr;
+	libusb_context *ctx;
 	unsigned char *buff;
 	int complet;
 	int ret;
 
+	ctx = NULL;
+	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_control_transfer enter");
+
 	if (devh == NULL || data == NULL)
 		return (LIBUSB_ERROR_NO_MEM);
 
@@ -555,6 +618,8 @@
 		ret = LIBUSB_ERROR_OTHER;
 	}
 	libusb_free_transfer(xfer);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_control_transfer leave");
 	return (ret);
 }
 
@@ -628,8 +693,18 @@
     unsigned char endpoint, unsigned char *data, int length,
     int *transferred, unsigned int timeout)
 {
-	return (do_transfer(devh, endpoint, data, length, transferred,
-	    timeout, LIBUSB_TRANSFER_TYPE_BULK));
+	libusb_context *ctx;
+	int ret;
+	
+	ctx = NULL;
+	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer enter");
+
+	ret = do_transfer(devh, endpoint, data, length, transferred,
+	    timeout, LIBUSB_TRANSFER_TYPE_BULK);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_bulk_transfer leave");
+	return (ret);
 }
 
 /*
@@ -640,6 +715,16 @@
     unsigned char endpoint, unsigned char *data, int length, 
     int *transferred, unsigned int timeout)
 {
-	return (do_transfer(devh, endpoint, data, length, transferred,
-	    timeout, LIBUSB_TRANSFER_TYPE_INTERRUPT));
+	libusb_context *ctx;
+	int ret;
+
+	ctx = NULL;
+	GET_CONTEXT(ctx);
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer enter");
+
+	ret = do_transfer(devh, endpoint, data, length, transferred,
+	    timeout, LIBUSB_TRANSFER_TYPE_INTERRUPT);
+
+	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_interrupt_transfer leave");
+	return (ret);
 }


More information about the p4-projects mailing list