summaryrefslogtreecommitdiff
path: root/gps2udp.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2018-12-26 13:23:04 -0500
committerEric S. Raymond <esr@thyrsus.com>2018-12-26 13:23:04 -0500
commit5517175ed53b877720fdf5a1a4085386b40c4590 (patch)
tree31c1ce53dea117cfb36a1e7d679cb785b32abdf8 /gps2udp.c
parentc9e81aabcf2f5c6886be1fd0e859ceb63470e06f (diff)
downloadgpsd-5517175ed53b877720fdf5a1a4085386b40c4590.tar.gz
Eliminate effectively all uses of struct timeval.
Outide of one Mac portability shim, anyway. Associated select(2) calls become pselect(2) calls.
Diffstat (limited to 'gps2udp.c')
-rw-r--r--gps2udp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gps2udp.c b/gps2udp.c
index 4e79b729..467919bf 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -15,6 +15,11 @@
/* strsep() needs _DEFAULT_SOURCE */
#define _DEFAULT_SOURCE
+#ifdef __linux__
+/* isfinite() and pselect() needs _POSIX_C_SOURCE >= 200112L */
+#define _POSIX_C_SOURCE 200112L
+#endif /* __linux__ */
+
#include <time.h>
#include "gpsd_config.h"
@@ -230,7 +235,7 @@ static void connect2gpsd(bool restart)
static ssize_t read_gpsd(char *message, size_t len)
/* get data from gpsd */
{
- struct timeval tv;
+ struct timespec tv;
fd_set fds,master;
int ind;
char c;
@@ -248,9 +253,9 @@ static ssize_t read_gpsd(char *message, size_t len)
int result;
/* prepare for a blocking read with a 10s timeout */
tv.tv_sec = 10;
- tv.tv_usec = 0;
+ tv.tv_nsec = 0;
fds = master;
- result = select(gpsdata.gps_fd+1, &fds, NULL, NULL, &tv);
+ result = pselect(gpsdata.gps_fd+1, &fds, NULL, NULL, &tv, NULL);
switch (result)
{