pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/33897: benchmarks/ttcp is not 64-bit clean (alpha/ultrasparc)



The following reply was made to PR pkg/33897; it has been noted by GNATS.

From: "Erik E. Fair" <fair%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: pkg/33897: benchmarks/ttcp is not 64-bit clean (alpha/ultrasparc) 
Date: Mon, 03 Jul 2006 01:53:55 -0700

 *** ttcp.c.orig        Thu Feb 27 13:30:23 1997
 --- ttcp.c     Sun Jul  2 20:12:26 2006
 ***************
 *** 31,36 ****
 --- 31,38 ----
    * Modified Oct. 1991 at Silicon Graphics, Inc.
    *   use getopt(3) for option processing, add -f and -T options.
    *   SGI IRIX 3.3 and 4.0 releases don't need #define SYSV.
 +  * Modified July 2006 by the NetBSD Project
 +  *      for modern APIs and LP64
    *
    * Distribution Status -
    *      Public Domain.  Distribution Unlimited.
 ***************
 *** 44,49 ****
 --- 46,55 ----
   /* #define BSD41a */
   /* #define SYSV */   /* required on SGI IRIX releases before 3.3 */
   
 + #include <unistd.h>
 + #include <stdlib.h>
 + #include <string.h>
 + #include <strings.h>
   #include <stdio.h>
   #include <signal.h>
   #include <ctype.h>
 ***************
 *** 67,90 ****
   #include <sys/resource.h>
   #endif
   
 ! struct sockaddr_in sinme;
 ! struct sockaddr_in sinhim;
 ! struct sockaddr_in frominet;
   
 ! int domain, fromlen;
   int fd;                              /* fd of network socket */
   
 ! int buflen = 8 * 1024;               /* length of buffer */
   char *buf;                   /* ptr to dynamic buffer */
 ! int nbuf = 2 * 1024;         /* number of buffers to send in sinkmode */
   
   int bufoffset = 0;           /* align buffer to this */
 ! int bufalign = 16*1024;              /* modulo this */
   
   int udp = 0;                 /* 0 = tcp, !0 = udp */
   int options = 0;             /* socket options */
   int one = 1;                    /* for 4.3 BSD style setsockopt() */
 ! short port = 5001;           /* TCP port number */
   char *host;                  /* ptr to name of host */
   int trans;                   /* 0=receive, !0=transmit mode */
   int sinkmode = 0;            /* 0=normal I/O, !0=sink/source mode */
 --- 73,136 ----
   #include <sys/resource.h>
   #endif
   
 ! /* time to ANSIfy */
   
 ! void delay( long us );
 ! 
 ! ssize_t      mread( int fd, void *bufp, size_t n );
 ! 
 ! ssize_t      Nwrite( int fd, void *buf, size_t count );
 ! 
 ! ssize_t      Nread( int fd, void *buf, size_t count );
 ! 
 ! void mes( const char *s );
 ! 
 ! static void  err( const char *s );
 ! 
 ! void pattern( char *cp, ssize_t cnt );
 ! 
 ! void prep_timer();
 ! 
 ! double       read_timer( char *str, size_t len );
 ! 
 ! char *       outfmt( double b );
 ! 
 ! static void  prusage( struct rusage *r0, struct rusage *r1,
 !      struct timeval *e, struct timeval *b, char *outp );
 ! 
 ! static void  tvadd( struct timeval *tsum, struct timeval *t0, struct timeval 
*t1 );
 ! 
 ! static void  tvsub( struct timeval *tdiff, struct timeval *t1, struct 
timeval *t0 );
 ! 
 ! static void  psecs( long l, char *cp );
 ! 
 ! #define      DEFPORT         5001
 ! #define      DEFALIGN        (16 * 1024)
 ! #define      DEFBUFSZ        (8 * 1024)
 ! #define      DEFNBUFS2SEND   (2 * 1024)
 ! 
 ! #define      KILO            1000
 ! #define      MEGA            (KILO * KILO)
 ! #define      GIGA            (MEGA * KILO)
 ! 
 ! struct sockaddr_in sinme = { sizeof(struct sockaddr_in), AF_INET, DEFPORT };
 ! struct sockaddr_in sinhim = { sizeof(struct sockaddr_in), AF_INET, DEFPORT };
 ! struct sockaddr_in frominet = { sizeof(struct sockaddr_in), AF_INET, DEFPORT 
};
 ! 
 ! socklen_t fromlen;
   int fd;                              /* fd of network socket */
   
 ! ssize_t buflen = DEFBUFSZ;   /* length of buffer */
   char *buf;                   /* ptr to dynamic buffer */
 ! int nbuf = DEFNBUFS2SEND;    /* number of buffers to send in sinkmode */
   
   int bufoffset = 0;           /* align buffer to this */
 ! int bufalign = DEFALIGN;     /* modulo this */
   
   int udp = 0;                 /* 0 = tcp, !0 = udp */
   int options = 0;             /* socket options */
   int one = 1;                    /* for 4.3 BSD style setsockopt() */
 ! in_port_t port = DEFPORT;    /* TCP port number */
   char *host;                  /* ptr to name of host */
   int trans;                   /* 0=receive, !0=transmit mode */
   int sinkmode = 0;            /* 0=normal I/O, !0=sink/source mode */
 ***************
 *** 107,125 ****
   Usage: ttcp -t [-options] host [ < in ]\n\
          ttcp -r [-options > out]\n\
   Common options:\n\
 !      -l ##   length of bufs read from or written to network (default 8192)\n\
        -u      use UDP instead of TCP\n\
 !      -p ##   port number to send to or listen at (default 5001)\n\
        -s      -t: source a pattern to network\n\
                -r: sink (discard) all data from network\n\
 !      -A      align the start of buffers to this modulus (default 16384)\n\
        -O      start buffers at this offset from the modulus (default 0)\n\
        -v      verbose: print more statistics\n\
        -d      set SO_DEBUG socket option\n\
        -b ##   set socket buffer size (if supported)\n\
        -f X    format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga\n\
   Options specific to -t:\n\
 !      -n##    number of source bufs written to network (default 2048)\n\
        -D      don't buffer TCP writes (sets TCP_NODELAY socket option)\n\
   Options specific to -r:\n\
        -B      for -s, only output full blocks as specified by -l (for TAR)\n\
 --- 153,171 ----
   Usage: ttcp -t [-options] host [ < in ]\n\
          ttcp -r [-options > out]\n\
   Common options:\n\
 !      -l ##   length of bufs read from or written to network (default %lu)\n\
        -u      use UDP instead of TCP\n\
 !      -p ##   port number to send to or listen at (default %u)\n\
        -s      -t: source a pattern to network\n\
                -r: sink (discard) all data from network\n\
 !      -A      align the start of buffers to this modulus (default %u)\n\
        -O      start buffers at this offset from the modulus (default 0)\n\
        -v      verbose: print more statistics\n\
        -d      set SO_DEBUG socket option\n\
        -b ##   set socket buffer size (if supported)\n\
        -f X    format for rate: k,K = kilo{bit,byte}; m,M = mega; g,G = giga\n\
   Options specific to -t:\n\
 !      -n##    number of source bufs written to network (default %u)\n\
        -D      don't buffer TCP writes (sets TCP_NODELAY socket option)\n\
   Options specific to -r:\n\
        -B      for -s, only output full blocks as specified by -l (for TAR)\n\
 ***************
 *** 131,155 ****
   unsigned long numCalls;              /* # of I/O system calls */
   double cput, realt;          /* user, real time (seconds) */
   
 - void err();
 - void mes();
 - int pattern();
 - void prep_timer();
 - double read_timer();
 - int Nread();
 - int Nwrite();
 - void delay();
 - int mread();
 - char *outfmt();
 - 
   void
   sigpipe()
   {
   }
   
 ! main(argc,argv)
 ! int argc;
 ! char **argv;
   {
        unsigned long addr_tmp;
        int c;
 --- 177,189 ----
   unsigned long numCalls;              /* # of I/O system calls */
   double cput, realt;          /* user, real time (seconds) */
   
   void
   sigpipe()
   {
   }
   
 ! int
 ! main( int argc, char **argv )
   {
        unsigned long addr_tmp;
        int c;
 ***************
 *** 263,280 ****
        if ( (buf = (char *)malloc(buflen+bufalign)) == (char *)NULL)
                err("malloc");
        if (bufalign != 0)
 !              buf +=(bufalign - ((int)buf % bufalign) + bufoffset) % bufalign;
   
        if (trans) {
            fprintf(stdout,
 !          "ttcp-t: buflen=%d, nbuf=%d, align=%d/%d, port=%d",
                buflen, nbuf, bufalign, bufoffset, port);
            if (sockbufsize)
                fprintf(stdout, ", sockbufsize=%d", sockbufsize);
            fprintf(stdout, "  %s  -> %s\n", udp?"udp":"tcp", host);
        } else {
            fprintf(stdout,
 !          "ttcp-r: buflen=%d, nbuf=%d, align=%d/%d, port=%d",
                buflen, nbuf, bufalign, bufoffset, port);
            if (sockbufsize)
                fprintf(stdout, ", sockbufsize=%d", sockbufsize);
 --- 297,314 ----
        if ( (buf = (char *)malloc(buflen+bufalign)) == (char *)NULL)
                err("malloc");
        if (bufalign != 0)
 !              buf +=(bufalign - ((unsigned int)buf % bufalign) + bufoffset) % 
bufalign;
   
        if (trans) {
            fprintf(stdout,
 !          "ttcp-t: buflen=%lu, nbuf=%d, align=%d/%d, port=%d",
                buflen, nbuf, bufalign, bufoffset, port);
            if (sockbufsize)
                fprintf(stdout, ", sockbufsize=%d", sockbufsize);
            fprintf(stdout, "  %s  -> %s\n", udp?"udp":"tcp", host);
        } else {
            fprintf(stdout,
 !          "ttcp-r: buflen=%lu, nbuf=%d, align=%d/%d, port=%d",
                buflen, nbuf, bufalign, bufoffset, port);
            if (sockbufsize)
                fprintf(stdout, ", sockbufsize=%d", sockbufsize);
 ***************
 *** 285,291 ****
                err("socket");
        mes("socket");
   
 !      if (bind(fd, &sinme, sizeof(sinme)) < 0)
                err("bind");
   
   #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
 --- 319,325 ----
                err("socket");
        mes("socket");
   
 !      if (bind(fd, (struct sockaddr *)&sinme, sizeof(sinme)) < 0)
                err("bind");
   
   #if defined(SO_SNDBUF) || defined(SO_RCVBUF)
 ***************
 *** 326,332 ****
                        mes("nodelay");
                }
   #endif
 !              if(connect(fd, &sinhim, sizeof(sinhim) ) < 0)
                        err("connect");
                mes("connect");
            } else {
 --- 360,366 ----
                        mes("nodelay");
                }
   #endif
 !              if(connect(fd, (struct sockaddr *)&sinhim, sizeof(sinhim) ) < 0)
                        err("connect");
                mes("connect");
            } else {
 ***************
 *** 347,370 ****
                                err("setsockopt");
                }
                fromlen = sizeof(frominet);
 !              domain = AF_INET;
 !              if((fd=accept(fd, &frominet, &fromlen) ) < 0)
                        err("accept");
 !              { struct sockaddr_in peer;
 !                int peerlen = sizeof(peer);
 !                if (getpeername(fd, (struct sockaddr_in *) &peer, 
                                &peerlen) < 0) {
                        err("getpeername");
                  }
                  fprintf(stderr,"ttcp-r: accept from %s\n", 
 !                      inet_ntoa(peer.sin_addr));
                }
            }
        }
        prep_timer();
        errno = 0;
        if (sinkmode) {      
 !              register int cnt;
                if (trans)  {
                        pattern( buf, buflen );
                        if(udp)  (void)Nwrite( fd, buf, 4 ); /* rcvr start */
 --- 381,403 ----
                                err("setsockopt");
                }
                fromlen = sizeof(frominet);
 !              if((fd=accept(fd, (struct sockaddr *)&frominet, &fromlen) ) < 0)
                        err("accept");
 !              { struct sockaddr_storage peer;
 !                socklen_t peerlen = sizeof(peer);
 !                if (getpeername(fd,  (struct sockaddr *)&peer, 
                                &peerlen) < 0) {
                        err("getpeername");
                  }
                  fprintf(stderr,"ttcp-r: accept from %s\n", 
 !                      inet_ntoa(((struct sockaddr_in *)&peer)->sin_addr));
                }
            }
        }
        prep_timer();
        errno = 0;
        if (sinkmode) {      
 !              ssize_t cnt;
                if (trans)  {
                        pattern( buf, buflen );
                        if(udp)  (void)Nwrite( fd, buf, 4 ); /* rcvr start */
 ***************
 *** 391,397 ****
                        }
                }
        } else {
 !              register int cnt;
                if (trans)  {
                        while((cnt=read(0,buf,buflen)) > 0 &&
                            Nwrite(fd,buf,cnt) == cnt)
 --- 424,430 ----
                        }
                }
        } else {
 !              ssize_t cnt;
                if (trans)  {
                        while((cnt=read(0,buf,buflen)) > 0 &&
                            Nwrite(fd,buf,cnt) == cnt)
 ***************
 *** 423,429 ****
                nbytes, cput, outfmt(nbytes/cput));
        }
        fprintf(stdout,
 !              "ttcp%s: %d I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
                trans?"-t":"-r",
                numCalls,
                1024.0 * realt/((double)numCalls),
 --- 456,462 ----
                nbytes, cput, outfmt(nbytes/cput));
        }
        fprintf(stdout,
 !              "ttcp%s: %lu I/O calls, msec/call = %.2f, calls/sec = %.2f\n",
                trans?"-t":"-r",
                numCalls,
                1024.0 * realt/((double)numCalls),
 ***************
 *** 438,450 ****
        exit(0);
   
   usage:
 !      fprintf(stderr,Usage);
        exit(1);
   }
   
 ! void
 ! err(s)
 ! char *s;
   {
        fprintf(stderr,"ttcp%s: ", trans?"-t":"-r");
        perror(s);
 --- 471,482 ----
        exit(0);
   
   usage:
 !      fprintf(stderr, Usage, DEFBUFSZ, DEFPORT, DEFALIGN, DEFNBUFS2SEND);
        exit(1);
   }
   
 ! static void
 ! err( const char *s )
   {
        fprintf(stderr,"ttcp%s: ", trans?"-t":"-r");
        perror(s);
 ***************
 *** 453,470 ****
   }
   
   void
 ! mes(s)
 ! char *s;
   {
        fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", s);
   }
   
 ! pattern( cp, cnt )
 ! register char *cp;
 ! register int cnt;
   {
 !      register char c;
 !      c = 0;
        while( cnt-- > 0 )  {
                while( !isprint((c&0x7F)) )  c++;
                *cp++ = (c++&0x7F);
 --- 485,500 ----
   }
   
   void
 ! mes( const char *s )
   {
        fprintf(stderr,"ttcp%s: %s\n", trans?"-t":"-r", s);
   }
   
 ! void
 ! pattern( char *cp, ssize_t cnt )
   {
 !      char c = 0;
 ! 
        while( cnt-- > 0 )  {
                while( !isprint((c&0x7F)) )  c++;
                *cp++ = (c++&0x7F);
 ***************
 *** 472,500 ****
   }
   
   char *
 ! outfmt(b)
 ! double b;
   {
       static char obuf[50];
       switch (fmt) {
        case 'G':
 !          sprintf(obuf, "%.2f GB", b / 1024.0 / 1024.0 / 1024.0);
            break;
        default:
        case 'K':
 !          sprintf(obuf, "%.2f KB", b / 1024.0);
            break;
        case 'M':
 !          sprintf(obuf, "%.2f MB", b / 1024.0 / 1024.0);
            break;
        case 'g':
 !          sprintf(obuf, "%.2f Gbit", b * 8.0 / 1024.0 / 1024.0 / 1024.0);
            break;
        case 'k':
 !          sprintf(obuf, "%.2f Kbit", b * 8.0 / 1024.0);
            break;
        case 'm':
 !          sprintf(obuf, "%.2f Mbit", b * 8.0 / 1024.0 / 1024.0);
            break;
       }
       return obuf;
 --- 502,529 ----
   }
   
   char *
 ! outfmt( double b )
   {
       static char obuf[50];
       switch (fmt) {
        case 'G':
 !          sprintf(obuf, "%.2f GB", b / (double)GIGA);
            break;
        default:
        case 'K':
 !          sprintf(obuf, "%.2f KB", b / (double)KILO);
            break;
        case 'M':
 !          sprintf(obuf, "%.2f MB", b / (double)MEGA);
            break;
        case 'g':
 !          sprintf(obuf, "%.2f Gbit", b * 8.0 / (double)GIGA);
            break;
        case 'k':
 !          sprintf(obuf, "%.2f Kbit", b * 8.0 / (double)KILO);
            break;
        case 'm':
 !          sprintf(obuf, "%.2f Mbit", b * 8.0 / (double)MEGA);
            break;
       }
       return obuf;
 ***************
 *** 503,513 ****
   static struct        timeval time0;  /* Time at which timing started */
   static struct        rusage ru0;     /* Resource utilization at the start */
   
 - static void prusage();
 - static void tvadd();
 - static void tvsub();
 - static void psecs();
 - 
   #if defined(SYSV)
   /*ARGSUSED*/
   static
 --- 532,537 ----
 ***************
 *** 552,559 ****
    * 
    */
   double
 ! read_timer(str,len)
 ! char *str;
   {
        struct timeval timedol;
        struct rusage ru1;
 --- 576,582 ----
    * 
    */
   double
 ! read_timer( char *str, size_t len )
   {
        struct timeval timedol;
        struct rusage ru1;
 ***************
 *** 580,595 ****
   }
   
   static void
 ! prusage(r0, r1, e, b, outp)
 !      register struct rusage *r0, *r1;
 !      struct timeval *e, *b;
 !      char *outp;
   {
        struct timeval tdiff;
        register time_t t;
        register char *cp;
 !      register int i;
 !      int ms;
   
        t = (r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
            (r1->ru_utime.tv_usec-r0->ru_utime.tv_usec)/10000+
 --- 603,614 ----
   }
   
   static void
 ! prusage( struct rusage *r0, struct rusage *r1, struct timeval *e, struct 
timeval *b, char *outp )
   {
        struct timeval tdiff;
        register time_t t;
        register char *cp;
 !      long ms, i;
   
        t = (r1->ru_utime.tv_sec-r0->ru_utime.tv_sec)*100+
            (r1->ru_utime.tv_usec-r0->ru_utime.tv_usec)/10000+
 ***************
 *** 614,690 ****
   
                case 'U':
                        tvsub(&tdiff, &r1->ru_utime, &r0->ru_utime);
 !                      sprintf(outp,"%d.%01d", tdiff.tv_sec, 
tdiff.tv_usec/100000);
                        END(outp);
                        break;
   
                case 'S':
                        tvsub(&tdiff, &r1->ru_stime, &r0->ru_stime);
 !                      sprintf(outp,"%d.%01d", tdiff.tv_sec, 
tdiff.tv_usec/100000);
                        END(outp);
                        break;
   
                case 'E':
 !                      psecs(ms / 100, outp);
                        END(outp);
                        break;
   
                case 'P':
 !                      sprintf(outp,"%d%%", (int) (t*100 / ((ms ? ms : 1))));
                        END(outp);
                        break;
   
   #if !defined(SYSV)
                case 'W':
                        i = r1->ru_nswap - r0->ru_nswap;
 !                      sprintf(outp,"%d", i);
                        END(outp);
                        break;
   
                case 'X':
 !                      sprintf(outp,"%d", t == 0 ? 0 : 
(r1->ru_ixrss-r0->ru_ixrss)/t);
                        END(outp);
                        break;
   
                case 'D':
 !                      sprintf(outp,"%d", t == 0 ? 0 :
                            
(r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t);
                        END(outp);
                        break;
   
                case 'K':
 !                      sprintf(outp,"%d", t == 0 ? 0 :
                            ((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) -
                            (r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t);
                        END(outp);
                        break;
   
                case 'M':
 !                      sprintf(outp,"%d", r1->ru_maxrss/2);
                        END(outp);
                        break;
   
                case 'F':
 !                      sprintf(outp,"%d", r1->ru_majflt-r0->ru_majflt);
                        END(outp);
                        break;
   
                case 'R':
 !                      sprintf(outp,"%d", r1->ru_minflt-r0->ru_minflt);
                        END(outp);
                        break;
   
                case 'I':
 !                      sprintf(outp,"%d", r1->ru_inblock-r0->ru_inblock);
                        END(outp);
                        break;
   
                case 'O':
 !                      sprintf(outp,"%d", r1->ru_oublock-r0->ru_oublock);
                        END(outp);
                        break;
                case 'C':
 !                      sprintf(outp,"%d+%d", r1->ru_nvcsw-r0->ru_nvcsw,
                                r1->ru_nivcsw-r0->ru_nivcsw );
                        END(outp);
                        break;
 --- 633,709 ----
   
                case 'U':
                        tvsub(&tdiff, &r1->ru_utime, &r0->ru_utime);
 !                      sprintf(outp,"%ld.%01ld", tdiff.tv_sec, 
tdiff.tv_usec/100000);
                        END(outp);
                        break;
   
                case 'S':
                        tvsub(&tdiff, &r1->ru_stime, &r0->ru_stime);
 !                      sprintf(outp,"%ld.%01ld", tdiff.tv_sec, 
tdiff.tv_usec/100000);
                        END(outp);
                        break;
   
                case 'E':
 !                      psecs(ms / 100L, outp);
                        END(outp);
                        break;
   
                case 'P':
 !                      sprintf(outp,"%ld%%",  (t*100 / ((ms ? ms : 1))));
                        END(outp);
                        break;
   
   #if !defined(SYSV)
                case 'W':
                        i = r1->ru_nswap - r0->ru_nswap;
 !                      sprintf(outp,"%ld", i);
                        END(outp);
                        break;
   
                case 'X':
 !                      sprintf(outp,"%ld", t == 0 ? 0 : 
(r1->ru_ixrss-r0->ru_ixrss)/t);
                        END(outp);
                        break;
   
                case 'D':
 !                      sprintf(outp,"%ld", t == 0 ? 0 :
                            
(r1->ru_idrss+r1->ru_isrss-(r0->ru_idrss+r0->ru_isrss))/t);
                        END(outp);
                        break;
   
                case 'K':
 !                      sprintf(outp,"%ld", t == 0 ? 0 :
                            ((r1->ru_ixrss+r1->ru_isrss+r1->ru_idrss) -
                            (r0->ru_ixrss+r0->ru_idrss+r0->ru_isrss))/t);
                        END(outp);
                        break;
   
                case 'M':
 !                      sprintf(outp,"%ld", r1->ru_maxrss/2);
                        END(outp);
                        break;
   
                case 'F':
 !                      sprintf(outp,"%ld", r1->ru_majflt-r0->ru_majflt);
                        END(outp);
                        break;
   
                case 'R':
 !                      sprintf(outp,"%ld", r1->ru_minflt-r0->ru_minflt);
                        END(outp);
                        break;
   
                case 'I':
 !                      sprintf(outp,"%ld", r1->ru_inblock-r0->ru_inblock);
                        END(outp);
                        break;
   
                case 'O':
 !                      sprintf(outp,"%ld", r1->ru_oublock-r0->ru_oublock);
                        END(outp);
                        break;
                case 'C':
 !                      sprintf(outp,"%ld+%ld", r1->ru_nvcsw-r0->ru_nvcsw,
                                r1->ru_nivcsw-r0->ru_nivcsw );
                        END(outp);
                        break;
 ***************
 *** 695,702 ****
   }
   
   static void
 ! tvadd(tsum, t0, t1)
 !      struct timeval *tsum, *t0, *t1;
   {
   
        tsum->tv_sec = t0->tv_sec + t1->tv_sec;
 --- 714,720 ----
   }
   
   static void
 ! tvadd( struct timeval *tsum, struct timeval *t0, struct timeval *t1 )
   {
   
        tsum->tv_sec = t0->tv_sec + t1->tv_sec;
 ***************
 *** 706,713 ****
   }
   
   static void
 ! tvsub(tdiff, t1, t0)
 !      struct timeval *tdiff, *t1, *t0;
   {
   
        tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
 --- 724,730 ----
   }
   
   static void
 ! tvsub( struct timeval *tdiff, struct timeval *t1, struct timeval *t0 )
   {
   
        tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
 ***************
 *** 717,758 ****
   }
   
   static void
 ! psecs(l,cp)
 ! long l;
 ! register char *cp;
   {
 !      register int i;
   
 !      i = l / 3600;
        if (i) {
 !              sprintf(cp,"%d:", i);
                END(cp);
 !              i = l % 3600;
 !              sprintf(cp,"%d%d", (i/60) / 10, (i/60) % 10);
                END(cp);
        } else {
                i = l;
 !              sprintf(cp,"%d", i / 60);
                END(cp);
        }
 !      i %= 60;
        *cp++ = ':';
 !      sprintf(cp,"%d%d", i / 10, i % 10);
   }
   
   /*
    *                   N R E A D
    */
 ! Nread( fd, buf, count )
 ! int fd;
 ! void *buf;
 ! int count;
   {
        struct sockaddr_in from;
 !      int len = sizeof(from);
 !      register int cnt;
        if( udp )  {
 !              cnt = recvfrom( fd, buf, count, 0, &from, &len );
                numCalls++;
        } else {
                if( b_flag )
 --- 734,772 ----
   }
   
   static void
 ! psecs( long l, char *cp )
   {
 !      long i;
   
 !      i = l / 3600L;
        if (i) {
 !              sprintf(cp,"%ld:", i);
                END(cp);
 !              i = l % 3600L;
 !              sprintf(cp,"%ld%ld", (i/60L) / 10L, (i/60L) % 10L);
                END(cp);
        } else {
                i = l;
 !              sprintf(cp,"%ld", i / 60L);
                END(cp);
        }
 !      i %= 60L;
        *cp++ = ':';
 !      sprintf(cp,"%ld%ld", i / 10L, i % 10L);
   }
   
   /*
    *                   N R E A D
    */
 ! ssize_t
 ! Nread( int fd, void *buf, size_t count )
   {
        struct sockaddr_in from;
 !      socklen_t len = sizeof(from);
 !      ssize_t  cnt;
 ! 
        if( udp )  {
 !              cnt = recvfrom( fd, buf, count, 0, (struct sockaddr *)&from, 
&len );
                numCalls++;
        } else {
                if( b_flag )
 ***************
 *** 762,769 ****
                        numCalls++;
                }
                if (touchdata && cnt > 0) {
 !                      register int c = cnt, sum;
 !                      register char *b = buf;
                        while (c--)
                                sum += *b++;
                }
 --- 776,783 ----
                        numCalls++;
                }
                if (touchdata && cnt > 0) {
 !                      int c = cnt, sum = 0;
 !                      char *b = buf;
                        while (c--)
                                sum += *b++;
                }
 ***************
 *** 774,791 ****
   /*
    *                   N W R I T E
    */
 ! Nwrite( fd, buf, count )
 ! int fd;
 ! void *buf;
 ! int count;
   {
 !      register int cnt;
        if( udp )  {
   again:
 !              cnt = sendto( fd, buf, count, 0, &sinhim, sizeof(sinhim) );
                numCalls++;
                if( cnt<0 && errno == ENOBUFS )  {
 !                      delay(18000);
                        errno = 0;
                        goto again;
                }
 --- 788,803 ----
   /*
    *                   N W R I T E
    */
 ! ssize_t
 ! Nwrite( int fd, void *buf, size_t count )
   {
 !      ssize_t cnt;
        if( udp )  {
   again:
 !              cnt = sendto( fd, buf, count, 0, (struct sockaddr *)&sinhim, 
sizeof(sinhim) );
                numCalls++;
                if( cnt<0 && errno == ENOBUFS )  {
 !                      delay(18000L);
                        errno = 0;
                        goto again;
                }
 ***************
 *** 797,809 ****
   }
   
   void
 ! delay(us)
   {
        struct timeval tv;
   
        tv.tv_sec = 0;
        tv.tv_usec = us;
 !      (void)select( 1, (char *)0, (char *)0, (char *)0, &tv );
   }
   
   /*
 --- 809,821 ----
   }
   
   void
 ! delay(long us)
   {
        struct timeval tv;
   
        tv.tv_sec = 0;
        tv.tv_usec = us;
 !      (void)select( 1, NULL, NULL, NULL, &tv );
   }
   
   /*
 ***************
 *** 815,828 ****
    * network connections don't deliver data with the same
    * grouping as it is written with.  Written by Robert S. Miles, BRL.
    */
 ! int
 ! mread(fd, bufp, n)
 ! int fd;
 ! register char        *bufp;
 ! unsigned     n;
   {
 !      register unsigned       count = 0;
 !      register int            nread;
   
        do {
                nread = read(fd, bufp, n-count);
 --- 827,837 ----
    * network connections don't deliver data with the same
    * grouping as it is written with.  Written by Robert S. Miles, BRL.
    */
 ! ssize_t
 ! mread(int fd, void *bufp, size_t n)
   {
 !      size_t          count = 0;
 !      ssize_t         nread;
   
        do {
                nread = read(fd, bufp, n-count);
 ***************
 *** 832,841 ****
                        return(-1);
                }
                if(nread == 0)
 !                      return((int)count);
 !              count += (unsigned)nread;
                bufp += nread;
         } while(count < n);
   
 !      return((int)count);
   }
 --- 841,850 ----
                        return(-1);
                }
                if(nread == 0)
 !                      return((ssize_t)count);
 !              count += nread;
                bufp += nread;
         } while(count < n);
   
 !      return((ssize_t)count);
   }
 



Home | Main Index | Thread Index | Old Index