Path: blob/main/comms/chu/files/patch-chu.c
16124 views
--- chu.c.orig 1999-03-17 16:42:18 UTC1+++ chu.c2@@ -20,15 +20,21 @@3#include <stdlib.h>4#include <string.h>5#include <math.h>6+#include <errno.h>7+#include <sys/types.h>8#include <sys/time.h>9#include <sys/resource.h>10#include <unistd.h>1112-#define USE_TIMEX13+#define ADJTIME14+#undef USE_TIMEX15+#define USE_ADJTIME16+17+#ifdef ADJTIME18#ifdef USE_TIMEX19#include <sys/timex.h>20#endif21-22+#endif23#define SAMPLE_RATE 800024#define SAMPLES 51225#define OVERLAP 5026@@ -389,6 +395,21 @@ void saveAdjTime()27}28}2930+#ifdef USE_ADJTIME31+void32+do_adjtime(int microsec)33+{34+ struct timeval delta;35+ int status;36+37+ printf("do_adjtime adjustment: %d\n", microsec);38+ delta.tv_sec = 0;39+ delta.tv_usec = microsec;40+ status = adjtime(&delta, NULL);41+ printf("do_adjtime status: %d\n", status);42+}43+#endif44+45#ifdef USE_TIMEX46void timex_adjustment(int microsec)47{48@@ -462,7 +483,8 @@ double gettimexoffset()49adjtimex(&t);50offset = t.offset;51#endif52-53+#ifdef USE_ADJTIME54+#endif55return (double) offset;56}5758@@ -655,13 +677,18 @@ void adj_time(double d)59tv.tv_usec += 1000000;60}6162+#ifdef ADJTIME63#ifdef USE_TIMEX64if (fabs(d) < ((double)MAXPHASE))65{66timex_adjustment((int)-d);67}68+#else69+ if (fabs(d) < ((double)1000000))70+ do_adjtime((int)-d);71else72#endif73+#endif74{75printf("standard adjustment ");7677@@ -1267,7 +1294,7 @@ char *parseArgs(int argc, char **argv)78return fname;79}8081-void main(int argc, char **argv)82+int main(int argc, char **argv)83{84FILE *fp;85signed char buf[8192];86@@ -1278,7 +1305,7 @@ void main(int argc, char **argv)8788fname = parseArgs(argc, argv);89if (fname == NULL)90- return;91+ return 0;9293/* Set priority to maximum -- just long enough for us94to open the audio device and timestamp it. This should95@@ -1293,7 +1320,7 @@ void main(int argc, char **argv)96if (fp == NULL)97{98printf("fopen(): Unable to open file: %s %s\n", fname, strerror(errno));99- return;100+ return 0;101}102103gettimeofday(&starttime, &tz);104105106