From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/fio/awaitb.x | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 sys/fio/awaitb.x (limited to 'sys/fio/awaitb.x') diff --git a/sys/fio/awaitb.x b/sys/fio/awaitb.x new file mode 100644 index 00000000..3d27f748 --- /dev/null +++ b/sys/fio/awaitb.x @@ -0,0 +1,39 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include +include + +# AWAITB -- Wait for any pending i/o operations on a file to complete. +# Must be called after an AREADB or AWRITEB (to check for an i/o error +# and for synchronization) or an abort will result. + +int procedure awaitb (fd) + +int fd +int nbytes, nchars +include + +begin + fp = fiodes[fd] + + if (FFIOMODE(fp) == INACTIVE) + return (FNBYTES(fp)) + else + call zcall2 (ZAWTBF(fp), FCHAN(fp), nbytes) + + nchars = nbytes + if (nbytes >= 0) + nchars = (nbytes + SZB_CHAR-1) / SZB_CHAR + + FNBYTES(fp) = nbytes + FILSTAT(fp) = nchars + + FCIOMODE(fp) = INACTIVE # clear channel + FFIOMODE(fp) = INACTIVE # complete fd request + + if (nbytes >= 0) + return (nbytes) + else + return (ERR) +end -- cgit