3 week bump. -- Scott Cheloha
> On Aug 16, 2017, at 8:46 PM, Scott Cheloha <scottchel...@gmail.com> wrote: > > Hi, > > Same deal here as in dd(1). We display the elapsed time so we want > a monotonic clock. > > -- > Scott Cheloha > > Index: usr.bin/tftp/tftp.c > =================================================================== > RCS file: /cvs/src/usr.bin/tftp/tftp.c,v > retrieving revision 1.24 > diff -u -p -r1.24 tftp.c > --- usr.bin/tftp/tftp.c 21 Oct 2014 06:15:16 -0000 1.24 > +++ usr.bin/tftp/tftp.c 17 Aug 2017 01:44:46 -0000 > @@ -52,6 +52,7 @@ > #include <stddef.h> > #include <stdlib.h> > #include <string.h> > +#include <time.h> > #include <unistd.h> > #include <netdb.h> > > @@ -83,8 +84,8 @@ extern int opt_tsize; > extern int opt_tout; > extern int opt_blksize; > > -struct timeval tstart; > -struct timeval tstop; > +struct timespec tstart; > +struct timespec tstop; > unsigned int segment_size = SEGSIZE; > unsigned int packet_size = SEGSIZE + 4; > > @@ -548,13 +549,13 @@ tpacket(const char *s, struct tftphdr *t > static void > startclock(void) > { > - (void)gettimeofday(&tstart, NULL); > + clock_gettime(CLOCK_MONOTONIC, &tstart); > } > > static void > stopclock(void) > { > - (void)gettimeofday(&tstop, NULL); > + clock_gettime(CLOCK_MONOTONIC, &tstop); > } > > static void > @@ -563,8 +564,8 @@ printstats(const char *direction, unsign > double delta; > > /* compute delta in 1/10's second units */ > - delta = ((tstop.tv_sec * 10.) + (tstop.tv_usec / 100000)) - > - ((tstart.tv_sec * 10.) + (tstart.tv_usec / 100000)); > + delta = ((tstop.tv_sec * 10.) + (tstop.tv_nsec / 100000000)) - > + ((tstart.tv_sec * 10.) + (tstart.tv_nsec / 100000000)); > delta = delta / 10.; /* back to seconds */ > printf("%s %lu bytes in %.1f seconds", direction, amount, delta); > if (verbose)