From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/fio/fexbuf.x | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sys/fio/fexbuf.x (limited to 'sys/fio/fexbuf.x') 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 +include + +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 + +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 -- cgit