aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/fexbuf.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/fio/fexbuf.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/fio/fexbuf.x')
-rw-r--r--sys/fio/fexbuf.x46
1 files changed, 46 insertions, 0 deletions
diff --git a/sys/fio/fexbuf.x b/sys/fio/fexbuf.x
new file mode 100644
index 00000000..38ba5b3d
--- /dev/null
+++ b/sys/fio/fexbuf.x
@@ -0,0 +1,46 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <config.h>
+include <fio.h>
+
+define INC_BUFSIZE 4096
+
+
+# FEXBUF -- Expand the size of the file buffer. Called by FLSBUF when the FIO
+# buffer fills while writing to a file of type SPOOL_FILE. Spool files are
+# files of arbitrary size, buffered entirely in memory. Typically, a finite
+# amount of data is written into a spoolfile, the file is rewound, the data
+# is read back out, and so on. This makes it possible to use the file interface
+# to pass data between program modules.
+
+procedure fexbuf (fd)
+
+int fd # file which needs a larger buffer
+
+pointer bp
+int offset
+errchk malloc, realloc
+include <fio.com>
+
+begin
+ fp = fiodes[fd]
+ bp = bufptr[fd]
+ offset = iop[fd] - bp
+
+ if (bufptr[fd] == NULL) {
+ if (FBUFSIZE(fp) == 0)
+ FBUFSIZE(fp) = SZ_SPOOLBUF
+ call malloc (bp, FBUFSIZE(fp), TY_CHAR)
+ } else {
+ FBUFSIZE(fp) = FBUFSIZE(fp) + INC_BUFSIZE
+ call realloc (bp, FBUFSIZE(fp), TY_CHAR)
+ }
+
+ boffset[fd] = 1
+ bufptr[fd] = bp
+ buftop[fd] = bp + FBUFSIZE(fp)
+
+ iop[fd] = bp + offset
+ itop[fd] = iop[fd]
+ otop[fd] = buftop[fd]
+end