From 36a20c1a27af1aa64791a2528c371d39ba33939f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 28 Mar 2011 10:39:49 -0400 Subject: Improve the barrier code and beat GCC harder about not reordering operations. --- NEWS | 8 ++++---- gpsd.h-tail | 4 ++-- libgps_shm.c | 5 +++-- shmexport.c | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index f3fa9759..f4773636 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,12 @@ -* Mon Mar 21 2011 Eric S. Raymond - 3.0~dev +* Mon Mar 28 2011 Eric S. Raymond - 3.0~dev POLL subobject name changes: fixes -> tpv, skyview -> sky. Fix a timestamp-clobbering bug in the C library revealed by an obscure car-nav device, the MyGuide 3100. The DEVICE 'activated' attribute becomes an ISO8601 string; the client libraries will still backward-compatibly read a float value. gps_unpack() is - now a documented part of the library API. There is now an experimental - shared-memory export from the daemon with a working client-library - binding. + now a documented part of the library API. There is now a + shared-memory export from the daemon that can be accessed through + the C and C++ client libraries. * Mon Mar 21 2011 Eric S. Raymond - 2.96 Bumped maximum channel count to 32 to accommodate GPS+GLONASS devices. diff --git a/gpsd.h-tail b/gpsd.h-tail index 62a367f7..73c5834e 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -774,11 +774,11 @@ void cfmakeraw(struct termios *); /* memory barriers */ static /*@unused@*/ inline void barrier(void) { -#ifdef __GNUC__ +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #ifndef S_SPLINT_S asm volatile("sfence"); #endif /* S_SPLINT_S */ -#endif /* __GNUC__ */ +#endif /* defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) */ } #endif /* _GPSD_H_ */ diff --git a/libgps_shm.c b/libgps_shm.c index 7cb63c96..4cb28e26 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -55,7 +55,8 @@ int gps_shm_read(struct gps_data_t *gpsdata) else { int before, after; - struct shmexport_t *shared = (struct shmexport_t *)gpsdata->privdata; + void *private_save = gpsdata->privdata; + volatile struct shmexport_t *shared = (struct shmexport_t *)gpsdata->privdata; struct gps_data_t noclobber; /* @@ -83,7 +84,7 @@ int gps_shm_read(struct gps_data_t *gpsdata) (void)memcpy((void *)gpsdata, (void *)&noclobber, sizeof(struct gps_data_t)); - /*@i1@*/gpsdata->privdata = shared; + /*@i1@*/gpsdata->privdata = private_save; return (int)sizeof(struct gps_data_t); } } diff --git a/shmexport.c b/shmexport.c index eaf8ddf6..bcd78821 100644 --- a/shmexport.c +++ b/shmexport.c @@ -63,7 +63,7 @@ void shm_update(struct gps_context_t *context, struct gps_data_t *gpsdata) if (context->shmexport != NULL) { static int tick; - struct shmexport_t *shared = (struct shmexport_t *)context->shmexport; + volatile struct shmexport_t *shared = (struct shmexport_t *)context->shmexport; ++tick; /* -- cgit v1.2.1