1.\" $OpenBSD: CRYPTO_lock.3,v 1.3 2024/03/14 22:09:40 tb Exp $ 2.\" OpenSSL doc/crypto/threads.pod fb552ac6 Sep 30 23:43:01 2009 +0000 3.\" 4.\" Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org> 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: March 14 2024 $ 19.Dt CRYPTO_LOCK 3 20.Os 21.Sh NAME 22.Nm CRYPTO_lock , 23.Nm CRYPTO_w_lock , 24.Nm CRYPTO_w_unlock , 25.Nm CRYPTO_r_lock , 26.Nm CRYPTO_r_unlock , 27.Nm CRYPTO_add 28.Nd thread support 29.Sh SYNOPSIS 30.In openssl/crypto.h 31.Ft void 32.Fo CRYPTO_lock 33.Fa "int mode" 34.Fa "int type" 35.Fa "const char *file" 36.Fa "int line" 37.Fc 38.Ft int 39.Fo CRYPTO_add 40.Fa "int *p" 41.Fa "int amount" 42.Fa "int type" 43.Fc 44.Bd -literal 45#define CRYPTO_w_lock(type) \e 46 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE, type, __FILE__, __LINE__) 47#define CRYPTO_w_unlock(type) \e 48 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE, type, __FILE__, __LINE__) 49#define CRYPTO_r_lock(type) \e 50 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ, type, __FILE__, __LINE__) 51#define CRYPTO_r_unlock(type) \e 52 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ, type, __FILE__, __LINE__) 53.Ed 54.Sh DESCRIPTION 55These functions are obsolete. 56.Pp 57.Fn CRYPTO_lock 58locks or unlocks a mutex lock. 59.Pp 60.Fa mode 61is a bitfield describing what should be done with the lock. 62For each call, either 63.Dv CRYPTO_LOCK 64or 65.Dv CRYPTO_UNLOCK 66must be included. 67In the LibreSSL implementation, 68.Dv CRYPTO_READ 69and 70.Dv CRYPTO_WRITE 71are ignored. 72.Pp 73.Fa type 74is a number in the range 0 <= 75.Fa type No < Dv CRYPTO_NUM_LOCKS 76identifying a particular lock. 77Currently, the value of 78.Dv CRYPTO_NUM_LOCKS 79is 41. 80.Pp 81The 82.Ar file 83and 84.Ar line 85arguments are ignored. 86.Pp 87In the LibreSSL implementation, 88.Fn CRYPTO_lock 89is a wrapper around 90.Xr pthread_mutex_lock 3 91and 92.Xr pthread_mutex_unlock 3 . 93.Pp 94.Fn CRYPTO_add 95locks the lock number 96.Fa type , 97adds 98.Fa amount 99to 100.Pf * Fa p , 101and unlocks the lock number 102.Fa type 103again. 104.Sh RETURN VALUES 105.Fn CRYPTO_add 106returns the new value of 107.Pf * Fa p . 108.Sh SEE ALSO 109.Xr crypto 3 110.Sh HISTORY 111.Fn CRYPTO_lock , 112.Fn CRYPTO_w_lock , 113.Fn CRYPTO_w_unlock , 114.Fn CRYPTO_r_lock , 115and 116.Fn CRYPTO_r_unlock 117first appeared in SSLeay 0.6.0. 118.Fn CRYPTO_add 119first appeared in SSLeay 0.6.2. 120These functions have been available since 121.Ox 2.4 . 122