diff options
-rw-r--r-- | gpsd.h-tail | 9 | ||||
-rw-r--r-- | libgps_shm.c | 8 | ||||
-rw-r--r-- | shmexport.c | 8 |
3 files changed, 13 insertions, 12 deletions
diff --git a/gpsd.h-tail b/gpsd.h-tail index f0f01519..bd859e8f 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -758,6 +758,15 @@ void cfmakeraw(struct termios *); #define DEVICEHOOKPATH SYSCONFDIR"/gpsd/device-hook" +/* memory barriers */ +static inline void barrier(void) { +#ifdef __GNUC__ +#ifndef S_SPLINT_S + asm volatile("sfence"); +#endif /* S_SPLINT_S */ +#endif /* __GNUC__ */ +} + #endif /* _GPSD_H_ */ // Local variables: // mode: c diff --git a/libgps_shm.c b/libgps_shm.c index 56fe5e5a..8c90f524 100644 --- a/libgps_shm.c +++ b/libgps_shm.c @@ -66,15 +66,11 @@ int gps_shm_read(struct gps_data_t *gpsdata) * get clobbered first and the data can be detected as bad. */ before = shared->bookend1; -#ifndef S_SPLINT_S - asm volatile("sfence"); -#endif /* S_SPLINT_S */ + barrier(); (void)memcpy((void *)gpsdata, (void *)&shared->gpsdata, sizeof(struct gps_data_t)); -#ifndef S_SPLINT_S - asm volatile("sfence"); -#endif /* S_SPLINT_S */ + barrier(); after = shared->bookend2; /*@i1@*/gpsdata->privdata = shared; diff --git a/shmexport.c b/shmexport.c index d9aad54c..4d615abf 100644 --- a/shmexport.c +++ b/shmexport.c @@ -77,15 +77,11 @@ void shm_update(struct gps_context_t *context, struct gps_data_t *gpsdata) * get clobbered first and the data can be detected as bad. */ ((struct shmexport_t *)context->shmexport)->bookend2 = tick; -#ifndef S_SPLINT_S - asm volatile("sfence"); -#endif /* S_SPLINT_S */ + barrier(); memcpy((void *)(context->shmexport + offsetof(struct shmexport_t, gpsdata)), (void *)gpsdata, sizeof(struct gps_data_t)); -#ifndef S_SPLINT_S - asm volatile("sfence"); -#endif /* S_SPLINT_S */ + barrier(); ((struct shmexport_t *)context->shmexport)->bookend1 = tick; } } |