aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/fcanpb.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/fio/fcanpb.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fio/fcanpb.x')
-rw-r--r--sys/fio/fcanpb.x39
1 files changed, 39 insertions, 0 deletions
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 <config.h>
+include <fio.h>
+
+# 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 <fio.com>
+
+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