aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/fwatio.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/fwatio.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fio/fwatio.x')
-rw-r--r--sys/fio/fwatio.x50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys/fio/fwatio.x b/sys/fio/fwatio.x
new file mode 100644
index 00000000..15e9c249
--- /dev/null
+++ b/sys/fio/fwatio.x
@@ -0,0 +1,50 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <config.h>
+include <syserr.h>
+include <fio.h>
+
+# FWATIO -- Wait for i/o to complete on the file buffer, update file
+# buffer pointers.
+
+procedure fwatio (fd)
+
+int fd
+int nchars, bufmode
+int await()
+errchk filerr
+include <fio.com>
+
+begin
+ fp = fiodes[fd]
+
+ if (FBUFMODE(fp) == INACTIVE)
+ return
+
+ else {
+ nchars = await (fd)
+
+ # Set the buffer mode flag to inactive regardless of the status
+ # returned by await.
+
+ bufmode = FBUFMODE(fp)
+ FBUFMODE(fp) = INACTIVE
+
+ if (bufmode == READ_IN_PROGRESS) {
+ if (nchars == ERR)
+ call filerr (FNAME(fp), SYS_FREAD)
+ else
+ itop[fd] = bufptr[fd] + nchars
+
+ } else if (nchars == ERR) {
+ # If an i/o error occurs on a write invalidate the buffer
+ # else during error recovery close will try again to write
+ # the data, probably causing another error.
+
+ otop[fd] = bufptr[fd]
+ call filerr (FNAME(fp), SYS_FWRITE)
+ }
+
+ otop[fd] = bufptr[fd]
+ }
+end