9022 loader.efi: module placement must check memory map
[unleashed.git] / share / man / man9f / putnextctl.9f
bloba8eaee82eeddd584861ca61b8467e441f2a46fe8
1 '\" te
2 .\"  Copyright 1989 AT&T
3 .\"  Copyright (c) 2006, Sun Microsystems, Inc.,  All Rights Reserved
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH PUTNEXTCTL 9F "Jan 16, 2006"
8 .SH NAME
9 putnextctl \- send a control message to a queue
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/stream.h>
17 \fBint\fR \fBputnextctl\fR(\fBqueue_t *\fR\fIq\fR, \fBint\fR \fItype\fR);
18 .fi
20 .SH INTERFACE LEVEL
21 .sp
22 .LP
23 Architecture independent level 1 (DDI/DKI).
24 .SH PARAMETERS
25 .sp
26 .ne 2
27 .na
28 \fB\fIq\fR\fR
29 .ad
30 .RS 8n
31 Queue to which the message is to be sent.
32 .RE
34 .sp
35 .ne 2
36 .na
37 \fB\fItype\fR\fR
38 .ad
39 .RS 8n
40 Message type (must be control, not data type).
41 .RE
43 .SH DESCRIPTION
44 .sp
45 .LP
46 The \fBputnextctl()\fR function tests the \fItype\fR argument to make sure a
47 data type has not been specified, and then attempts to allocate a message
48 block. \fBputnextctl()\fR fails if \fItype\fR is \fBM_DATA\fR, \fBM_PROTO\fR,
49 or \fBM_PCPROTO\fR, or if a message block cannot be allocated. If successful,
50 \fBputnextctl()\fR calls the  \fBput\fR(9E) routine of the queue pointed to by
51 \fIq\fR with the newly allocated and initialized messages.
52 .sp
53 .LP
54 A call to \fBputnextctl(\fR\fIq\fR\fB,\fR\fItype\fR\fB)\fR is an atomic
55 equivalent of \fBputctl(\fR\fIq\fR\fB->q_next\fR,\fItype\fR\fI).\fR The STREAMS
56 framework provides whatever mutual exclusion is necessary to insure that
57 dereferencing \fIq\fR through its \fBq_next\fR field and then invoking
58 \fBputctl\fR(9F) proceeds without interference from other threads.
59 .sp
60 .LP
61 The \fBputnextctl()\fR function should always be used in preference to
62 \fBputctl\fR(9F)
63 .SH RETURN VALUES
64 .sp
65 .LP
66 On success, \fB1\fR is returned. If \fItype\fR is a data type, or if a message
67 block cannot be allocated, \fB0\fR is returned.
68 .SH CONTEXT
69 .sp
70 .LP
71 The \fBputnextctl()\fR function can be user, interrupt, or kernel context.
72 .SH EXAMPLES
73 .sp
74 .LP
75 The \fBsend_ctl\fR routine is used to pass control messages downstream.
76 \fBM_BREAK\fR messages are handled with  \fBputnextctl\fR(\|) (line 8).
77 \fBputnextctl1\fR(9F) (line 13) is used for \fBM_DELAY\fR messages,  so that
78 \fIparm\fR can be used to specify the length of the delay. In either case, if a
79 message block cannot be allocated  a  variable recording the number of
80 allocation failures  is incremented (lines 9, 14). If an invalid message type
81 is detected,  \fBcmn_err\fR(9F) panics the system (line 18).
82 .sp
83 .in +2
84 .nf
85 1 void
86  2 send_ctl(queue_t *wrq, uchar_t type, uchar_t parm)
87  3 {
88  4              extern int num_alloc_fail;
89  5
90  6              switch (type) {
91  7         case M_BREAK:
92  8                if (!putnextctl(wrq, M_BREAK))
93  9                              num_alloc_fail++;
94 10                     break;
96 12              case M_DELAY:
97 13                if (!putnextctl1(wrq, M_DELAY, parm))
98 14                              num_alloc_fail++;
99 15                break;
101 17         default:
102 18                cmn_err(CE_PANIC, "send_ctl: bad message type passed");
103 19                     break;
104 20              }
105 21  }
107 .in -2
109 .SH SEE ALSO
112 \fBput\fR(9E), \fBcmn_err\fR(9F), \fBdatamsg\fR(9F), \fBputctl\fR(9F),
113 \fBputnextctl1\fR(9F)
116 \fIWriting Device Drivers\fR
119 \fISTREAMS Programming Guide\fR