Add copyright
[unix-history] / usr / src / old / as.vax / asio.c
index 08bb9be..1432902 100644 (file)
@@ -1,5 +1,13 @@
-/* Coypright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)asio.c 4.3 %G%";
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)asio.c     5.1 (Berkeley) %G%";
+#endif not lint
+
 #include <stdio.h>
 #include "as.h"
 /*
 #include <stdio.h>
 #include "as.h"
 /*
@@ -7,6 +15,7 @@ static char sccsid[] = "@(#)asio.c 4.3 %G%";
  *     more than one place in the same file.
  */
 int    biofd;                  /* file descriptor for block I/O file */
  *     more than one place in the same file.
  */
 int    biofd;                  /* file descriptor for block I/O file */
+int    biobufsize;             /* optimal block size for I/O */
 off_t  boffset;                /* physical position in logical file */
 BFILE  *biobufs;               /* the block I/O buffers */
 
 off_t  boffset;                /* physical position in logical file */
 BFILE  *biobufs;               /* the block I/O buffers */
 
@@ -33,8 +42,8 @@ bopen(bp, off)
        off_t   off;
 {
 
        off_t   off;
 {
 
-       bp->b_ptr = bp->b_buf;
-       bp->b_nleft = BUFSIZ - off % BUFSIZ;
+       bp->b_ptr = bp->b_buf = Calloc(1, biobufsize);
+       bp->b_nleft = biobufsize - (off % biobufsize);
        bp->b_off = off;
        bp->b_link = biobufs;
        biobufs = bp;
        bp->b_off = off;
        bp->b_link = biobufs;
        biobufs = bp;
@@ -59,18 +68,21 @@ top:
                        put = cnt;
                bp->b_nleft -= put;
                to = bp->b_ptr;
                        put = cnt;
                bp->b_nleft -= put;
                to = bp->b_ptr;
+#ifdef lint
+               *to = *to;
+#endif lint
                asm("movc3 r8,(r11),(r7)");
                bp->b_ptr += put;
                p += put;
                cnt -= put;
                goto top;
        }
                asm("movc3 r8,(r11),(r7)");
                bp->b_ptr += put;
                p += put;
                cnt -= put;
                goto top;
        }
-       if (cnt >= BUFSIZ) {
+       if (cnt >= biobufsize) {
                if (bp->b_ptr != bp->b_buf)
                        bflush1(bp);
                if (bp->b_ptr != bp->b_buf)
                        bflush1(bp);
-               put = cnt - cnt % BUFSIZ;
+               put = cnt - cnt % biobufsize;
                if (boffset != bp->b_off)
                if (boffset != bp->b_off)
-                       lseek(biofd, bp->b_off, 0);
+                       (void)lseek(biofd, (long)bp->b_off, 0);
                if (write(biofd, p, put) != put) {
                        bwrerror = 1;
                        error(1, "Output write error");
                if (write(biofd, p, put) != put) {
                        bwrerror = 1;
                        error(1, "Output write error");
@@ -103,7 +115,7 @@ bflush1(bp)
        if (cnt == 0)
                return;
        if (boffset != bp->b_off)
        if (cnt == 0)
                return;
        if (boffset != bp->b_off)
-               lseek(biofd, bp->b_off, 0);
+               (void)lseek(biofd, (long)bp->b_off, 0);
        if (write(biofd, bp->b_buf, cnt) != cnt) {
                bwrerror = 1;
                error(1, "Output write error");
        if (write(biofd, bp->b_buf, cnt) != cnt) {
                bwrerror = 1;
                error(1, "Output write error");
@@ -111,14 +123,13 @@ bflush1(bp)
        bp->b_off += cnt;
        boffset = bp->b_off;
        bp->b_ptr = bp->b_buf;
        bp->b_off += cnt;
        boffset = bp->b_off;
        bp->b_ptr = bp->b_buf;
-       bp->b_nleft = BUFSIZ;
+       bp->b_nleft = biobufsize;
 }
 
 bflushc(bp, c)
        register struct biobuf *bp;
        char    c;
 {
 }
 
 bflushc(bp, c)
        register struct biobuf *bp;
        char    c;
 {
-
        bflush1(bp);
        bputc(c, bp);
 }
        bflush1(bp);
        bputc(c, bp);
 }