1*86f9d4cdStedu.\" $OpenBSD: pthread_rwlock_init.3,v 1.8 2013/06/05 03:44:50 tedu Exp $ 2f8344ebdSd.\" Copyright (c) 1998 Alex Nash 3f8344ebdSd.\" All rights reserved. 4f8344ebdSd.\" 5f8344ebdSd.\" Redistribution and use in source and binary forms, with or without 6f8344ebdSd.\" modification, are permitted provided that the following conditions 7f8344ebdSd.\" are met: 8f8344ebdSd.\" 1. Redistributions of source code must retain the above copyright 9f8344ebdSd.\" notice, this list of conditions and the following disclaimer. 10f8344ebdSd.\" 2. Redistributions in binary form must reproduce the above copyright 11f8344ebdSd.\" notice, this list of conditions and the following disclaimer in the 12f8344ebdSd.\" documentation and/or other materials provided with the distribution. 13f8344ebdSd.\" 14f8344ebdSd.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15f8344ebdSd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16f8344ebdSd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17f8344ebdSd.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18f8344ebdSd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19f8344ebdSd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20f8344ebdSd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21f8344ebdSd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22f8344ebdSd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23f8344ebdSd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24f8344ebdSd.\" SUCH DAMAGE. 25f8344ebdSd.\" 2674493c91Sd.\" $FreeBSD: pthread_rwlock_init.3,v 1.2 1999/08/28 00:03:09 peter Exp $ 27f8344ebdSd.\" 28*86f9d4cdStedu.Dd $Mdocdate: June 5 2013 $ 29f8344ebdSd.Dt PTHREAD_RWLOCK_INIT 3 30f8344ebdSd.Os 31f8344ebdSd.Sh NAME 32f8344ebdSd.Nm pthread_rwlock_init 33f8344ebdSd.Nd initialize a read/write lock 34f8344ebdSd.Sh SYNOPSIS 35*86f9d4cdStedu.In pthread.h 36f8344ebdSd.Ft int 37f8344ebdSd.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" 38f8344ebdSd.Sh DESCRIPTION 39f8344ebdSdThe 40f8344ebdSd.Fn pthread_rwlock_init 41f8344ebdSdfunction is used to initialize a read/write lock, with attributes 42f8344ebdSdspecified by 43f8344ebdSd.Fa attr . 44f8344ebdSdIf 45f8344ebdSd.Fa attr 46f8344ebdSdis NULL, the default read/write lock attributes are used. 47f8344ebdSd.Pp 48f8344ebdSdThe results of calling 49f8344ebdSd.Fn pthread_rwlock_init 50f8344ebdSdwith an already initialized lock are undefined. 51f8344ebdSd.Sh RETURN VALUES 52f8344ebdSdIf successful, the 53f8344ebdSd.Fn pthread_rwlock_init 5479ad192cSjmcfunction will return zero. 5579ad192cSjmcOtherwise an error number will be returned to indicate the error. 56f8344ebdSd.Sh ERRORS 57f8344ebdSdThe 58f8344ebdSd.Fn pthread_rwlock_init 59f8344ebdSdfunction will fail if: 60f8344ebdSd.Bl -tag -width Er 61f8344ebdSd.It Bq Er EAGAIN 62f8344ebdSdThe system lacked the necessary resources (other than memory) to 63f8344ebdSdinitialize the lock. 64f8344ebdSd.It Bq Er ENOMEM 65f8344ebdSdInsufficient memory exists to initialize the lock. 66f8344ebdSd.It Bq Er EPERM 67f8344ebdSdThe caller does not have sufficient privilege to perform the 68f8344ebdSdoperation. 69f8344ebdSd.El 70f8344ebdSd.Pp 71f8344ebdSdThe 72f8344ebdSd.Fn pthread_rwlock_init 73f8344ebdSdfunction may fail if: 74f8344ebdSd.Bl -tag -width Er 75f8344ebdSd.It Bq Er EBUSY 76f8344ebdSdThe system has detected an attempt to re-initialize the object 77f8344ebdSdreferenced by 78f8344ebdSd.Fa lock , 79f8344ebdSda previously initialized but not yet destroyed read/write lock. 80f8344ebdSd.It Bq Er EINVAL 81f8344ebdSdThe value specified by 82f8344ebdSd.Fa attr 83f8344ebdSdis invalid. 84f8344ebdSd.El 85c062f733Sjmc.Sh SEE ALSO 86c062f733Sjmc.Xr pthread_rwlock_destroy 3 , 87c062f733Sjmc.Xr pthread_rwlockattr_init 3 , 88c062f733Sjmc.Xr pthread_rwlockattr_setpshared 3 89c062f733Sjmc.Sh STANDARDS 90c062f733SjmcThe 91c062f733Sjmc.Fn pthread_rwlock_init 92c062f733Sjmcfunction is expected to conform to 93c062f733Sjmc.St -susv2 . 94f8344ebdSd.Sh HISTORY 95f8344ebdSdThe 96f8344ebdSd.Fn pthread_rwlock_init 97f8344ebdSdfunction first appeared in 9874493c91Sd.Fx 3.0 9974493c91Sdand 100c536383fSalex.Ox 2.5 . 101f8344ebdSd.Sh BUGS 102f8344ebdSdThe PTHREAD_PROCESS_SHARED attribute is not supported. 103