core: Split usbi_clock_gettime() into two separate functions
authorChris Dickens <christopher.a.dickens@gmail.com>
Thu, 27 Aug 2020 20:46:32 +0000 (13:46 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Sun, 13 Sep 2020 07:09:31 +0000 (00:09 -0700)
commitc3e292c57a42d16b3451eb6265cae2f1f8123a48
treed8248a9947d587fc8803395451059a89050e48a7
parent63934ff179dd1bfa8e91f35844c802fff8038ab6
core: Split usbi_clock_gettime() into two separate functions

Most of the library only uses the monotonic clock. In fact, the only use
of the realtime clock is to implement the POSIX version of
usbi_cond_timedwait(). Now that Windows can no longer use the POSIX
thread abstraction, there is no need for Windows to implement a means of
reading the realtime clock.

This change replaces usbi_clock_gettime() with usbi_get_monotonic_time()
and usbi_get_real_time(). When clock_gettime() is available, both
functions are implemented as simple inline calls, otherwise the backend
must provide a definition for usbi_get_monotonic_time() *AND*
usbi_get_real_time() iff the platform is POSIX.

Reading the clocks is also never expected to fail. In practice, if it
ever did there would be much more than libusb that would not function
correctly. The new functions therefore have no return value, thus
allowing the callers to assume success and remove a bunch of error
handling code. The clock_gettime() wrappers have a simple error check
that is only enforced in debug builds.

This change also makes it unnecessary to check for and use
clock_gettime() on Windows, so remove it and always provide
usbi_get_monotonic_time().

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
configure.ac
libusb/core.c
libusb/io.c
libusb/libusbi.h
libusb/os/darwin_usb.c
libusb/os/events_windows.c
libusb/os/threads_posix.c
libusb/os/windows_common.c
libusb/os/windows_winusb.c
libusb/version_nano.h