diff options
Diffstat (limited to 'ppsthread.c')
-rw-r--r-- | ppsthread.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/ppsthread.c b/ppsthread.c index 00037b33..594e8945 100644 --- a/ppsthread.c +++ b/ppsthread.c @@ -53,17 +53,8 @@ #include <stdbool.h> #include <limits.h> #include <errno.h> -#include <pthread.h> #include <math.h> #ifdef S_SPLINT_S -#include <sys/timepps.h> -/*@-incondefs@*/ -typedef long int time_t; -extern int pthread_create (pthread_t *__restrict __newthread, - /*@null@*/const pthread_attr_t *__restrict __attr, - void *(*__start_routine) (void *), - void *__restrict __arg); -/*@+incondefs@*/ /*@-type@*/ int strerror_r(int errnum, char *buf, size_t buflen); /*@+type@*/ @@ -75,6 +66,7 @@ struct timespec }; /*@+matchfields@*/ #else +#include <pthread.h> #include <sys/socket.h> #include <unistd.h> #endif /* S_SPLINT_S */ @@ -174,8 +166,10 @@ static pthread_mutex_t ppslast_mutex = PTHREAD_MUTEX_INITIALIZER; static int init_kernel_pps(volatile struct pps_thread_t *pps_thread) /* return handle for kernel pps, or -1; requires root privileges */ { +#ifndef S_SPLINT_S pps_params_t pp; int pps_caps; +#endif /* S_SPLINT_S */ int ret; #ifdef __linux__ /* These variables are only needed by Linux to find /dev/ppsN. */ @@ -296,6 +290,7 @@ static int init_kernel_pps(volatile struct pps_thread_t *pps_thread) pps_thread->devicename, path, ret); +#ifndef S_SPLINT_S /* RFC 2783 implies the time_pps_setcap() needs priviledges * * keep root a tad longer just in case */ if ( 0 > time_pps_create(ret, (pps_handle_t *)&pps_thread->kernelpps_handle )) { @@ -368,6 +363,7 @@ static int init_kernel_pps(volatile struct pps_thread_t *pps_thread) (void)time_pps_destroy(pps_thread->kernelpps_handle); return -1; } +#endif /* S_SPLINT_S */ return 0; } #endif /* defined(HAVE_SYS_TIMEPPS_H) */ @@ -491,9 +487,10 @@ static int get_edge_rfc2783( volatile struct pps_thread_t *thread_context, int *edge, volatile struct timedelta_t *last_fixtime) { - +#ifndef S_SPLINT_S pps_info_t pi; char ts_str1[TIMESPEC_LEN], ts_str2[TIMESPEC_LEN]; +#endif /* S_SPLINT_S */ struct timespec kernelpps_tv; if ( pps_canwait ) { @@ -521,6 +518,7 @@ static int get_edge_rfc2783( volatile struct pps_thread_t *thread_context, */ memset( (void *)&kernelpps_tv, 0, sizeof(kernelpps_tv)); } +#ifndef S_SPLINT_S memset( (void *)&pi, 0, sizeof(pi)); /* paranoiia, and to shutup splint */ if ( 0 > time_pps_fetch(thread_context->kernelpps_handle, PPS_TSFMT_TSPEC , &pi, &kernelpps_tv)) { @@ -536,6 +534,7 @@ static int get_edge_rfc2783( volatile struct pps_thread_t *thread_context, } return 0; } +#endif /* S_SPLINT_S */ if ( pps_canwait ) { int pthread_err; /* return code from pthread functions */ @@ -564,6 +563,7 @@ static int get_edge_rfc2783( volatile struct pps_thread_t *thread_context, } +#ifndef S_SPLINT_S // find the last edge if ( pi.assert_timestamp.tv_sec > pi.clear_timestamp.tv_sec ) { /* assert 1 sec or more after than clear */ @@ -612,6 +612,7 @@ static int get_edge_rfc2783( volatile struct pps_thread_t *thread_context, (unsigned long) pi.assert_sequence, ts_str2, (unsigned long) pi.clear_sequence); +#endif /* S_SPLINT_S */ thread_context->log_hook(thread_context, THREAD_PROG, "KPPS:%s data: last edge %s\n", thread_context->devicename, @@ -653,7 +654,9 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) #endif /* TIOCMIWAIT */ #if defined(HAVE_SYS_TIMEPPS_H) +#ifndef S_SPLINT_S int pps_caps; +#endif /* S_SPLINT_S */ 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} }; @@ -674,6 +677,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) } /* if no TIOCMIWAIT, we hope to have PPS_CANWAIT */ +#ifndef S_SPLINT_S #if defined(HAVE_SYS_TIMEPPS_H) /* get RFC2783 features supported */ pps_caps = 0; @@ -697,6 +701,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) pps_canwait = true; } #endif /* HAVE_SYS_TIMEPPS_H */ +#endif /* S_SPLINT_S */ if ( not_a_tty && !pps_canwait ) { /* for now, no way to wait for an edge, in the future maybe figure out @@ -1083,7 +1088,7 @@ static /*@null@*/ void *gpsd_ppsmonitor(void *arg) thread_context->log_hook(thread_context, THREAD_PROG, "PPS:%s descriptor cleaned up\n", thread_context->devicename); - (void)time_pps_destroy(thread_context->kernelpps_handle); + /*@i1@*/(void)time_pps_destroy(thread_context->kernelpps_handle); } #endif if (thread_context->wrap_hook != NULL) @@ -1113,7 +1118,7 @@ void pps_thread_activate(volatile struct pps_thread_t *pps_thread) } #endif memset( &pt, 0, sizeof(pt)); - retval = pthread_create(&pt, NULL, gpsd_ppsmonitor, (void *)pps_thread); + /*@i1@*/retval = pthread_create(&pt, NULL, gpsd_ppsmonitor, (void *)pps_thread); pps_thread->log_hook(pps_thread, THREAD_PROG, "PPS:%s thread %s\n", pps_thread->devicename, (retval==0) ? "launched" : "FAILED"); |