Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / db / darwin-mutexes-4.8.patch
blob09d5b814f16191b916ed9618df43dd0f5a859679
1 diff -ur a/dist/aclocal/mutex.m4 b/dist/aclocal/mutex.m4
2 --- a/dist/aclocal/mutex.m4 1969-12-31 19:00:01.000000000 -0500
3 +++ b/dist/aclocal/mutex.m4 2023-06-05 19:14:47.214158196 -0400
4 @@ -372,10 +376,11 @@
6 # _spin_lock_try/_spin_unlock: Apple/Darwin
7 if test "$db_cv_mutex" = no; then
8 -AC_TRY_LINK(,[
9 - int x;
10 - _spin_lock_try(&x);
11 - _spin_unlock(&x);
12 +AC_TRY_LINK([
13 +#include <os/lock.h>],[
14 + os_unfair_lock x = OS_UNFAIR_LOCK_INIT;
15 + bool _ = os_unfair_lock_trylock(&x);
16 + os_unfair_lock_unlock(&x);
17 ], [db_cv_mutex=Darwin/_spin_lock_try])
20 diff -ur a/dbinc/mutex_int.h b/dbinc/mutex_int.h
21 --- a/dbinc/mutex_int.h 1969-12-31 19:00:01.000000000 -0500
22 +++ b/dbinc/mutex_int.h 2023-06-05 19:15:37.510514745 -0400
23 @@ -154,14 +154,13 @@
24 * Apple/Darwin library functions.
25 *********************************************************************/
26 #ifdef HAVE_MUTEX_DARWIN_SPIN_LOCK_TRY
27 -typedef u_int32_t tsl_t;
28 +#include <os/lock.h>
29 +typedef os_unfair_lock tsl_t;
31 #ifdef LOAD_ACTUAL_MUTEX_CODE
32 -extern int _spin_lock_try(tsl_t *);
33 -extern void _spin_unlock(tsl_t *);
34 -#define MUTEX_SET(tsl) _spin_lock_try(tsl)
35 -#define MUTEX_UNSET(tsl) _spin_unlock(tsl)
36 -#define MUTEX_INIT(tsl) (MUTEX_UNSET(tsl), 0)
37 +#define MUTEX_SET(tsl) os_unfair_lock_trylock(tsl)
38 +#define MUTEX_UNSET(tsl) os_unfair_lock_unlock(tsl)
39 +#define MUTEX_INIT(tsl) ({ *(tsl) = OS_UNFAIR_LOCK_INIT; tsl; })
40 #endif
41 #endif
43 diff -ur a/dbinc/mutex_int.h b/dbinc/mutex_int.h
44 --- a/dbinc_auto/mutex_ext.h 1969-12-31 19:00:01.000000000 -0500
45 +++ b/dbinc_auto/mutex_ext.h 2023-07-01 22:38:20.749201366 -0400
46 @@ -34,6 +34,9 @@
47 #if !defined(HAVE_ATOMIC_SUPPORT) && defined(HAVE_MUTEX_SUPPORT)
48 atomic_value_t __atomic_dec __P((ENV *, db_atomic_t *));
49 #endif
50 +#if !defined(HAVE_ATOMIC_SUPPORT) && defined(HAVE_MUTEX_SUPPORT)
51 +int atomic_compare_exchange __P((ENV *, db_atomic_t *, atomic_value_t, atomic_value_t));
52 +#endif
53 int __db_pthread_mutex_init __P((ENV *, db_mutex_t, u_int32_t));
54 int __db_pthread_mutex_lock __P((ENV *, db_mutex_t));
55 #if defined(HAVE_SHARED_LATCHES)