diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-10-03 10:45:29 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-10-03 10:45:29 -0400 |
commit | db993006c341f476e80cf7f1aba59081d2947ab3 (patch) | |
tree | 0b8c0a8d324819cd810c8ef4317a91a213e45909 /libgps_shm.c | |
parent | ecf1b666629bd74e4b5e28ec0edd1f787c737476 (diff) | |
download | gpsd-db993006c341f476e80cf7f1aba59081d2947ab3.tar.gz |
First cut at implementing waiting test for shm export.
Timeout argument is presently ignored.
Diffstat (limited to 'libgps_shm.c')
-rw-r--r-- | libgps_shm.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libgps_shm.c b/libgps_shm.c index b28b13a7..1ea25c67 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -31,6 +31,7 @@ PERMISSIONS struct privdata_t { void *shmseg; + int tick; }; /*@+matchfields@*/ @@ -65,6 +66,18 @@ int gps_shm_open(/*@out@*/struct gps_data_t *gpsdata) return 0; } +bool gps_shm_waiting(const struct gps_data_t *gpsdata, int timeout UNUSED) +/* check to see if new dayta has been written */ +{ + volatile struct shmexport_t *shared = (struct shmexport_t *)PRIVATE(gpsdata)->shmseg; + bool newdata; + + barrier(); + newdata = (shared->bookend1 == shared->bookend2 && shared->bookend1 > PRIVATE(gpsdata)->tick + timeout); + barrier(); + return newdata; +} + int gps_shm_read(struct gps_data_t *gpsdata) /* read an update from the shared-memory segment */ { @@ -104,6 +117,7 @@ int gps_shm_read(struct gps_data_t *gpsdata) (void *)&noclobber, sizeof(struct gps_data_t)); /*@i1@*/gpsdata->privdata = private_save; + PRIVATE(gpsdata)->tick = after; if ((gpsdata->set & REPORT_IS)!=0) { if (gpsdata->fix.mode >= 2) gpsdata->status = STATUS_FIX; |