gnunet-fuse: Fix compile with glibc
authorHauke Mehrtens <redacted>
Mon, 15 Aug 2022 11:41:31 +0000 (13:41 +0200)
committerRosen Penev <redacted>
Thu, 25 Aug 2022 07:37:54 +0000 (00:37 -0700)
Always use pthread_mutexattr_settype() the
pthread_mutexattr_setkind_np() function is not available in the
glibc and musl version used by OpenWrt.

This fixes the following compile error:
arc-openwrt-linux-gnu/bin/ld: gnunet_fuse-mutex.o: in function `GNUNET_mutex_create':
mutex.c:(.text+0x14): undefined reference to `pthread_mutexattr_setkind_np'
arc-openwrt-linux-gnu/bin/ld: mutex.c:(.text+0x14): undefined reference to `pthread_mutexattr_setkind_np'
arc-openwrt-linux-gnu/bin/ld: mutex.c:(.text+0x76): undefined reference to `pthread_mutexattr_setkind_np'
arc-openwrt-linux-gnu/bin/ld: mutex.c:(.text+0x76): undefined reference to `pthread_mutexattr_setkind_np'
collect2: error: ld returned 1 exit status

This patch was taken from:
https://aur.archlinux.org/cgit/aur.git/plain/pthread_mutexattr_settype.patch?h=gnunet-fuse

Signed-off-by: Hauke Mehrtens <redacted>
net/gnunet-fuse/patches/001-musl-compat.patch [deleted file]
net/gnunet-fuse/patches/001-pthread_mutexattr_settype.patch [new file with mode: 0644]

diff --git a/net/gnunet-fuse/patches/001-musl-compat.patch b/net/gnunet-fuse/patches/001-musl-compat.patch
deleted file mode 100644 (file)
index 5b5b912..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/src/fuse/mutex.c
-+++ b/src/fuse/mutex.c
-@@ -68,8 +68,13 @@ GNUNET_mutex_create (int isRecursive)
-   if (isRecursive)
-     {
- #ifdef __linux__
-+#if defined(__UCLIBC__) || defined(__GLIBC__)
-       GNUNET_assert (0 == pthread_mutexattr_setkind_np
-                    (&attr, PTHREAD_MUTEX_RECURSIVE_NP));
-+#else
-+      GNUNET_assert (0 == pthread_mutexattr_settype
-+                   (&attr, PTHREAD_MUTEX_RECURSIVE));
-+#endif
- #elif BSD || SOLARIS || OSX || WINDOWS
-       GNUNET_assert (0 == pthread_mutexattr_settype
-                    (&attr, PTHREAD_MUTEX_RECURSIVE));
-@@ -78,11 +83,16 @@ GNUNET_mutex_create (int isRecursive)
-   else
-     {
- #ifdef __linux__
-+#if defined(__UCLIBC__) || defined(__GLIBC__)
-       GNUNET_assert (0 == pthread_mutexattr_setkind_np
-                    (&attr, PTHREAD_MUTEX_ERRORCHECK_NP));
- #else
-       GNUNET_assert (0 == pthread_mutexattr_settype
-                    (&attr, PTHREAD_MUTEX_ERRORCHECK));
-+#endif
-+#else
-+      GNUNET_assert (0 == pthread_mutexattr_settype
-+                   (&attr, PTHREAD_MUTEX_ERRORCHECK));
- #endif
-     }
-   mut = GNUNET_new (struct GNUNET_Mutex);
diff --git a/net/gnunet-fuse/patches/001-pthread_mutexattr_settype.patch b/net/gnunet-fuse/patches/001-pthread_mutexattr_settype.patch
new file mode 100644 (file)
index 0000000..4c9eba5
--- /dev/null
@@ -0,0 +1,50 @@
+Always use pthread_mutexattr_settype() the 
+pthread_mutexattr_setkind_np() is not available in the glibc and musl 
+version used by OpenWrt.
+
+This patch was taken from:
+https://aur.archlinux.org/cgit/aur.git/plain/pthread_mutexattr_settype.patch?h=gnunet-fuse
+
+--- a/src/fuse/mutex.c
++++ b/src/fuse/mutex.c
+@@ -35,16 +35,6 @@
+ #endif
+ #endif
+-/**
+- * This prototype is somehow missing in various Linux pthread
+- * include files. But we need it and it seems to be available
+- * on all pthread-systems so far. Odd.
+- */
+-#ifndef _MSC_VER
+-extern int pthread_mutexattr_setkind_np (pthread_mutexattr_t * attr,
+-                                         int kind);
+-#endif
+-
+ /**
+  * @brief Structure for MUTual EXclusion (Mutex).
+@@ -67,23 +57,13 @@ GNUNET_mutex_create (int isRecursive)
+   pthread_mutexattr_init (&attr);
+   if (isRecursive)
+     {
+-#ifdef __linux__
+-      GNUNET_assert (0 == pthread_mutexattr_setkind_np
+-                   (&attr, PTHREAD_MUTEX_RECURSIVE_NP));
+-#elif BSD || SOLARIS || OSX || WINDOWS
+       GNUNET_assert (0 == pthread_mutexattr_settype
+                    (&attr, PTHREAD_MUTEX_RECURSIVE));
+-#endif
+     }
+   else
+     {
+-#ifdef __linux__
+-      GNUNET_assert (0 == pthread_mutexattr_setkind_np
+-                   (&attr, PTHREAD_MUTEX_ERRORCHECK_NP));
+-#else
+       GNUNET_assert (0 == pthread_mutexattr_settype
+                    (&attr, PTHREAD_MUTEX_ERRORCHECK));
+-#endif
+     }
+   mut = GNUNET_new (struct GNUNET_Mutex);
+   GNUNET_assert (0 == pthread_mutex_init (&mut->pt, &attr));
git clone https://git.99rst.org/PROJECT