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_geostar.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_geostar.c')
-rw-r--r-- | driver_geostar.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/driver_geostar.c b/driver_geostar.c index 5bacbfcf..25b61bde 100644 --- a/driver_geostar.c +++ b/driver_geostar.c @@ -11,11 +11,10 @@ */ #if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L -/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */ +/* isfinite() needs _POSIX_C_SOURCE >= 200112L */ #define _POSIX_C_SOURCE 200112L #endif /* _POSIX_C_SOURCE */ -#include <sys/time.h> /* for pselect() */ #include <stdbool.h> #include <stdio.h> #include <math.h> @@ -24,8 +23,7 @@ #include "gpsd.h" #include "bits.h" #include "strfuncs.h" - -#include <sys/select.h> +#include "timespec.h" #ifdef GEOSTAR_ENABLE #define GEOSTAR_CHANNELS 24 @@ -91,8 +89,6 @@ static bool geostar_detect(struct gps_device_t *session) unsigned char buf[1 * 4]; bool ret = false; int myfd; - fd_set fdset; - struct timespec to; myfd = session->gpsdata.gps_fd; @@ -101,11 +97,7 @@ static bool geostar_detect(struct gps_device_t *session) if (geostar_write(session, 0xc1, buf, 1) == 0) { 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 == GEOSTAR_PACKET) { |