diff options
author | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2024-11-01 08:38:25 +0000 |
---|---|---|
committer | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2024-11-01 08:38:25 +0000 |
commit | ca50c0f64f1b2fce46b4cb83ed111854bac13852 (patch) | |
tree | 92713a6fb08559f6f7ddd4e03781572eba0a7f02 /Radio/HW/RtlSdr/libusb/os/events_posix.h | |
parent | e3a7f5bafec6715cd11555c39925665c78029dd9 (diff) | |
download | PrySDR-ca50c0f64f1b2fce46b4cb83ed111854bac13852.tar.gz PrySDR-ca50c0f64f1b2fce46b4cb83ed111854bac13852.zip |
rtlsdr library example compiles
Diffstat (limited to 'Radio/HW/RtlSdr/libusb/os/events_posix.h')
-rw-r--r-- | Radio/HW/RtlSdr/libusb/os/events_posix.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Radio/HW/RtlSdr/libusb/os/events_posix.h b/Radio/HW/RtlSdr/libusb/os/events_posix.h new file mode 100644 index 0000000..d81b5c4 --- /dev/null +++ b/Radio/HW/RtlSdr/libusb/os/events_posix.h @@ -0,0 +1,59 @@ +/* + * libusb event abstraction on POSIX platforms + * + * Copyright © 2020 Chris Dickens <christopher.a.dickens@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef LIBUSB_EVENTS_POSIX_H +#define LIBUSB_EVENTS_POSIX_H + +#include <poll.h> + +typedef int usbi_os_handle_t; +#define USBI_OS_HANDLE_FORMAT_STRING "fd %d" + +#ifdef HAVE_EVENTFD +typedef struct usbi_event { + int eventfd; +} usbi_event_t; +#define USBI_EVENT_OS_HANDLE(e) ((e)->eventfd) +#define USBI_EVENT_POLL_EVENTS POLLIN +#define USBI_INVALID_EVENT { -1 } +#else +typedef struct usbi_event { + int pipefd[2]; +} usbi_event_t; +#define USBI_EVENT_OS_HANDLE(e) ((e)->pipefd[0]) +#define USBI_EVENT_POLL_EVENTS POLLIN +#define USBI_INVALID_EVENT { { -1, -1 } } +#endif + +#ifdef HAVE_TIMERFD +#define HAVE_OS_TIMER 1 +typedef struct usbi_timer { + int timerfd; +} usbi_timer_t; +#define USBI_TIMER_OS_HANDLE(t) ((t)->timerfd) +#define USBI_TIMER_POLL_EVENTS POLLIN + +static inline int usbi_timer_valid(usbi_timer_t *timer) +{ + return timer->timerfd >= 0; +} +#endif + +#endif |