xref: /freebsd/lib/libc/gen/dllockinit.3 (revision 2efeeba554cbd7bdee9cfe17641c8bd335c7972f)
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
4359a821daSJohn Polstraneeded.  It is deprecated and will be removed from future releases.
4459a821daSJohn PolstraIn current releases it still exists, but only as a stub which does nothing.
454e1635feSJohn Polstra.Ef
464e1635feSJohn Polstra.Pp
47d3980376SJohn PolstraThreads packages can call
4895f4226bSRuslan Ermilov.Fn dllockinit
49d3980376SJohn Polstraat initialization time to register locking functions for the dynamic
50d3980376SJohn Polstralinker to use.  This enables the dynamic linker to prevent multiple
51d3980376SJohn Polstrathreads from entering its critical sections simultaneously.
52d3980376SJohn Polstra.Pp
53d3980376SJohn PolstraThe
54d3980376SJohn Polstra.Fa context
552efeeba5SRuslan Ermilovargument specifies an opaque context for creating locks.  The
56d3980376SJohn Polstradynamic linker will pass it to the
57d3980376SJohn Polstra.Fa lock_create
58d3980376SJohn Polstrafunction when creating the locks it needs.  When the dynamic linker
59d3980376SJohn Polstrais permanently finished using the locking functions (e.g., if the
60d3980376SJohn Polstraprogram makes a subsequent call to
6195f4226bSRuslan Ermilov.Fn dllockinit
62d3980376SJohn Polstrato register new locking functions) it will call
63d3980376SJohn Polstra.Fa context_destroy
64d3980376SJohn Polstrato destroy the context.
65d3980376SJohn Polstra.Pp
66d3980376SJohn PolstraThe
67d3980376SJohn Polstra.Fa lock_create
682efeeba5SRuslan Ermilovargument specifies a function for creating a read/write lock.  It
69d3980376SJohn Polstramust return a pointer to the new lock.
70d3980376SJohn Polstra.Pp
71d3980376SJohn PolstraThe
72d3980376SJohn Polstra.Fa rlock_acquire
73d3980376SJohn Polstraand
74d3980376SJohn Polstra.Fa wlock_acquire
752efeeba5SRuslan Ermilovarguments specify functions which lock a lock for reading or
76d3980376SJohn Polstrawriting, respectively.  The
77d3980376SJohn Polstra.Fa lock_release
782efeeba5SRuslan Ermilovargument specifies a function which unlocks a lock.  Each of these
79d3980376SJohn Polstrafunctions is passed a pointer to the lock.
80d3980376SJohn Polstra.Pp
81d3980376SJohn PolstraThe
82d3980376SJohn Polstra.Fa lock_destroy
832efeeba5SRuslan Ermilovargument specifies a function to destroy a lock.  It may be
84d3980376SJohn Polstra.Dv NULL
85d3980376SJohn Polstraif locks do not need to be destroyed.  The
86d3980376SJohn Polstra.Fa context_destroy
872efeeba5SRuslan Ermilovargument specifies a function to destroy the context.  It may be
88d3980376SJohn Polstra.Dv NULL
89d3980376SJohn Polstraif the context does not need to be destroyed.
90d3980376SJohn Polstra.Pp
917f205788SJohn PolstraUntil
9295f4226bSRuslan Ermilov.Fn dllockinit
937f205788SJohn Polstrais called, the dynamic linker protects its critical sections using
947f205788SJohn Polstraa default locking mechanism which works by blocking the
95d3980376SJohn Polstra.Dv SIGVTALRM ,
96d3980376SJohn Polstra.Dv SIGPROF ,
97d3980376SJohn Polstraand
98d3980376SJohn Polstra.Dv SIGALRM
99d3980376SJohn Polstrasignals.  This is sufficient for many application level threads
100d3980376SJohn Polstrapackages, which typically use one of these signals to implement
101d3980376SJohn Polstrapreemption.  An application which has registered its own locking
102d3980376SJohn Polstramethods with
10395f4226bSRuslan Ermilov.Fn dllockinit
104d3980376SJohn Polstracan restore the default locking by calling
10595f4226bSRuslan Ermilov.Fn dllockinit
106d3980376SJohn Polstrawith all arguments
107d3980376SJohn Polstra.Dv NULL .
108d3980376SJohn Polstra.Sh SEE ALSO
109d3980376SJohn Polstra.Xr rtld 1 ,
110d3980376SJohn Polstra.Xr signal 3
111d3980376SJohn Polstra.Sh HISTORY
112d3980376SJohn PolstraThe
11395f4226bSRuslan Ermilov.Fn dllockinit
114b5c508fbSRuslan Ermilovfunction first appeared in
115b5c508fbSRuslan Ermilov.Fx 4.0 .
116