summaryrefslogtreecommitdiff
path: root/libusb/os/linux_usbfs.c
diff options
context:
space:
mode:
authorNathan Hjelm <hjelmn@mac.com>2009-02-16 21:25:18 -0300
committerDaniel Drake <dsd@gentoo.org>2009-02-16 21:25:51 -0300
commit9196f58bdc8b9e967261df39865215faa5d39cfa (patch)
tree68cda454a4a72c0ac77553b91c9802c8d4fad65e /libusb/os/linux_usbfs.c
parente91207860cac09b3afaafc4c14221b78d585c59a (diff)
downloadlibusb-9196f58bdc8b9e967261df39865215faa5d39cfa.tar.gz
Abstract clock reading into OS layer
This will differ on Linux and Darwin, at least. [dsd: minor style tweaks]
Diffstat (limited to 'libusb/os/linux_usbfs.c')
-rw-r--r--libusb/os/linux_usbfs.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 46e770c..7727ba6 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1999,6 +1999,18 @@ out:
return r;
}
+static int op_clock_gettime(int clk_id, struct timespec *tp)
+{
+ switch (clk_id) {
+ case USBI_CLOCK_MONOTONIC:
+ return clock_gettime(CLOCK_MONOTONIC, tp);
+ case USBI_CLOCK_REALTIME:
+ return clock_gettime(CLOCK_REALTIME, tp);
+ default:
+ return LIBUSB_ERROR_INVALID_PARAM;
+ }
+}
+
const struct usbi_os_backend linux_usbfs_backend = {
.name = "Linux usbfs",
.init = op_init,
@@ -2031,6 +2043,8 @@ const struct usbi_os_backend linux_usbfs_backend = {
.handle_events = op_handle_events,
+ .clock_gettime = op_clock_gettime,
+
.device_priv_size = sizeof(struct linux_device_priv),
.device_handle_priv_size = sizeof(struct linux_device_handle_priv),
.transfer_priv_size = sizeof(struct linux_transfer_priv),