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/fcanpb.x | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sys/fio/fcanpb.x (limited to 'sys/fio/fcanpb.x') diff --git a/sys/fio/fcanpb.x b/sys/fio/fcanpb.x new file mode 100644 index 00000000..a3c58ab8 --- /dev/null +++ b/sys/fio/fcanpb.x @@ -0,0 +1,39 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include + +# FCANPB -- Cancel any pushed back data, restoring the original file pointers. +# This should be done before performing any non-i/o operation which relys +# upon the FIO data structures being in their normal state (e.g., before the +# file buffers are deallocated). + +procedure fcanpb (fd) + +int fd # file descriptor + +int pb_sp +int and() +include + +begin + fp = fiodes[fd] + + while (and (fflags[fd], FF_PUSHBACK) != 0) { + pb_sp = FPBSP(fp) + + iop[fd] = Memi[pb_sp]; pb_sp = pb_sp + 1 + itop[fd] = Memi[pb_sp]; pb_sp = pb_sp + 1 + bufptr[fd] = Memi[pb_sp]; pb_sp = pb_sp + 1 + FPBIOP(fp) = Memi[pb_sp]; pb_sp = pb_sp + 1 + + FPBSP(fp) = pb_sp + + # When the pb stack pointer reaches the top of the pushback buffer, + # all pushed back data has been read. Note that the stack pointer + # is a pointer to int while FPBTOP is a pointer to char. + + if (pb_sp >= (FPBTOP(fp) - 1) / SZ_INT + 1) + fflags[fd] = fflags[fd] - FF_PUSHBACK + } +end -- cgit