if (r < 0) {
usbi_err(ITRANSFER_CTX(itransfer),
"failed to read monotonic clock, errno=%d", errno);
- return r;
+ return LIBUSB_ERROR_OTHER;
}
itransfer->timeout.tv_sec += timeout / 1000U;
/* get current time */
r = usbi_clock_gettime(USBI_CLOCK_MONOTONIC, &systime);
- if (r < 0)
- return r;
+ if (r < 0) {
+ usbi_err(ctx, "failed to read monotonic clock, errno=%d", errno);
+ return LIBUSB_ERROR_OTHER;
+ }
/* iterate through flying transfers list, finding all transfers that
* have expired timeouts */
clock_ref = clock_monotonic;
break;
default:
- return LIBUSB_ERROR_INVALID_PARAM;
+ errno = EINVAL;
+ return -1;
}
clock_get_time (clock_ref, &sys_time);
tp->tv_sec = sys_time.tv_sec;
tp->tv_nsec = sys_time.tv_nsec;
- return LIBUSB_SUCCESS;
+ return 0;
}
#endif
#include <config.h>
+#include <errno.h>
#include <inttypes.h>
#include <process.h>
#include <stdio.h>
QueryPerformanceCounter(&hires_counter);
tp->tv_sec = (long)(hires_counter.QuadPart / hires_frequency);
tp->tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency) * hires_ticks_to_ps) / UINT64_C(1000));
- return LIBUSB_SUCCESS;
+ return 0;
}
// Fall through and return real-time if monotonic was not detected @ timer init
case USBI_CLOCK_REALTIME:
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
- if (!timespec_get(tp, TIME_UTC))
- return LIBUSB_ERROR_OTHER;
+ if (!timespec_get(tp, TIME_UTC)) {
+ errno = EIO;
+ return -1;
+ }
#else
// We follow http://msdn.microsoft.com/en-us/library/ms724928%28VS.85%29.aspx
// with a predef epoch time to have an epoch that starts at 1970.01.01 00:00
tp->tv_sec = (long)(rtime.QuadPart / 10000000);
tp->tv_nsec = (long)((rtime.QuadPart % 10000000) * 100);
#endif
- return LIBUSB_SUCCESS;
+ return 0;
default:
- return LIBUSB_ERROR_INVALID_PARAM;
+ errno = EINVAL;
+ return -1;
}
}
#endif
-#define LIBUSB_NANO 11465
+#define LIBUSB_NANO 11466