libusb10_io.c (d1d015864103b253b3fcb2f72a0da5b0cfeb31b6) libusb10_io.c (03205428b8c51b7ec8bba846f9d976023249cdf1)
1/* $FreeBSD$ */
2/*-
3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 322 unchanged lines hidden (view full) ---

331
332 if (err == ETIMEDOUT)
333 return (1);
334
335 return (0);
336}
337
338int
1/* $FreeBSD$ */
2/*-
3 * Copyright (c) 2009 Sylvestre Gallon. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 322 unchanged lines hidden (view full) ---

331
332 if (err == ETIMEDOUT)
333 return (1);
334
335 return (0);
336}
337
338int
339libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv)
339libusb_handle_events_timeout_completed(libusb_context *ctx,
340 struct timeval *tv, int *completed)
340{
341{
341 int err;
342 int err = 0;
342
343 ctx = GET_CONTEXT(ctx);
344
343
344 ctx = GET_CONTEXT(ctx);
345
345 DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout enter");
346 DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout_completed enter");
346
347 libusb_lock_events(ctx);
348
347
348 libusb_lock_events(ctx);
349
349 err = libusb_handle_events_locked(ctx, tv);
350 while (1) {
351 if (completed != NULL) {
352 if (*completed != 0 || err != 0)
353 break;
354 }
355 err = libusb_handle_events_locked(ctx, tv);
356 if (completed == NULL)
357 break;
358 }
350
351 libusb_unlock_events(ctx);
352
359
360 libusb_unlock_events(ctx);
361
353 DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout leave");
362 DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_handle_events_timeout_completed exit");
354
355 return (err);
356}
357
358int
363
364 return (err);
365}
366
367int
368libusb_handle_events_completed(libusb_context *ctx, int *completed)
369{
370 return (libusb_handle_events_timeout_completed(ctx, NULL, completed));
371}
372
373int
374libusb_handle_events_timeout(libusb_context *ctx, struct timeval *tv)
375{
376 return (libusb_handle_events_timeout_completed(ctx, tv, NULL));
377}
378
379int
359libusb_handle_events(libusb_context *ctx)
360{
380libusb_handle_events(libusb_context *ctx)
381{
361 return (libusb_handle_events_timeout(ctx, NULL));
382 return (libusb_handle_events_timeout_completed(ctx, NULL, NULL));
362}
363
364int
365libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv)
366{
367 int err;
368
369 ctx = GET_CONTEXT(ctx);
370
371 if (libusb_event_handling_ok(ctx)) {
372 err = libusb10_handle_events_sub(ctx, tv);
373 } else {
383}
384
385int
386libusb_handle_events_locked(libusb_context *ctx, struct timeval *tv)
387{
388 int err;
389
390 ctx = GET_CONTEXT(ctx);
391
392 if (libusb_event_handling_ok(ctx)) {
393 err = libusb10_handle_events_sub(ctx, tv);
394 } else {
374 libusb_wait_for_event(ctx, tv);
375 err = 0;
395 err = libusb_wait_for_event(ctx, tv);
396 if (err != 0)
397 err = LIBUSB_ERROR_TIMEOUT;
376 }
377 return (err);
378}
379
380int
381libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv)
382{
383 /* all timeouts are currently being done by the kernel */

--- 364 unchanged lines hidden ---
398 }
399 return (err);
400}
401
402int
403libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv)
404{
405 /* all timeouts are currently being done by the kernel */

--- 364 unchanged lines hidden ---