Start removing the old build infrastructure for the a.out
[dragonfly.git] / lib / libc / gen / dllockinit.3
1 .\"
2 .\" Copyright (c) 1999, 2000 John D. Polstra
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/lib/libc/gen/dllockinit.3,v 1.5.2.7 2003/03/15 15:11:05 trhodes Exp $
27 .\" $DragonFly: src/lib/libc/gen/Attic/dllockinit.3,v 1.2 2003/06/17 04:26:42 dillon Exp $
28 .\"
29 .Dd July 5, 2000
30 .Os
31 .Dt DLLOCKINIT 3
32 .Sh NAME
33 .Nm dllockinit
34 .Nd register thread locking methods with the dynamic linker
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In dlfcn.h
39 .Ft void
40 .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)"
41 .Sh DESCRIPTION
42 .Bf Sy
43 Due to enhancements in the dynamic linker, this interface is no longer
44 needed.  It is deprecated and will be removed from future releases.
45 In current releases it still exists, but only as a stub which does nothing.
46 .Ef
47 .Pp
48 Threads packages can call
49 .Fn dllockinit
50 at initialization time to register locking functions for the dynamic
51 linker to use.  This enables the dynamic linker to prevent multiple
52 threads from entering its critical sections simultaneously.
53 .Pp
54 The
55 .Fa context
56 argument specifies an opaque context for creating locks.  The
57 dynamic linker will pass it to the
58 .Fa lock_create
59 function when creating the locks it needs.  When the dynamic linker
60 is permanently finished using the locking functions (e.g., if the
61 program makes a subsequent call to
62 .Fn dllockinit
63 to register new locking functions) it will call
64 .Fa context_destroy
65 to destroy the context.
66 .Pp
67 The
68 .Fa lock_create
69 argument specifies a function for creating a read/write lock.  It
70 must return a pointer to the new lock.
71 .Pp
72 The
73 .Fa rlock_acquire
74 and
75 .Fa wlock_acquire
76 arguments specify functions which lock a lock for reading or
77 writing, respectively.  The
78 .Fa lock_release
79 argument specifies a function which unlocks a lock.  Each of these
80 functions is passed a pointer to the lock.
81 .Pp
82 The
83 .Fa lock_destroy
84 argument specifies a function to destroy a lock.  It may be
85 .Dv NULL
86 if locks do not need to be destroyed.  The
87 .Fa context_destroy
88 argument specifies a function to destroy the context.  It may be
89 .Dv NULL
90 if the context does not need to be destroyed.
91 .Pp
92 Until
93 .Fn dllockinit
94 is called, the dynamic linker protects its critical sections using
95 a default locking mechanism which works by blocking the
96 .Dv SIGVTALRM ,
97 .Dv SIGPROF ,
98 and
99 .Dv SIGALRM
100 signals.  This is sufficient for many application level threads
101 packages, which typically use one of these signals to implement
102 preemption.  An application which has registered its own locking
103 methods with
104 .Fn dllockinit
105 can restore the default locking by calling
106 .Fn dllockinit
107 with all arguments
108 .Dv NULL .
109 .Sh SEE ALSO
110 .Xr rtld 1 ,
111 .Xr signal 3
112 .Sh HISTORY
113 The
114 .Fn dllockinit
115 function first appeared in
116 .Fx 4.0 .