libpthread: Document some more functions.
[dragonfly.git] / lib / libpthread / pthread_mutexattr.3
blobdc9722b27c1d89b544dc76b616defa3357c0b199
1 .\" Copyright (C) 2000 Jason Evans <jasone@FreeBSD.org>.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice(s), this list of conditions and the following disclaimer as
9 .\"    the first lines of this file unmodified other than the possible
10 .\"    addition of one or more copyright notices.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice(s), this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
17 .\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
20 .\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD: src/share/man/man3/pthread_mutexattr.3,v 1.13 2007/10/22 10:08:00 ru Exp $
29 .\"
30 .Dd July 10, 2009
31 .Dt PTHREAD_MUTEXATTR 3
32 .Os
33 .Sh NAME
34 .Nm pthread_mutexattr_init ,
35 .Nm pthread_mutexattr_destroy ,
36 .Nm pthread_mutexattr_setprioceiling ,
37 .Nm pthread_mutexattr_getprioceiling ,
38 .Nm pthread_mutexattr_setprotocol ,
39 .Nm pthread_mutexattr_getprotocol ,
40 .Nm pthread_mutexattr_settype ,
41 .Nm pthread_mutexattr_gettype ,
42 .Nm pthread_mutexattr_getpshared ,
43 .Nm pthread_mutexattr_setpshared
44 .Nd mutex attribute operations
45 .Sh LIBRARY
46 .Lb libpthread
47 .Sh SYNOPSIS
48 .In pthread.h
49 .Ft int
50 .Fn pthread_mutexattr_init "pthread_mutexattr_t *attr"
51 .Ft int
52 .Fn pthread_mutexattr_destroy "pthread_mutexattr_t *attr"
53 .Ft int
54 .Fn pthread_mutexattr_setprioceiling "pthread_mutexattr_t *attr" "int prioceiling"
55 .Ft int
56 .Fn pthread_mutexattr_getprioceiling "pthread_mutexattr_t *attr" "int *prioceiling"
57 .Ft int
58 .Fn pthread_mutexattr_setprotocol "pthread_mutexattr_t *attr" "int protocol"
59 .Ft int
60 .Fn pthread_mutexattr_getprotocol "pthread_mutexattr_t *attr" "int *protocol"
61 .Ft int
62 .Fn pthread_mutexattr_settype "pthread_mutexattr_t *attr" "int type"
63 .Ft int
64 .Fn pthread_mutexattr_gettype "pthread_mutexattr_t *attr" "int *type"
65 .Ft int
66 .Fn pthread_mutexattr_setpshared "pthread_mutexattr_t *attr" "int pshared"
67 .Ft int
68 .Fn pthread_mutexattr_getpshared "const pthread_mutexattr_t * restrict attr" "int * restrict pshared"
69 .Sh DESCRIPTION
70 Mutex attributes are used to specify parameters to
71 .Fn pthread_mutex_init .
72 One attribute object can be used in multiple calls to
73 .Fn pthread_mutex_init ,
74 with or without modifications between calls.
75 .Pp
76 The
77 .Fn pthread_mutexattr_init
78 function initializes
79 .Fa attr
80 with all the default mutex attributes.
81 .Pp
82 The
83 .Fn pthread_mutexattr_destroy
84 function destroys
85 .Fa attr .
86 .Pp
87 The
88 .Fn pthread_mutexattr_set*
89 functions set the attribute that corresponds to each function name.
90 Note that the
91 .Fn pthread_mutexattr_setpshared
92 function only supports
93 .Dv PTHREAD_PROCESS_PRIVATE
94 at the moment.
95 .Pp
96 The
97 .Fn pthread_mutexattr_get*
98 functions copy the value of the attribute that corresponds to each function name
99 to the location pointed to by the second function parameter.
100 .Sh RETURN VALUES
101 If successful, these functions return 0.
102 Otherwise, an error number is returned to indicate the error.
103 .Sh ERRORS
105 .Fn pthread_mutexattr_init
106 function will fail if:
107 .Bl -tag -width Er
108 .It Bq Er ENOMEM
109 Out of memory.
113 .Fn pthread_mutexattr_destroy
114 function will fail if:
115 .Bl -tag -width Er
116 .It Bq Er EINVAL
117 Invalid value for
118 .Fa attr .
122 .Fn pthread_mutexattr_setprioceiling
123 function will fail if:
124 .Bl -tag -width Er
125 .It Bq Er EINVAL
126 Invalid value for
127 .Fa attr ,
128 or invalid value for
129 .Fa prioceiling .
133 .Fn pthread_mutexattr_getprioceiling
134 function will fail if:
135 .Bl -tag -width Er
136 .It Bq Er EINVAL
137 Invalid value for
138 .Fa attr .
142 .Fn pthread_mutexattr_setprotocol
143 function will fail if:
144 .Bl -tag -width Er
145 .It Bq Er EINVAL
146 Invalid value for
147 .Fa attr ,
148 or invalid value for
149 .Fa protocol .
153 .Fn pthread_mutexattr_getprotocol
154 function will fail if:
155 .Bl -tag -width Er
156 .It Bq Er EINVAL
157 Invalid value for
158 .Fa attr .
162 .Fn pthread_mutexattr_getpshared
164 .Fn pthread_mutexattr_setpshared
165 functions will fail if:
166 .Bl -tag -width Er
167 .It Bq Er EINVAL
168 The value specified by
169 .Fa attr
170 is invalid.
174 .Fn pthread_mutexattr_settype
175 function will fail if:
176 .Bl -tag -width Er
177 .It Bq Er EINVAL
178 Invalid value for
179 .Fa attr ,
180 or invalid value for
181 .Fa type .
185 .Fn pthread_mutexattr_gettype
186 function will fail if:
187 .Bl -tag -width Er
188 .It Bq Er EINVAL
189 Invalid value for
190 .Fa attr .
192 .Sh SEE ALSO
193 .Xr pthread_mutex_init 3
194 .Sh STANDARDS
196 .Fn pthread_mutexattr_init
198 .Fn pthread_mutexattr_destroy
199 functions conform to
200 .St -p1003.1-96 .
203 .Fn pthread_mutexattr_setprioceiling ,
204 .Fn pthread_mutexattr_getprioceiling ,
205 .Fn pthread_mutexattr_setprotocol ,
206 .Fn pthread_mutexattr_getprotocol ,
207 .Fn pthread_mutexattr_settype ,
209 .Fn pthread_mutexattr_gettype
210 functions conform to
211 .St -susv2 .