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_condattr.3,v 1.15 2007/10/22 10:08:00 ru Exp $
29.\"
30.Dd November 30, 2017
31.Dt PTHREAD_CONDATTR 3
32.Os
33.Sh NAME
34.Nm pthread_condattr_init ,
35.Nm pthread_condattr_destroy ,
36.Nm pthread_condattr_getclock ,
37.Nm pthread_condattr_setclock ,
38.Nm pthread_condattr_getpshared ,
39.Nm pthread_condattr_setpshared
40.Nd condition attribute operations
41.Sh LIBRARY
42.Lb libpthread
43.Sh SYNOPSIS
44.In pthread.h
45.Ft int
46.Fn pthread_condattr_init "pthread_condattr_t *attr"
47.Ft int
48.Fn pthread_condattr_destroy "pthread_condattr_t *attr"
49.Ft int
50.Fn pthread_condattr_getclock "const pthread_condattr_t * restrict attr" "clockid_t * restrict clock_id"
51.Ft int
52.Fn pthread_condattr_setclock "pthread_condattr_t *attr" "clockid_t clock_id"
53.Ft int
54.Fn pthread_condattr_getpshared "const pthread_condattr_t * restrict attr" "int * restrict pshared"
55.Ft int
56.Fn pthread_condattr_setpshared "pthread_condattr_t *attr" "int pshared"
57.Sh DESCRIPTION
58Condition attribute objects are used to specify parameters to
59.Fn pthread_cond_init .
60.Dx Ns 's
61implementation of conditions does not support any non-default
62attributes, so these functions are not very useful, though they are required
63to be present by
64.Tn POSIX .
65.Pp
66The
67.Fn pthread_condattr_init
68function initializes a condition attribute object with the default attributes.
69.Pp
70The
71.Fn pthread_condattr_destroy
72function destroys a condition attribute object.
73.Pp
74The
75.Fn pthread_condattr_getclock
76function will put the value of the clock attribute from
77.Fa attr
78into the memory area pointed to by
79.Fa clock_id .
80The
81.Fn pthread_condattr_setclock
82function will set the clock attribute of
83.Fa attr
84to the value specified in
85.Fa clock_id .
86The clock attribute affects the interpretation of
87.Fa abstime
88in
89.Xr pthread_cond_timedwait 3
90and may be set to
91.Dv CLOCK_REALTIME
92(default)
93or
94.Dv CLOCK_MONOTONIC .
95.Pp
96The
97.Fn pthread_condattr_getpshared
98function will put the value of the process-shared attribute from
99.Fa attr
100into the memory area pointed to by
101.Fa pshared .
102The
103.Fn pthread_condattr_setpshared
104function will set the process-shared attribute of
105.Fa attr
106to the value specified in
107.Fa pshared .
108The argument
109.Fa pshared
110may have the following value:
111.Bl -tag -width ".Dv PTHREAD_PROCESS_PRIVATE"
112.It Dv PTHREAD_PROCESS_PRIVATE
113The condition variable it is attached to may only be accessed by
114threads in the same process as the one that created the object.
115.\".It Dv PTHREAD_PROCESS_SHARED
116.\"The condition variable it is attached to may be accessed by
117.\"threads in processes other than the one that created the object.
118.El
119.Sh RETURN VALUES
120If successful, these functions return 0.
121Otherwise, an error number is returned to indicate the error.
122.Sh ERRORS
123The
124.Fn pthread_condattr_init
125function will fail if:
126.Bl -tag -width Er
127.It Bq Er ENOMEM
128Out of memory.
129.El
130.Pp
131The
132.Fn pthread_condattr_destroy
133function will fail if:
134.Bl -tag -width Er
135.It Bq Er EINVAL
136Invalid value for
137.Fa attr .
138.El
139.Pp
140The
141.Fn pthread_condattr_setclock
142function will fail if:
143.Bl -tag -width Er
144.It Bq Er EINVAL
145The value specified in
146.Fa clock_id
147is not one of the allowed values.
148.El
149.Pp
150The
151.Fn pthread_condattr_setpshared
152function will fail if:
153.Bl -tag -width Er
154.It Bq Er EINVAL
155The value specified in
156.Fa pshared
157is not one of the allowed values.
158.El
159.Sh SEE ALSO
160.Xr pthread_cond_init 3 ,
161.Xr pthread_cond_timedwait 3
162.Sh STANDARDS
163The
164.Fn pthread_condattr_init
165and
166.Fn pthread_condattr_destroy
167functions conform to
168.St -p1003.1-96 .
169