6b9fde9c55ed7efb275c2ef9517692d93bbbb1ab
[packages.git] / libs / libusb-1.0 / patches / 001-timerfd.patch
1 commit cadb77d99e314e42c3eb02d016e9d90136ec6959
2 Author: Alexander Gordeev <lasaine@lvk.cs.msu.su>
3 Date:   Thu Jan 27 06:39:16 2011 +0300
4
5     fix timerfd initialization
6     
7     sys/timerfd.h defines TFD_NONBLOCK as 0x800 but in kernel TFD_NONBLOCK
8     is an alias for O_NONBLOCK which is defined in arch-specific fcntl.h.
9     While it's still 0x800 for most of archs but for mips it's 0x80. So
10     timerfd_create(..., TFD_NONBLOCK) returns -EINVAL because of that. Fix
11     this by using O_NONBLOCK instead.
12     
13     Signed-off-by: Alexander Gordeev <lasaine@lvk.cs.msu.su>
14
15 diff --git a/libusb/io.c b/libusb/io.c
16 index 1379eb3..250b8dc 100644
17 --- a/libusb/io.c
18 +++ b/libusb/io.c
19 @@ -20,6 +20,7 @@
20  
21  #include <config.h>
22  #include <errno.h>
23 +#include <fcntl.h>
24  #include <poll.h>
25  #include <pthread.h>
26  #include <signal.h>
27 @@ -1025,7 +1026,7 @@ int usbi_io_init(struct libusb_context *ctx)
28  
29  #ifdef USBI_TIMERFD_AVAILABLE
30         ctx->timerfd = timerfd_create(usbi_backend->get_timerfd_clockid(),
31 -               TFD_NONBLOCK);
32 +               O_NONBLOCK);
33         if (ctx->timerfd >= 0) {
34                 usbi_dbg("using timerfd for timeouts");
35                 r = usbi_add_pollfd(ctx, ctx->timerfd, POLLIN);