1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
.\" $OpenBSD: CRYPTO_lock.3,v 1.1 2019/03/10 15:00:34 schwarze Exp $
.\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000
.\"
.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 10 2019 $
.Dt CRYPTO_LOCK 3
.Os
.Sh NAME
.Nm CRYPTO_THREADID_current ,
.Nm CRYPTO_THREADID_cmp ,
.Nm CRYPTO_THREADID_cpy ,
.Nm CRYPTO_THREADID_hash ,
.Nm CRYPTO_lock ,
.Nm CRYPTO_w_lock ,
.Nm CRYPTO_w_unlock ,
.Nm CRYPTO_r_lock ,
.Nm CRYPTO_r_unlock ,
.Nm CRYPTO_add
.Nd thread support
.Sh SYNOPSIS
.In openssl/crypto.h
.Ft void
.Fo CRYPTO_THREADID_current
.Fa "CRYPTO_THREADID *id"
.Fc
.Ft int
.Fo CRYPTO_THREADID_cmp
.Fa "const CRYPTO_THREADID *a"
.Fa "const CRYPTO_THREADID *b"
.Fc
.Ft void
.Fo CRYPTO_THREADID_cpy
.Fa "CRYPTO_THREADID *dest"
.Fa "const CRYPTO_THREADID *src"
.Fc
.Ft unsigned long
.Fo CRYPTO_THREADID_hash
.Fa "const CRYPTO_THREADID *id"
.Fc
.Ft void
.Fo CRYPTO_lock
.Fa "int mode"
.Fa "int type"
.Fa "const char *file"
.Fa "int line"
.Fc
.Ft int
.Fo CRYPTO_add
.Fa "int *p"
.Fa "int amount"
.Fa "int type"
.Fc
.Bd -literal
#define CRYPTO_w_lock(type) \e
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE, type, __FILE__, __LINE__)
#define CRYPTO_w_unlock(type) \e
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE, type, __FILE__, __LINE__)
#define CRYPTO_r_lock(type) \e
CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ, type, __FILE__, __LINE__)
#define CRYPTO_r_unlock(type) \e
CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ, type, __FILE__, __LINE__)
.Ed
.Sh DESCRIPTION
These functions are obsolete.
.Pp
.Fn CRYPTO_THREADID_current
stores a unique identifier of the currently executing thread
into the opaque object
.Fa id .
.Pp
.Fn CRYPTO_THREADID_cpy
copies the contents of
.Fa src
to
.Fa dest .
.Pp
.Fn CRYPTO_lock
locks or unlocks a mutex lock.
.Pp
.Fa mode
is a bitfield describing what should be done with the lock.
For each call, either
.Dv CRYPTO_LOCK
or
.Dv CRYPTO_UNLOCK
must be included.
In the LibreSSL implementation,
.Dv CRYPTO_READ
and
.Dv CRYPTO_WRITE
are ignored.
.Pp
.Fa type
is a number in the range 0 <=
.Fa type No < Dv CRYPTO_NUM_LOCKS
identifying a particular lock.
Currently, the value of
.Dv CRYPTO_NUM_LOCKS
is 41.
.Pp
The
.Ar file
and
.Ar line
arguments are ignored.
.Pp
In the LibreSSL implementation,
.Fn CRYPTO_lock
is a wrapper around
.Xr pthread_mutex_lock 3
and
.Xr pthread_mutex_unlock 3 .
.Pp
.Fn CRYPTO_add
locks the lock number
.Fa type ,
adds
.Fa amount
to
.Pf * Fa p ,
and unlocks the lock number
.Fa type
again.
.Sh RETURN VALUES
.Fn CRYPTO_THREADID_cmp
returns 0 if
.Fa a
and
.Fa b
refer to the same thread or a non-zero value otherwise.
.Pp
.Fn CRYPTO_THREADID_hash
returns a numeric value usable as a hash-table key.
In the LibreSSL implementation, it is the value returned from
.Xr pthread_self 3
for the thread
.Fa id .
.Pp
.Fn CRYPTO_add
returns the new value of
.Pf * Fa p .
.Sh SEE ALSO
.Xr crypto 3
.Sh HISTORY
.Fn CRYPTO_lock ,
.Fn CRYPTO_w_lock ,
.Fn CRYPTO_w_unlock ,
.Fn CRYPTO_r_lock ,
and
.Fn CRYPTO_r_unlock
first appeared in SSLeay 0.6.0.
.Fn CRYPTO_add
first appeared in SSLeay 0.6.2.
These functions have been available since
.Ox 2.4 .
.Pp
.Fn CRYPTO_THREADID_current ,
.Fn CRYPTO_THREADID_cmp ,
.Fn CRYPTO_THREADID_cpy ,
and
.Fn CRYPTO_THREADID_hash
first appeared in OpenSSL 1.0.0 and have been available since
.Ox 4.9 .
|