.TH phalloc() "" "" "DDI/DKI Kernel Routine"
.PC "Create a pollhead structure"
.B "#include <sys/kmem.h>"
.B "#include <sys/poll.h>"
\fBstruct pollhead *phalloc(\fIflag\^\fB)\fR
\fBint \fIflag\^\fB;\fR
.PP
.B phalloc()
allocates and initializes structure of type
.BR pollhead .
A character driver that uses the DDI/DKI interface
can use
.B pollhead
to support polling.
.PP
The calling routine should use
.B flag
to indicate whether it will sleep.
Setting
.I flag
to
.B KM_SLEEP
indicates that if not enough memory is available to
allocate a
.B pollhead
structure, the caller will sleep until memory becomes available.
Setting
.I flag
to
.B KM_NOSLEEP
indicates that the caller will not sleep; if not enough memory
is available to allocate a
.B pollhead
structure,
.B phalloc()
immediately returns NULL.
.SH "See Also"
.B
DDI/DKI kernel routines,
phfree(),
pollwakeup()
.R
.SH Notes
If
.I flag
equals
.BR KM_SLEEP ,
.B phalloc()
has base level only and can sleep;
if
.I flag
equals
.BR KM_NOSLEEP ,
it has base or interrupt level and does not sleep.
.PP
A driver can hold a
driver-defined basic lock or read/write lock across a call to this function if
.I flag
equals
.BR KM_NOSLEEP ;
it cannot hold such locks if
.I flag
equals
.BR KM_SLEEP .
.PP
Driver-defined sleep locks may be held across calls to this function
regardless of the value of
.IR flag .
