xref: /openbsd-src/lib/libpthread/man/pthread_cond_init.3 (revision 41ce3b17e73f6b7d2d9e1a3d961e4bab2d895cb5)
1*41ce3b17Snaddy.\" $OpenBSD: pthread_cond_init.3,v 1.12 2022/03/31 17:27:17 naddy Exp $
282d2d131Sfgsch.\"
3a278733dSd.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
4a278733dSd.\" All rights reserved.
5a278733dSd.\"
6a278733dSd.\" Redistribution and use in source and binary forms, with or without
7a278733dSd.\" modification, are permitted provided that the following conditions
8a278733dSd.\" are met:
9a278733dSd.\" 1. Redistributions of source code must retain the above copyright
10a278733dSd.\"    notice, this list of conditions and the following disclaimer.
11a278733dSd.\" 2. Redistributions in binary form must reproduce the above copyright
12a278733dSd.\"    notice, this list of conditions and the following disclaimer in the
13a278733dSd.\"    documentation and/or other materials provided with the distribution.
14a278733dSd.\" 3. Neither the name of the author nor the names of any co-contributors
15a278733dSd.\"    may be used to endorse or promote products derived from this software
16a278733dSd.\"    without specific prior written permission.
17a278733dSd.\"
18a278733dSd.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
19a278733dSd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20a278733dSd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21a278733dSd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22a278733dSd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23a278733dSd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24a278733dSd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25a278733dSd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26a278733dSd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27a278733dSd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28a278733dSd.\" SUCH DAMAGE.
29a278733dSd.\"
3074493c91Sd.\" $FreeBSD: pthread_cond_init.3,v 1.6 1999/08/28 00:03:03 peter Exp $
3174493c91Sd.\"
32*41ce3b17Snaddy.Dd $Mdocdate: March 31 2022 $
33a278733dSd.Dt PTHREAD_COND_INIT 3
34c043c0f7Sd.Os
35a278733dSd.Sh NAME
36a278733dSd.Nm pthread_cond_init
37a278733dSd.Nd create a condition variable
38a278733dSd.Sh SYNOPSIS
3986f9d4cdStedu.In pthread.h
40a278733dSd.Ft int
41a278733dSd.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr"
42a278733dSd.Sh DESCRIPTION
43a278733dSdThe
44a278733dSd.Fn pthread_cond_init
45a278733dSdfunction creates a new condition variable, with attributes specified with
46a278733dSd.Fa attr .
47a278733dSdIf
48a278733dSd.Fa attr
49096e5ce2Saaronis
50*41ce3b17Snaddy.Dv NULL ,
51096e5ce2Saaronthe default attributes are used.
52a278733dSd.Sh RETURN VALUES
53a278733dSdIf successful, the
54a278733dSd.Fn pthread_cond_init
55096e5ce2Saaronfunction will return zero and put the new condition variable ID into
56a278733dSd.Fa cond ,
57a278733dSdotherwise an error number will be returned to indicate the error.
58a278733dSd.Sh ERRORS
59a278733dSd.Fn pthread_cond_init
60a278733dSdwill fail if:
61a278733dSd.Bl -tag -width Er
62a278733dSd.It Bq Er EINVAL
63a278733dSdThe value specified by
64a278733dSd.Fa attr
65a278733dSdis invalid.
66a278733dSd.It Bq Er ENOMEM
67a278733dSdThe process cannot allocate enough memory to create another condition
68a278733dSdvariable.
69a278733dSd.It Bq Er EAGAIN
705bb7d6adSjasoniThe system temporarily lacks the resources to create another condition
715bb7d6adSjasonivariable.
72a278733dSd.El
73a278733dSd.Sh SEE ALSO
74f8344ebdSd.Xr pthread_cond_broadcast 3 ,
75a278733dSd.Xr pthread_cond_destroy 3 ,
76a278733dSd.Xr pthread_cond_signal 3 ,
77f8344ebdSd.Xr pthread_cond_timedwait 3 ,
78f8344ebdSd.Xr pthread_cond_wait 3
79a278733dSd.Sh STANDARDS
80a278733dSd.Fn pthread_cond_init
8182d2d131Sfgschconforms to
8282d2d131Sfgsch.St -p1003.1-96 .
83