1.\" $OpenBSD: pthread_spin_init.3,v 1.3 2020/04/06 00:01:08 pirofti Exp $ 2.\" 3.\" Copyright (c) 2012 Paul Irofti <paul@irofti.net> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.\" 18.Dd $Mdocdate: April 6 2020 $ 19.Dt PTHREAD_SPIN_INIT 3 20.Os 21.Sh NAME 22.Nm pthread_spin_init , 23.Nm pthread_spin_destroy 24.Nd initialize and destroy a spinlock object 25.Sh SYNOPSIS 26.In pthread.h 27.Ft int 28.Fn pthread_spin_init "pthread_spinlock_t *lock" "int pshared" 29.Ft int 30.Fn pthread_spin_destroy "pthread_spinlock_t *lock" 31.Sh DESCRIPTION 32The 33.Fn pthread_spin_init 34function creates a new spinlock object, with sharing attributes specified by 35.Fa pshared . 36.Pp 37The 38.Fn pthread_spin_destroy 39function frees the resources allocated for the 40.Fa lock . 41.Sh RETURN VALUES 42If successful, 43.Fn pthread_spin_init 44and 45.Fn pthread_spin_destroy 46return zero; otherwise an error number is returned to indicate the error. 47.Sh ERRORS 48.Fn pthread_spin_init 49will fail if: 50.Bl -tag -width Er 51.It Bq Er EINVAL 52The value specified by 53.Fa lock 54is invalid. 55.It Bq Er ENOMEM 56The process cannot allocate enough memory to create another spinlock object. 57.It Bq Er ENOTSUP 58The shared attributes specified by 59.Fa pshared 60are not supported by the current implementation. 61.El 62.Pp 63.Fn pthread_spin_destroy 64will fail if: 65.Bl -tag -width Er 66.It Bq Er EINVAL 67The value specified by 68.Fa lock 69is invalid. 70.It Bq Er EBUSY 71The lock is still in use. 72.El 73.Sh SEE ALSO 74.Xr pthread_spin_lock 3 , 75.Xr pthread_spin_unlock 3 76.Sh STANDARDS 77.Fn pthread_spin_init 78and 79.Fn pthread_spin_destroy 80conform to 81.St -p1003.1-2008 . 82.Sh BUGS 83Currently only 84.Dv PTHREAD_PROCESS_PRIVATE 85spinlocks are supported and the pshared attribute is 86always set that way. 87Any attempts to initialize it to a different value will trigger 88.Er ENOTSUP . 89