summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ntpshmmon.c2
-rw-r--r--ppsthread.c8
-rw-r--r--ppsthread.h6
3 files changed, 8 insertions, 8 deletions
diff --git a/ntpshmmon.c b/ntpshmmon.c
index a212fe82..56f90aa6 100644
--- a/ntpshmmon.c
+++ b/ntpshmmon.c
@@ -19,7 +19,7 @@
/* difference between timespecs in nanoseconds */
/* int is too small, 32 bit long is too small, avoid floats */
/* MUST be long long to maintain precision on 32 bit code */
-#define timespec_diff_ns(x, y) (long long)(((x).tv_sec-(y).tv_sec)*1000000000+(x).tv_nsec-(y).tv_nsec)
+#define timespec_diff_ns(x, y) (long long)(((x).tv_sec-(y).tv_sec)*1000000000LL+(x).tv_nsec-(y).tv_nsec)
static struct shmTime *segments[NTPSEGMENTS + 1];
static struct timespec tick[NTPSEGMENTS + 1];
diff --git a/ppsthread.c b/ppsthread.c
index 5fae444d..00819cf4 100644
--- a/ppsthread.c
+++ b/ppsthread.c
@@ -619,7 +619,7 @@ static void *gpsd_ppsmonitor(void *arg)
volatile struct timedelta_t last_fixtime = {{0, 0}, {0, 0}};
struct timespec clock_ts = {0, 0};
time_t last_second_used = 0;
- long cycle = 0, duration = 0;
+ long long cycle = 0, duration = 0;
/* state is the last state of the tty control signals */
int state = 0;
/* count of how many cycles unchanged data */
@@ -631,8 +631,8 @@ static void *gpsd_ppsmonitor(void *arg)
#if defined(TIOCMIWAIT)
int edge_tio = 0;
- long cycle_tio = 0;
- long duration_tio = 0;
+ long long cycle_tio = 0;
+ long long duration_tio = 0;
int state_tio = 0;
int state_last_tio = 0;
struct timespec clock_ts_tio = {0, 0};
@@ -641,7 +641,7 @@ static void *gpsd_ppsmonitor(void *arg)
#endif /* TIOCMIWAIT */
#if defined(HAVE_SYS_TIMEPPS_H)
- long cycle_kpps = 0, duration_kpps = 0;
+ long long cycle_kpps = 0, duration_kpps = 0;
/* kpps_pulse stores the time of the last two edges */
struct timespec pulse_kpps[2] = { {0, 0}, {0, 0} };
#endif /* defined(HAVE_SYS_TIMEPPS_H) */
diff --git a/ppsthread.h b/ppsthread.h
index 81faa033..58d4b31a 100644
--- a/ppsthread.h
+++ b/ppsthread.h
@@ -17,9 +17,9 @@ struct timedelta_t {
#endif /* TIMEDELTA_DEFINED */
/* difference between timespecs in nanoseconds */
-/* int is too small, avoid floats */
-/* WARNING! this will overflow if x and y differ by more than a few seconds */
-#define timespec_diff_ns(x, y) (long)(((x).tv_sec-(y).tv_sec)*1000000000+(x).tv_nsec-(y).tv_nsec)
+/* int is too small, 32 bit long is too small, avoid floats */
+/* MUST be long long to maintain precision on 32 bit code */
+#define timespec_diff_ns(x, y) (long long)(((x).tv_sec-(y).tv_sec)*1000000000LL+(x).tv_nsec-(y).tv_nsec)
/*
* Set context, devicefd, and devicename at initialization time, before