aboutsummaryrefslogtreecommitdiff
path: root/sys/fio/awaitb.x
blob: 3d27f74877834dd9e1dcfeefd27680d1ede817c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<mach.h>
include	<config.h>
include	<fio.h>

# 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	<fio.com>

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