1999-10-16 Harlan Stenn <stenn@whimsy.udel.edu>
+ * parseutil/dcfd.c: abs() -> l_abs(), time.h (AIX 4.3.2 patches)
+ From: Dana Kaempen <decay@flash.net>
+
+ * ntpd/refclock_oncore.c:
+ * ntpd/refclock_atom.c:
+ * ntpd/ntp_refclock.c:
+ PPS cleanup
+ From: John.Hay@mikom.csir.co.za
+
* util/ntptime.c:
* ntpdate/ntptimeset.c:
* ntpdate/ntpdate.c:
#endif
#ifdef HAVE_PPSAPI
pps_info_t pi;
- struct timespec *tsp;
+ struct timespec timeout, *tsp;
double a;
#endif
trtmp = rbufp->recv_time;
#ifdef HAVE_PPSAPI
- if (rbufp->fd == fdpps && time_pps_fetch(fdpps, 0, &pi, 0) >= 0) {
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 0;
+ if ((rbufp->fd == fdpps) &&
+ (time_pps_fetch(fdpps, PPS_TSFMT_TSPEC, &pi, &timeout) >= 0)) {
if(pps_assert)
tsp = &pi.assert_timestamp;
else
}
if (pps_hardpps) {
if (pps_assert)
- mode |= PPS_CAPTUREASSERT;
+ mode = PPS_CAPTUREASSERT;
else
- mode |= PPS_CAPTURECLEAR;
- }
- if (time_pps_kcbind(fdpps, 0, mode, 0) < 0) {
- msyslog(LOG_ERR,
- "refclock_ioctl: time_pps_kpcbind failed");
- fdpps = 0;
- return (0);
+ mode = PPS_CAPTURECLEAR;
+ if (time_pps_kcbind(fdpps, PPS_KC_HARDPPS, mode,
+ PPS_TSFMT_TSPEC) < 0) {
+ msyslog(LOG_ERR,
+ "refclock_ioctl: time_pps_kcbind failed");
+ fdpps = 0;
+ return (0);
+ }
}
}
#endif /* HAVE_PPSAPI */
register struct atomunit *up;
struct refclockproc *pp;
#ifdef HAVE_PPSAPI
+ struct timespec timeout;
# ifdef HAVE_TIMESPEC
struct timespec ts;
# else
i = up->pps_info.assert_sequence;
if (fdpps <= 0)
return (1);
- if (time_pps_fetch(fdpps, 0, &up->pps_info, 0) < 0)
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 0;
+ if (time_pps_fetch(fdpps, PPS_TSFMT_TSPEC, &up->pps_info, &timeout) < 0)
return (1);
if (i == up->pps_info.assert_sequence)
return (2);
instance->pps_p.clear_offset.tv_sec = 0;
instance->pps_p.clear_offset.tv_nsec = 0;
}
-/*
- if (time_pps_setparams(instance->pps_h, &instance->pps_p) < 0)
- instance->pps_p.mode &= ~(PPS_HARDPPSONCLEAR|PPS_HARDPPSONASSERT);
-*/
+ instance->pps_p.mode |= PPS_TSFMT_TSPEC;
if (time_pps_setparams(instance->pps_h, &instance->pps_p) < 0) {
perror("time_pps_setparams");
exit(1);
}
+ if (time_pps_kcbind(instance->pps_h, PPS_KC_HARDPPS,
+ instance->pps_p.mode & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR),
+ PPS_TSFMT_TSPEC) < 0) {
+ perror("time_pps_kcbind");
+ }
#endif
instance->pp = pp;
instance->peer = peer;
struct timeval *tsp = 0;
#endif
#ifdef HAVE_PPSAPI
+ struct timespec timeout;
pps_info_t pps_i;
#else /* ! HAVE_PPSAPI */
#ifdef HAVE_CIOGETEV
#ifdef HAVE_PPSAPI
j = instance->ev_serial;
- if (time_pps_fetch(instance->pps_h, 0, &pps_i, 0) < 0) {
+ timeout.tv_sec = 0;
+ timeout.tv_nsec = 0;
+ if (time_pps_fetch(instance->pps_h, PPS_TSFMT_TSPEC, &pps_i,
+ &timeout) < 0) {
printf("ONCORE: time_pps_fetch failed\n");
return;
}
#include <sys/time.h>
#include <signal.h>
#include <syslog.h>
+#include <time.h>
/*
* NTP compilation environment
#define TIMES24(_X_) (((_X_) << 4) + ((_X_) << 3)) /* *16 + *8 */
#define TIMES60(_X_) ((((_X_) << 4) - (_X_)) << 2) /* *(16 - 1) *4 */
/*
- * generic abs() function
+ * generic l_abs() function
*/
-#define abs(_x_) (((_x_) < 0) ? -(_x_) : (_x_))
+#define l_abs(_x_) (((_x_) < 0) ? -(_x_) : (_x_))
/*
* conversion related return/error codes
static char buf[20];
if (val->tv_sec == 0)
- sprintf(buf, "%c0.%06ld", (val->tv_usec < 0) ? '-' : '+', (long int)abs(val->tv_usec));
+ sprintf(buf, "%c0.%06ld", (val->tv_usec < 0) ? '-' : '+', (long int)l_abs(val->tv_usec));
else
- sprintf(buf, "%ld.%06ld", (long int)val->tv_sec, (long int)abs(val->tv_usec));
+ sprintf(buf, "%ld.%06ld", (long int)val->tv_sec, (long int)l_abs(val->tv_usec));
return buf;
}
LPRINTF("update_drift: drift_comp %ld ", (long int)accum_drift);
fdrift = (fdrift * 1000) / (1<<USECSCALE);
fprintf(df, "%4d.%03d %c%ld.%06ld %.24s\n", idrift, fdrift,
- (offset < 0) ? '-' : '+', (long int)(abs(offset) / 1000000),
- (long int)(abs(offset) % 1000000), asctime(localtime(&reftime)));
+ (offset < 0) ? '-' : '+', (long int)(l_abs(offset) / 1000000),
+ (long int)(l_abs(offset) % 1000000), asctime(localtime(&reftime)));
fclose(df);
LPRINTF("update_drift: %d.%03d ppm ", idrift, fdrift);
}
}
toffset = *offset;
- toffset.tv_sec = abs(toffset.tv_sec);
- toffset.tv_usec = abs(toffset.tv_usec);
+ toffset.tv_sec = l_abs(toffset.tv_sec);
+ toffset.tv_usec = l_abs(toffset.tv_usec);
if (timercmp(&toffset, &max_adj_offset, >))
{
/*
(clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_",
(clock_time.flags & DCFB_DST) ? "D" : "_",
(clock_time.flags & DCFB_LEAP) ? "L" : "_",
- (lasterror < 0) ? '-' : '+', abs(lasterror) / 1000000, abs(lasterror) % 1000000
+ (lasterror < 0) ? '-' : '+', l_abs(lasterror) / 1000000, l_abs(lasterror) % 1000000
);
if (trace && (i == 0))