diff options
author | Gary E. Miller <gem@rellim.com> | 2011-03-18 17:07:58 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2011-03-18 17:07:58 -0700 |
commit | 3a99db10a4eef3c3f72a3fba5d0a418cd79f2de8 (patch) | |
tree | c477acb3e4b36af8dc40f61e65ffbf843e8e3c0b | |
parent | cf684b2a9909561a537a5189c4a2b6a76e3c105d (diff) | |
download | gpsd-3a99db10a4eef3c3f72a3fba5d0a418cd79f2de8.tar.gz |
thomas@mich.com pointed out that ntpd SHM needs to be volatile.
I checked the ntpd source code and mirrored how they marked the SHM
as volatile. This could prevent potential misoptimization by the
C compile.
-rw-r--r-- | ntpshm.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -126,7 +126,7 @@ static /*@null@*/ struct shmTime *getShmTime(int unit) (int)perms, strerror(errno)); return NULL; } else { - struct shmTime *p = (struct shmTime *)shmat(shmid, 0, 0); + volatile struct shmTime *p = (struct shmTime *)shmat(shmid, 0, 0); /*@ -mustfreefresh */ if ((int)(long)p == -1) { gpsd_report(LOG_ERROR, "NTPD shmat failed: %s\n", @@ -193,7 +193,7 @@ bool ntpshm_free(struct gps_context_t * context, int segment) int ntpshm_put(struct gps_device_t *session, double fixtime, double fudge) /* put a received fix time into shared memory for NTP */ { - struct shmTime *shmTime = NULL; + volatile struct shmTime *shmTime = NULL; struct timeval tv; double seconds, microseconds; @@ -256,7 +256,7 @@ int ntpshm_put(struct gps_device_t *session, double fixtime, double fudge) */ int ntpshm_pps(struct gps_device_t *session, struct timeval *tv) { - struct shmTime *shmTime = NULL, *shmTimeP = NULL; + volatile struct shmTime *shmTime = NULL, *shmTimeP = NULL; time_t seconds; /* FIX-ME, microseconds needs to be set for 5Hz PPS */ int microseconds = 0; |