xref: /openbsd-src/lib/libpthread/man/pthread_spin_init.3 (revision 8855e28c066fcedf8b2ce6df476d3f9b3d0ee8f9)
1*8855e28cSpirofti.\"	$OpenBSD: pthread_spin_init.3,v 1.3 2020/04/06 00:01:08 pirofti Exp $
25037ac14Spirofti.\"
3*8855e28cSpirofti.\" Copyright (c) 2012 Paul Irofti <paul@irofti.net>
45037ac14Spirofti.\"
55037ac14Spirofti.\" Permission to use, copy, modify, and distribute this software for any
65037ac14Spirofti.\" purpose with or without fee is hereby granted, provided that the above
75037ac14Spirofti.\" copyright notice and this permission notice appear in all copies.
85037ac14Spirofti.\"
95037ac14Spirofti.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
105037ac14Spirofti.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
115037ac14Spirofti.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
125037ac14Spirofti.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
135037ac14Spirofti.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
145037ac14Spirofti.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
155037ac14Spirofti.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
165037ac14Spirofti.\"
175037ac14Spirofti.\"
18*8855e28cSpirofti.Dd $Mdocdate: April 6 2020 $
195037ac14Spirofti.Dt PTHREAD_SPIN_INIT 3
205037ac14Spirofti.Os
215037ac14Spirofti.Sh NAME
225037ac14Spirofti.Nm pthread_spin_init ,
235037ac14Spirofti.Nm pthread_spin_destroy
245037ac14Spirofti.Nd initialize and destroy a spinlock object
255037ac14Spirofti.Sh SYNOPSIS
2686f9d4cdStedu.In pthread.h
275037ac14Spirofti.Ft int
285037ac14Spirofti.Fn pthread_spin_init "pthread_spinlock_t *lock" "int pshared"
295037ac14Spirofti.Ft int
305037ac14Spirofti.Fn pthread_spin_destroy "pthread_spinlock_t *lock"
315037ac14Spirofti.Sh DESCRIPTION
325037ac14SpiroftiThe
335037ac14Spirofti.Fn pthread_spin_init
345037ac14Spiroftifunction creates a new spinlock object, with sharing attributes specified by
355037ac14Spirofti.Fa pshared .
365037ac14Spirofti.Pp
375037ac14SpiroftiThe
385037ac14Spirofti.Fn pthread_spin_destroy
395037ac14Spiroftifunction frees the resources allocated for the
405037ac14Spirofti.Fa lock .
415037ac14Spirofti.Sh RETURN VALUES
425037ac14SpiroftiIf successful,
435037ac14Spirofti.Fn pthread_spin_init
445037ac14Spiroftiand
455037ac14Spirofti.Fn pthread_spin_destroy
465037ac14Spiroftireturn zero; otherwise an error number is returned to indicate the error.
475037ac14Spirofti.Sh ERRORS
485037ac14Spirofti.Fn pthread_spin_init
495037ac14Spiroftiwill fail if:
505037ac14Spirofti.Bl -tag -width Er
515037ac14Spirofti.It Bq Er EINVAL
525037ac14SpiroftiThe value specified by
535037ac14Spirofti.Fa lock
545037ac14Spiroftiis invalid.
555037ac14Spirofti.It Bq Er ENOMEM
565037ac14SpiroftiThe process cannot allocate enough memory to create another spinlock object.
575037ac14Spirofti.It Bq Er ENOTSUP
585037ac14SpiroftiThe shared attributes specified by
595037ac14Spirofti.Fa pshared
605037ac14Spiroftiare not supported by the current implementation.
615037ac14Spirofti.El
625037ac14Spirofti.Pp
635037ac14Spirofti.Fn pthread_spin_destroy
645037ac14Spiroftiwill fail if:
655037ac14Spirofti.Bl -tag -width Er
665037ac14Spirofti.It Bq Er EINVAL
675037ac14SpiroftiThe value specified by
685037ac14Spirofti.Fa lock
695037ac14Spiroftiis invalid.
705037ac14Spirofti.It Bq Er EBUSY
715037ac14SpiroftiThe lock is still in use.
725037ac14Spirofti.El
735037ac14Spirofti.Sh SEE ALSO
745037ac14Spirofti.Xr pthread_spin_lock 3 ,
755037ac14Spirofti.Xr pthread_spin_unlock 3
765037ac14Spirofti.Sh STANDARDS
775037ac14Spirofti.Fn pthread_spin_init
785037ac14Spiroftiand
795037ac14Spirofti.Fn pthread_spin_destroy
805037ac14Spirofticonform to
815037ac14Spirofti.St -p1003.1-2008 .
825037ac14Spirofti.Sh BUGS
835037ac14SpiroftiCurrently only
845037ac14Spirofti.Dv PTHREAD_PROCESS_PRIVATE
855037ac14Spiroftispinlocks are supported and the pshared attribute is
865037ac14Spiroftialways set that way.
875037ac14SpiroftiAny attempts to initialize it to a different value will trigger
885037ac14Spirofti.Er ENOTSUP .
89