1d3980376SJohn Polstra.\" 24e1635feSJohn Polstra.\" Copyright (c) 1999, 2000 John D. Polstra 3d3980376SJohn Polstra.\" All rights reserved. 4d3980376SJohn Polstra.\" 5d3980376SJohn Polstra.\" Redistribution and use in source and binary forms, with or without 6d3980376SJohn Polstra.\" modification, are permitted provided that the following conditions 7d3980376SJohn Polstra.\" are met: 8d3980376SJohn Polstra.\" 1. Redistributions of source code must retain the above copyright 9d3980376SJohn Polstra.\" notice, this list of conditions and the following disclaimer. 10d3980376SJohn Polstra.\" 2. Redistributions in binary form must reproduce the above copyright 11d3980376SJohn Polstra.\" notice, this list of conditions and the following disclaimer in the 12d3980376SJohn Polstra.\" documentation and/or other materials provided with the distribution. 13d3980376SJohn Polstra.\" 14d3980376SJohn Polstra.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15d3980376SJohn Polstra.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16d3980376SJohn Polstra.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17d3980376SJohn Polstra.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18d3980376SJohn Polstra.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19d3980376SJohn Polstra.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20d3980376SJohn Polstra.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21d3980376SJohn Polstra.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22d3980376SJohn Polstra.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23d3980376SJohn Polstra.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24d3980376SJohn Polstra.\" SUCH DAMAGE. 25d3980376SJohn Polstra.\" 26d3980376SJohn Polstra.\" $FreeBSD$ 27d3980376SJohn Polstra.\" 2859a821daSJohn Polstra.Dd July 5, 2000 29a307d598SRuslan Ermilov.Os 30d3980376SJohn Polstra.Dt DLLOCKINIT 3 31d3980376SJohn Polstra.Sh NAME 32d3980376SJohn Polstra.Nm dllockinit 33d3980376SJohn Polstra.Nd register thread locking methods with the dynamic linker 3425bb73e0SAlexey Zelkin.Sh LIBRARY 3525bb73e0SAlexey Zelkin.Lb libc 36d3980376SJohn Polstra.Sh SYNOPSIS 3732eef9aeSRuslan Ermilov.In dlfcn.h 38d3980376SJohn Polstra.Ft void 39a37e09e4SBruce Evans.Fn dllockinit "void *context" "void *(*lock_create)(void *context)" "void (*rlock_acquire)(void *lock)" "void (*wlock_acquire)(void *lock)" "void (*lock_release)(void *lock)" "void (*lock_destroy)(void *lock)" "void (*context_destroy)(void *context)" 40d3980376SJohn Polstra.Sh DESCRIPTION 414e1635feSJohn Polstra.Bf Sy 4259a821daSJohn PolstraDue to enhancements in the dynamic linker, this interface is no longer 431a0a9345SRuslan Ermilovneeded. 441a0a9345SRuslan ErmilovIt is deprecated and will be removed from future releases. 4559a821daSJohn PolstraIn current releases it still exists, but only as a stub which does nothing. 464e1635feSJohn Polstra.Ef 474e1635feSJohn Polstra.Pp 48d3980376SJohn PolstraThreads packages can call 4995f4226bSRuslan Ermilov.Fn dllockinit 50d3980376SJohn Polstraat initialization time to register locking functions for the dynamic 511a0a9345SRuslan Ermilovlinker to use. 521a0a9345SRuslan ErmilovThis enables the dynamic linker to prevent multiple 53d3980376SJohn Polstrathreads from entering its critical sections simultaneously. 54d3980376SJohn Polstra.Pp 55d3980376SJohn PolstraThe 56d3980376SJohn Polstra.Fa context 571a0a9345SRuslan Ermilovargument specifies an opaque context for creating locks. 581a0a9345SRuslan ErmilovThe 59d3980376SJohn Polstradynamic linker will pass it to the 60d3980376SJohn Polstra.Fa lock_create 611a0a9345SRuslan Ermilovfunction when creating the locks it needs. 621a0a9345SRuslan ErmilovWhen the dynamic linker 63d3980376SJohn Polstrais permanently finished using the locking functions (e.g., if the 64d3980376SJohn Polstraprogram makes a subsequent call to 6595f4226bSRuslan Ermilov.Fn dllockinit 66d3980376SJohn Polstrato register new locking functions) it will call 67d3980376SJohn Polstra.Fa context_destroy 68d3980376SJohn Polstrato destroy the context. 69d3980376SJohn Polstra.Pp 70d3980376SJohn PolstraThe 71d3980376SJohn Polstra.Fa lock_create 721a0a9345SRuslan Ermilovargument specifies a function for creating a read/write lock. 731a0a9345SRuslan ErmilovIt 74d3980376SJohn Polstramust return a pointer to the new lock. 75d3980376SJohn Polstra.Pp 76d3980376SJohn PolstraThe 77d3980376SJohn Polstra.Fa rlock_acquire 78d3980376SJohn Polstraand 79d3980376SJohn Polstra.Fa wlock_acquire 802efeeba5SRuslan Ermilovarguments specify functions which lock a lock for reading or 811a0a9345SRuslan Ermilovwriting, respectively. 821a0a9345SRuslan ErmilovThe 83d3980376SJohn Polstra.Fa lock_release 841a0a9345SRuslan Ermilovargument specifies a function which unlocks a lock. 851a0a9345SRuslan ErmilovEach of these 86d3980376SJohn Polstrafunctions is passed a pointer to the lock. 87d3980376SJohn Polstra.Pp 88d3980376SJohn PolstraThe 89d3980376SJohn Polstra.Fa lock_destroy 901a0a9345SRuslan Ermilovargument specifies a function to destroy a lock. 911a0a9345SRuslan ErmilovIt may be 92d3980376SJohn Polstra.Dv NULL 931a0a9345SRuslan Ermilovif locks do not need to be destroyed. 941a0a9345SRuslan ErmilovThe 95d3980376SJohn Polstra.Fa context_destroy 961a0a9345SRuslan Ermilovargument specifies a function to destroy the context. 971a0a9345SRuslan ErmilovIt may be 98d3980376SJohn Polstra.Dv NULL 99d3980376SJohn Polstraif the context does not need to be destroyed. 100d3980376SJohn Polstra.Pp 1017f205788SJohn PolstraUntil 10295f4226bSRuslan Ermilov.Fn dllockinit 1037f205788SJohn Polstrais called, the dynamic linker protects its critical sections using 1047f205788SJohn Polstraa default locking mechanism which works by blocking the 105d3980376SJohn Polstra.Dv SIGVTALRM , 106d3980376SJohn Polstra.Dv SIGPROF , 107d3980376SJohn Polstraand 108d3980376SJohn Polstra.Dv SIGALRM 1091a0a9345SRuslan Ermilovsignals. 1101a0a9345SRuslan ErmilovThis is sufficient for many application level threads 111d3980376SJohn Polstrapackages, which typically use one of these signals to implement 1121a0a9345SRuslan Ermilovpreemption. 1131a0a9345SRuslan ErmilovAn application which has registered its own locking 114d3980376SJohn Polstramethods with 11595f4226bSRuslan Ermilov.Fn dllockinit 116d3980376SJohn Polstracan restore the default locking by calling 11795f4226bSRuslan Ermilov.Fn dllockinit 118d3980376SJohn Polstrawith all arguments 119d3980376SJohn Polstra.Dv NULL . 120d3980376SJohn Polstra.Sh SEE ALSO 121d3980376SJohn Polstra.Xr rtld 1 , 122d3980376SJohn Polstra.Xr signal 3 123d3980376SJohn Polstra.Sh HISTORY 124d3980376SJohn PolstraThe 12595f4226bSRuslan Ermilov.Fn dllockinit 126b5c508fbSRuslan Ermilovfunction first appeared in 127b5c508fbSRuslan Ermilov.Fx 4.0 . 128