Date: Mon, 23 Mar 2015 12:50:36 +0000 (UTC) From: Jakub Wojciech Klama <jceel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r280366 - user/jceel/soc2014_evdev/contrib/libevdev/tools Message-ID: <201503231250.t2NCoa28053748@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jceel Date: Mon Mar 23 12:50:35 2015 New Revision: 280366 URL: https://svnweb.freebsd.org/changeset/base/280366 Log: Further FreeBSD adaptation. Use pselect() instead of non-standard signalfd() and argv[0] instead of program_invocation_short_name. Modified: user/jceel/soc2014_evdev/contrib/libevdev/tools/touchpad-edge-detector.c Modified: user/jceel/soc2014_evdev/contrib/libevdev/tools/touchpad-edge-detector.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/tools/touchpad-edge-detector.c Mon Mar 23 12:48:42 2015 (r280365) +++ user/jceel/soc2014_evdev/contrib/libevdev/tools/touchpad-edge-detector.c Mon Mar 23 12:50:35 2015 (r280366) @@ -26,7 +26,7 @@ #endif #include <libevdev/libevdev.h> -#include <sys/signalfd.h> +#include <sys/select.h> #include <errno.h> #include <fcntl.h> #include <limits.h> @@ -42,8 +42,8 @@ #define max(a, b) (((a) > (b)) ? (a) : (b)) static int -usage(void) { - printf("Usage: %s /dev/input/event0\n", program_invocation_short_name); +usage(const char *name) { + printf("Usage: %s /dev/input/event0\n", name); printf("\n"); printf("This tool reads the touchpad events from the kernel and calculates\n " "the minimum and maximum for the x and y coordinates, respectively.\n"); @@ -99,24 +99,23 @@ handle_event(struct dimensions *d, const static int mainloop(struct libevdev *dev, struct dimensions *dim) { - struct pollfd fds[2]; + fd_set fds; sigset_t mask; + int ev_fd = libevdev_get_fd(dev); - fds[0].fd = libevdev_get_fd(dev); - fds[0].events = POLLIN; + FD_ZERO(&fds); + FD_SET(ev_fd, &fds); sigemptyset(&mask); sigaddset(&mask, SIGINT); - fds[1].fd = signalfd(-1, &mask, SFD_NONBLOCK); - fds[1].events = POLLIN; sigprocmask(SIG_BLOCK, &mask, NULL); - while (poll(fds, 2, -1)) { + while (pselect(ev_fd + 1, &fds, NULL, NULL, NULL, &mask)) { struct input_event ev; int rc; - if (fds[1].revents) + if (FD_ISSET(ev_fd, &fds)) break; do { @@ -144,11 +143,11 @@ int main (int argc, char **argv) { struct dimensions dim; if (argc < 2) - return usage(); + return usage(argv[0]); path = argv[1]; if (path[0] == '-') - return usage(); + return usage(argv[0]); fd = open(path, O_RDONLY|O_NONBLOCK); if (fd < 0) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503231250.t2NCoa28053748>