'\"macro stdmacro
.if n .pH ddi_dki.chpoll @(#)chpoll	40.5 of 10/10/89
.\" Copyright 1989 AT&T
.de IX
.ie '\\n(.z'' .tm .Index: \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9	\\n%
.el \\!.IX \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
..
.nr X
.if \nX=0 .ds x} chpoll D2DK "" "DDI/DKI" "\&"
.if \nX=1 .ds x} chpoll D2DK "" "DDI/DKI"
.if \nX=2 .ds x} chpoll D2DK "" "\&"
.if \nX=3 .ds x} chpoll "" "" "\&"
.TH \*(x}
.IX "\f4chpoll\f1(D2DK)
.SH NAME
\f4chpoll\f1 \- poll entry point for a non-STREAMS character driver
.SH SYNOPSIS
.nf
.na
\f4#include <sys/poll.h>\fP
.sp 0.5
\f4chpoll(dev_t \f2dev, \f4short \f2events, \f4int \f2anyyet, \f4short *\f2reventsp,
	\f4struct pollhead **\f2phpp\f4);\f1
.ad
.fi
.SH ARGUMENTS
.RS 0n
.IP "\f2dev\f1" 10n
The device number for the device to be polled.
.IP "\f2events\f1" 10n
The events that may occur.  Valid events are:
.RS 14n
.P
.PD 0
.TP 12n
\f4POLLIN\f1
Data are available to be read.
.TP
\f4POLLOUT\f1
Data may be written without blocking.
.TP
\f4POLLPRI\f1
High priority data may be read.
.TP
\f4POLLHUP\f1
A device hangup.
.TP
\f4POLLERR\f1
A device error.
.PD
.RE
.IP "\f2anyyet\f1" 10n
A flag that is non-zero if any other file descriptors in the
\f4pollfd\f1 array have events pending.  The \f4poll\f1(2) system
call takes a pointer to an array of \f4pollfd\f1 structures as one
of its arguments.  See the \f4poll\f1(2) reference page for more
details.
.IP "\f2reventsp\f1" 10n
A pointer to a bitmask of the returned events satisfied.
.IP "\f2phpp\f1" 10n
A pointer to a pointer to a \f4pollhead\f1 structure.
The \f4pollhead\f1 structure is defined in \f4sys/poll.h\f1.
.RE
.SH DESCRIPTION
The \f4chpoll\f1 entry point routine is used by non-STREAMS character device drivers
that wish to support polling.  The
driver must implement the polling discipline itself.  The following
rules must be followed when implementing the polling discipline:
.P
.TP 4n
1.
Implement the following algorithm when the \f4chpoll\f1 entry point is
called: 
.P
.RS 8n
.ft 4
.nf
if (events_are_satisfied_now) {
      *reventsp = mask_of_satisfied_events;
} else {
      *reventsp = 0;
      if (!anyyet)
            *phpp = &my_local_pollhead_structure;
}
return (0);
.fi
.ft
.RE
.TP 4n
2.
Allocate an instance of the \f4pollhead\f1 structure.  This instance
may be tied to the per-minor data structure defined by the driver.  The
\f4pollhead\f1 structure should be treated as a ``black box'' by the driver.
None of its fields should be referenced.  However, the size of this structure
is guaranteed to remain the same across releases.
.TP
3.
Call the \f4pollwakeup\f1(D3DK) function whenever an event of type
\f4events\f1 listed above occur.  This function should only be
called with one event at a time.
.SH RETURN
A \f4chpoll\f1 routine should return 0 for success, or the
appropriate error number.
.SH SEE ALSO
\f4pollwakeup\f1(D3DK), \f4poll\f1(2)
