jcs's openbsd hax
openbsd
at jcs 89 lines 2.5 kB view raw
1.\" $OpenBSD: pthread_spin_init.3,v 1.4 2025/06/07 00:16:52 schwarze 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: June 7 2025 $ 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.Lb libpthread 27.In pthread.h 28.Ft int 29.Fn pthread_spin_init "pthread_spinlock_t *lock" "int pshared" 30.Ft int 31.Fn pthread_spin_destroy "pthread_spinlock_t *lock" 32.Sh DESCRIPTION 33The 34.Fn pthread_spin_init 35function creates a new spinlock object, with sharing attributes specified by 36.Fa pshared . 37.Pp 38The 39.Fn pthread_spin_destroy 40function frees the resources allocated for the 41.Fa lock . 42.Sh RETURN VALUES 43If successful, 44.Fn pthread_spin_init 45and 46.Fn pthread_spin_destroy 47return zero; otherwise an error number is returned to indicate the error. 48.Sh ERRORS 49.Fn pthread_spin_init 50will fail if: 51.Bl -tag -width Er 52.It Bq Er EINVAL 53The value specified by 54.Fa lock 55is invalid. 56.It Bq Er ENOMEM 57The process cannot allocate enough memory to create another spinlock object. 58.It Bq Er ENOTSUP 59The shared attributes specified by 60.Fa pshared 61are not supported by the current implementation. 62.El 63.Pp 64.Fn pthread_spin_destroy 65will fail if: 66.Bl -tag -width Er 67.It Bq Er EINVAL 68The value specified by 69.Fa lock 70is invalid. 71.It Bq Er EBUSY 72The lock is still in use. 73.El 74.Sh SEE ALSO 75.Xr pthread_spin_lock 3 , 76.Xr pthread_spin_unlock 3 77.Sh STANDARDS 78.Fn pthread_spin_init 79and 80.Fn pthread_spin_destroy 81conform to 82.St -p1003.1-2008 . 83.Sh BUGS 84Currently only 85.Dv PTHREAD_PROCESS_PRIVATE 86spinlocks are supported and the pshared attribute is 87always set that way. 88Any attempts to initialize it to a different value will trigger 89.Er ENOTSUP .