nbdkit/0005-common-include-test-once.c-Further-fixes-for-pthread.patch
Richard W.M. Jones ca4b55ce0a Further rebase along 1.44 branch.
- New nbdkit-count-filter.
- Remove nbdkit-cacheextents-filter.
- file: trim: Don't try BLKDISCARD if earlier FALLOC_FL_PUNCH_HOLE worked

related: RHEL-101180
2025-07-09 16:32:21 +01:00

58 lines
1.9 KiB
Diff

From f694d06d432d10699e26b2234f7a285fc018e94c Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 9 Jul 2025 12:20:34 +0100
Subject: [PATCH] common/include/test-once.c: Further fixes for
pthread_barrier_t
macOS defines _POSIX_BARRIERS but turns out to lack any implementation
of pthread_barrier_t. WTF.
FreeBSD requires linking with pthread else we get:
ld: error: undefined symbol: pthread_barrier_init
Fixes: commit ad8630deab4639e636212f11a5a47d2c34ef2949
Fixes: commit 8271f9244f1521c716460820d8162e7641018674
(cherry picked from commit 0d0e2b3d49cf8c9aa8cd37bb36b7002eb4624a2c)
---
common/include/Makefile.am | 3 ++-
common/include/test-once.c | 7 +++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/common/include/Makefile.am b/common/include/Makefile.am
index 3a3757e2..00a01091 100644
--- a/common/include/Makefile.am
+++ b/common/include/Makefile.am
@@ -124,7 +124,8 @@ test_nextnonzero_CFLAGS = $(WARNINGS_CFLAGS)
test_once_SOURCES = test-once.c once.h
test_once_CPPFLAGS = -I$(srcdir)
-test_once_CFLAGS = $(WARNINGS_CFLAGS)
+test_once_CFLAGS = $(WARNINGS_CFLAGS) $(PTHREAD_CFLAGS)
+test_once_LDFLAGS = $(PTHREAD_LIBS)
test_random_SOURCES = test-random.c random.h
test_random_CPPFLAGS = -I$(srcdir)
diff --git a/common/include/test-once.c b/common/include/test-once.c
index 512b1a20..304d512a 100644
--- a/common/include/test-once.c
+++ b/common/include/test-once.c
@@ -37,9 +37,12 @@
#include <unistd.h>
#include <pthread.h>
-#if !defined(HAVE_STDATOMIC_H) || !defined(_POSIX_BARRIERS)
+#if !defined(HAVE_STDATOMIC_H) || !defined(_POSIX_BARRIERS) || \
+ defined(__APPLE__)
-/* Skip the test if no <stdatomic.h> or pthread_barrier_t */
+/* Skip the test if no <stdatomic.h> or pthread_barrier_t or on macOS
+ * which defines _POSIX_BARRIERS but doesn't actually have them.
+ */
int
main (void)
--
2.47.1