1c0e36632SAlexander Langer.\" Copyright (c) 1998 Alex Nash 2c0e36632SAlexander Langer.\" All rights reserved. 3c0e36632SAlexander Langer.\" 4c0e36632SAlexander Langer.\" Redistribution and use in source and binary forms, with or without 5c0e36632SAlexander Langer.\" modification, are permitted provided that the following conditions 6c0e36632SAlexander Langer.\" are met: 7c0e36632SAlexander Langer.\" 1. Redistributions of source code must retain the above copyright 8c0e36632SAlexander Langer.\" notice, this list of conditions and the following disclaimer. 9c0e36632SAlexander Langer.\" 2. Redistributions in binary form must reproduce the above copyright 10c0e36632SAlexander Langer.\" notice, this list of conditions and the following disclaimer in the 11c0e36632SAlexander Langer.\" documentation and/or other materials provided with the distribution. 12c0e36632SAlexander Langer.\" 13c0e36632SAlexander Langer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14c0e36632SAlexander Langer.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15c0e36632SAlexander Langer.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16c0e36632SAlexander Langer.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17c0e36632SAlexander Langer.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18c0e36632SAlexander Langer.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19c0e36632SAlexander Langer.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20c0e36632SAlexander Langer.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21c0e36632SAlexander Langer.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22c0e36632SAlexander Langer.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23c0e36632SAlexander Langer.\" SUCH DAMAGE. 24c0e36632SAlexander Langer.\" 25*b6413b6dSPedro F. Giffuni.Dd August 17, 2018 26c0e36632SAlexander Langer.Dt PTHREAD_RWLOCK_INIT 3 27c0e36632SAlexander Langer.Os 28c0e36632SAlexander Langer.Sh NAME 29c0e36632SAlexander Langer.Nm pthread_rwlock_init 30c0e36632SAlexander Langer.Nd initialize a read/write lock 31d8a78688SAlexey Zelkin.Sh LIBRARY 32ec7452f1SRuslan Ermilov.Lb libpthread 33c0e36632SAlexander Langer.Sh SYNOPSIS 3432eef9aeSRuslan Ermilov.In pthread.h 35c0e36632SAlexander Langer.Ft int 36*b6413b6dSPedro F. Giffuni.Fn pthread_rwlock_init "pthread_rwlock_t *restrict lock" "const pthread_rwlockattr_t *restrict attr" 37c0e36632SAlexander Langer.Sh DESCRIPTION 38c0e36632SAlexander LangerThe 39c0e36632SAlexander Langer.Fn pthread_rwlock_init 40c0e36632SAlexander Langerfunction is used to initialize a read/write lock, with attributes 41c0e36632SAlexander Langerspecified by 42c0e36632SAlexander Langer.Fa attr . 43c0e36632SAlexander LangerIf 44c0e36632SAlexander Langer.Fa attr 45c0e36632SAlexander Langeris NULL, the default read/write lock attributes are used. 46c0e36632SAlexander Langer.Pp 47c0e36632SAlexander LangerThe results of calling 48c0e36632SAlexander Langer.Fn pthread_rwlock_init 49c0e36632SAlexander Langerwith an already initialized lock are undefined. 50c0e36632SAlexander Langer.Sh RETURN VALUES 51c0e36632SAlexander LangerIf successful, the 52c0e36632SAlexander Langer.Fn pthread_rwlock_init 535203edcdSRuslan Ermilovfunction will return zero. 545203edcdSRuslan ErmilovOtherwise an error number will be returned 55c0e36632SAlexander Langerto indicate the error. 56c0e36632SAlexander Langer.Sh ERRORS 57c0e36632SAlexander LangerThe 58c0e36632SAlexander Langer.Fn pthread_rwlock_init 59c0e36632SAlexander Langerfunction will fail if: 60c0e36632SAlexander Langer.Bl -tag -width Er 61c0e36632SAlexander Langer.It Bq Er EAGAIN 62c0e36632SAlexander LangerThe system lacked the necessary resources (other than memory) to 63c0e36632SAlexander Langerinitialize the lock. 64c0e36632SAlexander Langer.It Bq Er ENOMEM 65c0e36632SAlexander LangerInsufficient memory exists to initialize the lock. 66c0e36632SAlexander Langer.It Bq Er EPERM 67c0e36632SAlexander LangerThe caller does not have sufficient privilege to perform the 68c0e36632SAlexander Langeroperation. 69c0e36632SAlexander Langer.El 70c0e36632SAlexander Langer.Pp 71c0e36632SAlexander LangerThe 72c0e36632SAlexander Langer.Fn pthread_rwlock_init 73c0e36632SAlexander Langerfunction may fail if: 74c0e36632SAlexander Langer.Bl -tag -width Er 75c0e36632SAlexander Langer.It Bq Er EBUSY 76c0e36632SAlexander LangerThe system has detected an attempt to re-initialize the object 77c0e36632SAlexander Langerreferenced by 78c0e36632SAlexander Langer.Fa lock , 79c0e36632SAlexander Langera previously initialized but not yet destroyed read/write lock. 80c0e36632SAlexander Langer.It Bq Er EINVAL 81c0e36632SAlexander LangerThe value specified by 82c0e36632SAlexander Langer.Fa attr 83c0e36632SAlexander Langeris invalid. 84c0e36632SAlexander Langer.El 859cbda590SRuslan Ermilov.Sh SEE ALSO 86e52a1af2SBaptiste Daroussin.Xr pthread_rwlock_destroy 3 , 879cbda590SRuslan Ermilov.Xr pthread_rwlockattr_init 3 , 88e52a1af2SBaptiste Daroussin.Xr pthread_rwlockattr_setpshared 3 899cbda590SRuslan Ermilov.Sh STANDARDS 909cbda590SRuslan ErmilovThe 919cbda590SRuslan Ermilov.Fn pthread_rwlock_init 929cbda590SRuslan Ermilovfunction is expected to conform to 939cbda590SRuslan Ermilov.St -susv2 . 94c0e36632SAlexander Langer.Sh HISTORY 95c0e36632SAlexander LangerThe 96c0e36632SAlexander Langer.Fn pthread_rwlock_init 97c0e36632SAlexander Langerfunction first appeared in 98c0e36632SAlexander Langer.Fx 3.0 . 99