diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2018-12-27 05:39:42 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2018-12-27 05:39:42 -0500 |
commit | 1998c0301f6f9542bf5dd51e8d18f3d7f4e76023 (patch) | |
tree | 47b092141978039c773e4a4e9f992eab90ee340b /driver_tsip.c | |
parent | e81cfb77ab1a8de2e7cac6883e632124bcbe6f35 (diff) | |
download | gpsd-1998c0301f6f9542bf5dd51e8d18f3d7f4e76023.tar.gz |
Factor most uses of pselect(2) into a new utility function named 'nanowait'.
Also, remove sime header inclusions discovered to be unnecessary during
the change.
Diffstat (limited to 'driver_tsip.c')
-rw-r--r-- | driver_tsip.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/driver_tsip.c b/driver_tsip.c index cb30394b..55010584 100644 --- a/driver_tsip.c +++ b/driver_tsip.c @@ -26,7 +26,6 @@ #endif -#include <sys/time.h> /* for pselect() */ #include <string.h> #include <stdio.h> #include <stdbool.h> @@ -37,8 +36,7 @@ #include "gpsd.h" #include "bits.h" #include "strfuncs.h" - -#include <sys/select.h> +#include "timespec.h" #define USE_SUPERPACKET 1 /* use Super Packet mode? */ @@ -85,8 +83,6 @@ static bool tsip_detect(struct gps_device_t *session) char buf[BUFSIZ]; bool ret = false; int myfd; - fd_set fdset; - struct timespec to; speed_t old_baudrate; char old_parity; unsigned int old_stopbits; @@ -105,11 +101,7 @@ static bool tsip_detect(struct gps_device_t *session) if (write(myfd, buf, 4) == 4) { unsigned int n; for (n = 0; n < 3; n++) { - FD_ZERO(&fdset); - FD_SET(myfd, &fdset); - to.tv_sec = 1; - to.tv_nsec = 0; - if (pselect(myfd + 1, &fdset, NULL, NULL, &to, NULL) != 1) + if (!nanowait(myfd, NS_IN_SEC)) break; if (generic_get(session) >= 0) { if (session->lexer.type == TSIP_PACKET) { |