From aca7b842282f2f180ff497072079a9c40556f6fc Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Thu, 26 Oct 2023 18:43:26 +1300
Subject: [PATCH 3/3] Use futex-based semaphores on macOS.

---
 meson.build         |  2 ++
 src/template/darwin | 13 +------------
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/meson.build b/meson.build
index 5c9775f1a6e..0e713f65a66 100644
--- a/meson.build
+++ b/meson.build
@@ -205,6 +205,8 @@ if host_system == 'cygwin'
   mod_link_with_dir = 'libdir'
 
 elif host_system == 'darwin'
+  sema_kind = 'futex'
+
   dlsuffix = '.dylib'
   library_path_var = 'DYLD_LIBRARY_PATH'
 
diff --git a/src/template/darwin b/src/template/darwin
index e8eb9390687..d3c78805401 100644
--- a/src/template/darwin
+++ b/src/template/darwin
@@ -14,17 +14,6 @@ fi
 # Extra CFLAGS for code that will go into a shared library
 CFLAGS_SL=""
 
-# Select appropriate semaphore support.  Darwin 6.0 (macOS 10.2) and up
-# support System V semaphores; before that we have to use named POSIX
-# semaphores, which are less good for our purposes because they eat a
-# file descriptor per backend per max_connection slot.
-case $host_os in
-  darwin[015].*)
-    USE_NAMED_POSIX_SEMAPHORES=1
-    ;;
-  *)
-    USE_SYSV_SEMAPHORES=1
-    ;;
-esac
+USE_FUTEX_SEMAPHORES=1
 
 DLSUFFIX=".dylib"
-- 
2.47.1

