[vlc-commits] [Git][videolan/vlc][master] 5 commits: contrib: nfs: use the UNPACK_DIR

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Dec 20 13:37:35 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
f360f3e7 by Steve Lhomme at 2024-12-20T13:06:19+00:00
contrib: nfs: use the UNPACK_DIR

Rather than moving files.

- - - - -
8672e890 by Steve Lhomme at 2024-12-20T13:06:19+00:00
contrib: nfs: update to 6.0.2

With the necessary patches to build for Windows.

- - - - -
a97a0c94 by Steve Lhomme at 2024-12-20T13:06:19+00:00
contrib: nfs: export the necessary library in the pkg-config file

- - - - -
bf03bd51 by Steve Lhomme at 2024-12-20T13:06:19+00:00
contrib: nfs: depend on gnutls

It is necessary on Linux and someday on BSD. We just enable it for everyone.

- - - - -
7ee26e6f by Steve Lhomme at 2024-12-20T13:06:19+00:00
contrib: nfs: disable if network is disabled in contribs

- - - - -


8 changed files:

- + contrib/src/nfs/0001-cant-have-win32.h-referenced-from-a-header-we-instal.patch
- + contrib/src/nfs/0001-cmake-export-the-necessary-library-in-the-pkg-config.patch
- + contrib/src/nfs/0002-pthread-and-win32-need-to-be-exclusive-in-multithrea.patch
- + contrib/src/nfs/0003-win32-define-struct-timezone-for-non-mingw-w32.patch
- + contrib/src/nfs/0004-win32-fix-build-with-MSVC.patch
- + contrib/src/nfs/0005-win32-don-t-use-pthread-on-Windows.patch
- contrib/src/nfs/SHA512SUMS
- contrib/src/nfs/rules.mak


Changes:

=====================================
contrib/src/nfs/0001-cant-have-win32.h-referenced-from-a-header-we-instal.patch
=====================================
@@ -0,0 +1,28 @@
+From b713ca0fb7272b5a22d86ad0e823dbc40cc22a59 Mon Sep 17 00:00:00 2001
+From: Ronnie Sahlberg <ronniesahlberg at gmail.com>
+Date: Mon, 16 Dec 2024 18:49:59 +1000
+Subject: [PATCH 1/5] cant have win32.h referenced from a header we install
+
+Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
+---
+ include/nfsc/libnfs-raw.h | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/include/nfsc/libnfs-raw.h b/include/nfsc/libnfs-raw.h
+index 80d31f4..0bd88a2 100644
+--- a/include/nfsc/libnfs-raw.h
++++ b/include/nfsc/libnfs-raw.h
+@@ -39,10 +39,6 @@
+ #include "ps3_compat.h"
+ #endif
+ 
+-#ifdef WIN32
+-#include <win32/win32_compat.h>
+-#endif
+-
+ #include <stdint.h>
+ 
+ #if defined(HAVE_SYS_UIO_H) || (defined(__APPLE__) && defined(__MACH__))
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/nfs/0001-cmake-export-the-necessary-library-in-the-pkg-config.patch
=====================================
@@ -0,0 +1,44 @@
+From c6b70a429e7022fb5da88d3344ae8da55a761b41 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 16 Dec 2024 11:46:16 +0100
+Subject: [PATCH] cmake: export the necessary library in the pkg-config file
+
+That includes gnutls on Linux if it's used.
+---
+ CMakeLists.txt        | 8 ++++++++
+ cmake/libnfs.pc.cmake | 2 +-
+ 2 files changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1b94d2e..86e0845 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -155,6 +155,14 @@ install(FILES cmake/FindNFS.cmake
+         DESTINATION ${INSTALL_CMAKE_DIR})
+ 
+ # handle pc-config files
++set(PKG_LIBLIST "")
++foreach(LIB ${SYSTEM_LIBRARIES})
++  if(IS_ABSOLUTE ${LIB} AND EXISTS ${LIB})
++    list(APPEND PKG_LIBLIST "${LIB}")
++  else()
++    list(APPEND PKG_LIBLIST "-l${LIB}")
++  endif()
++endforeach()
+ configure_file(cmake/libnfs.pc.cmake
+                ${CMAKE_CURRENT_BINARY_DIR}/libnfs.pc @ONLY)
+ 
+diff --git a/cmake/libnfs.pc.cmake b/cmake/libnfs.pc.cmake
+index 8a4e11e..783c2e3 100644
+--- a/cmake/libnfs.pc.cmake
++++ b/cmake/libnfs.pc.cmake
+@@ -10,5 +10,5 @@ Description: libnfs is a client library for accessing NFS shares over a network.
+ Version: @PROJECT_VERSION@
+ Requires:
+ Conflicts:
+-Libs: -L${libdir} -lnfs
++Libs: -L${libdir} -lnfs @PKG_LIBLIST@
+ Cflags: -I${includedir}
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/nfs/0002-pthread-and-win32-need-to-be-exclusive-in-multithrea.patch
=====================================
@@ -0,0 +1,268 @@
+From 9d67b60f6ea777264b9b0db46a90e7c0a52d428c Mon Sep 17 00:00:00 2001
+From: Ronnie Sahlberg <ronniesahlberg at gmail.com>
+Date: Mon, 16 Dec 2024 19:01:06 +1000
+Subject: [PATCH 2/5] pthread and win32 need to be exclusive in multithread.c
+
+Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
+---
+ lib/multithreading.c | 238 +++++++++++++++++++++----------------------
+ 1 file changed, 118 insertions(+), 120 deletions(-)
+
+diff --git a/lib/multithreading.c b/lib/multithreading.c
+index b04cd5b..2dc4177 100644
+--- a/lib/multithreading.c
++++ b/lib/multithreading.c
+@@ -54,7 +54,124 @@
+ 
+ #ifdef HAVE_MULTITHREADING
+ 
+-#ifdef HAVE_PTHREAD
++#ifdef WIN32
++nfs_tid_t nfs_mt_get_tid(void)
++{
++    return GetCurrentThreadId();
++}
++static void* nfs_mt_service_thread(void* arg)
++{
++    struct nfs_context* nfs = (struct nfs_context*)arg;
++    struct pollfd pfd;
++    int revents;
++    int ret;
++
++    nfs->rpc->multithreading_enabled = 1;
++
++    while (nfs->rpc->multithreading_enabled) {
++        pfd.fd = nfs_get_fd(nfs);
++        pfd.events = nfs_which_events(nfs);
++        pfd.revents = 0;
++
++        ret = poll(&pfd, 1, 0);
++        if (ret < 0) {
++            nfs_set_error(nfs, "Poll failed");
++            revents = -1;
++        }
++        else {
++            revents = pfd.revents;
++        }
++        if (nfs_service(nfs, revents) < 0) {
++            if (revents != -1)
++                nfs_set_error(nfs, "nfs_service failed");
++        }
++    }
++    return NULL;
++}
++
++static DWORD WINAPI service_thread_init(LPVOID lpParam)
++{
++    HANDLE hStdout;
++    struct nfs_context* nfs;
++
++    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
++    if (hStdout == INVALID_HANDLE_VALUE) {
++        return 1;
++    }
++    nfs = (struct nfs_context *)lpParam;
++    nfs_mt_service_thread(nfs);
++    return 0;
++}
++
++int nfs_mt_service_thread_start(struct nfs_context* nfs)
++{
++    nfs->nfsi->service_thread = CreateThread(NULL, 1024*1024, service_thread_init, nfs, 0, NULL);
++    if (nfs->nfsi->service_thread == NULL) {
++        nfs_set_error(nfs, "Failed to start service thread");
++        return -1;
++    }
++    while (nfs->rpc->multithreading_enabled == 0) {
++        Sleep(100);
++    }
++    return 0;
++}
++
++void nfs_mt_service_thread_stop(struct nfs_context* nfs)
++{
++    nfs->rpc->multithreading_enabled = 0;
++    while (WaitForSingleObject(nfs->nfsi->service_thread, INFINITE) != WAIT_OBJECT_0);
++}
++
++int nfs_mt_mutex_init(libnfs_mutex_t* mutex)
++{
++    *mutex = CreateSemaphoreA(NULL, 1, 1, NULL);
++    return 0;
++}
++
++int nfs_mt_mutex_destroy(libnfs_mutex_t* mutex)
++{
++    CloseHandle(*mutex);
++    return 0;
++}
++
++int nfs_mt_mutex_lock(libnfs_mutex_t* mutex)
++{
++    while (WaitForSingleObject(*mutex, INFINITE) != WAIT_OBJECT_0);
++    return 0;
++}
++
++int nfs_mt_mutex_unlock(libnfs_mutex_t* mutex)
++{
++    ReleaseSemaphore(*mutex, 1, NULL);
++    return 0;
++}
++
++int nfs_mt_sem_init(libnfs_sem_t* sem, int value)
++{
++    *sem = CreateSemaphoreA(NULL, 0, 16, NULL);
++    return 0;
++}
++
++int nfs_mt_sem_destroy(libnfs_sem_t* sem)
++{
++    CloseHandle(*sem);
++    return 0;
++}
++
++int nfs_mt_sem_post(libnfs_sem_t* sem)
++{
++    ReleaseSemaphore(*sem, 1, NULL);
++    return 0;
++}
++
++int nfs_mt_sem_wait(libnfs_sem_t* sem)
++{
++    while (WaitForSingleObject(*sem, INFINITE) != WAIT_OBJECT_0);
++    return 0;
++}
++
++#elif HAVE_PTHREAD /* WIN32 */
++
+ #include <unistd.h>
+ #include <sys/syscall.h>
+ 
+@@ -226,124 +343,5 @@ int nfs_mt_sem_wait(libnfs_sem_t *sem)
+ 
+ #endif /* HAVE_PTHREAD */
+ 
+-#ifdef WIN32
+-nfs_tid_t nfs_mt_get_tid(void)
+-{
+-    return GetCurrentThreadId();
+-}
+-static void* nfs_mt_service_thread(void* arg)
+-{
+-    struct nfs_context* nfs = (struct nfs_context*)arg;
+-    struct pollfd pfd;
+-    int revents;
+-    int ret;
+-
+-    nfs->rpc->multithreading_enabled = 1;
+-
+-    while (nfs->rpc->multithreading_enabled) {
+-        pfd.fd = nfs_get_fd(nfs);
+-        pfd.events = nfs_which_events(nfs);
+-        pfd.revents = 0;
+-
+-        ret = poll(&pfd, 1, 0);
+-        if (ret < 0) {
+-            nfs_set_error(nfs, "Poll failed");
+-            revents = -1;
+-        }
+-        else {
+-            revents = pfd.revents;
+-        }
+-        if (nfs_service(nfs, revents) < 0) {
+-            if (revents != -1)
+-                nfs_set_error(nfs, "nfs_service failed");
+-        }
+-    }
+-    return NULL;
+-}
+-
+-static DWORD WINAPI service_thread_init(LPVOID lpParam)
+-{
+-    HANDLE hStdout;
+-    struct nfs_context* nfs;
+-
+-    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+-    if (hStdout == INVALID_HANDLE_VALUE) {
+-        return 1;
+-    }
+-    nfs = (struct nfs_context *)lpParam;
+-    nfs_mt_service_thread(nfs);
+-    return 0;
+-}
+-
+-int nfs_mt_service_thread_start(struct nfs_context* nfs)
+-{
+-    nfs->nfsi->service_thread = CreateThread(NULL, 1024*1024, service_thread_init, nfs, 0, NULL);
+-    if (nfs->nfsi->service_thread == NULL) {
+-        nfs_set_error(nfs, "Failed to start service thread");
+-        return -1;
+-    }
+-    while (nfs->rpc->multithreading_enabled == 0) {
+-        Sleep(100);
+-    }
+-    return 0;
+-}
+-
+-void nfs_mt_service_thread_stop(struct nfs_context* nfs)
+-{
+-    nfs->rpc->multithreading_enabled = 0;
+-    while (WaitForSingleObject(nfs->nfsi->service_thread, INFINITE) != WAIT_OBJECT_0);
+-}
+-
+-int nfs_mt_mutex_init(libnfs_mutex_t* mutex)
+-{
+-    *mutex = CreateSemaphoreA(NULL, 1, 1, NULL);
+-    return 0;
+-}
+-
+-int nfs_mt_mutex_destroy(libnfs_mutex_t* mutex)
+-{
+-    CloseHandle(*mutex);
+-    return 0;
+-}
+-
+-int nfs_mt_mutex_lock(libnfs_mutex_t* mutex)
+-{
+-    while (WaitForSingleObject(*mutex, INFINITE) != WAIT_OBJECT_0);
+-    return 0;
+-}
+-
+-int nfs_mt_mutex_unlock(libnfs_mutex_t* mutex)
+-{
+-    ReleaseSemaphore(*mutex, 1, NULL);
+-    return 0;
+-}
+-
+-int nfs_mt_sem_init(libnfs_sem_t* sem, int value)
+-{
+-    *sem = CreateSemaphoreA(NULL, 0, 16, NULL);
+-    return 0;
+-}
+-
+-int nfs_mt_sem_destroy(libnfs_sem_t* sem)
+-{
+-    CloseHandle(*sem);
+-    return 0;
+-}
+-
+-int nfs_mt_sem_post(libnfs_sem_t* sem)
+-{
+-    ReleaseSemaphore(*sem, 1, NULL);
+-    return 0;
+-}
+-
+-int nfs_mt_sem_wait(libnfs_sem_t* sem)
+-{
+-    while (WaitForSingleObject(*sem, INFINITE) != WAIT_OBJECT_0);
+-    return 0;
+-}
+-
+-#endif /* WIN32 */
+-
+-
+ #endif /* HAVE_MULTITHREADING */
+ 
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/nfs/0003-win32-define-struct-timezone-for-non-mingw-w32.patch
=====================================
@@ -0,0 +1,53 @@
+From 42e0694555f80ed93ff2013580d805fa1d928ff7 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 16 Dec 2024 10:01:27 +0100
+Subject: [PATCH 3/5] win32: define struct timezone for non-mingw-w32
+
+The compiler complains if the structure used in the .c file is defined after an
+anonymous version was used in the header.
+---
+ include/win32/win32_compat.h | 8 +++++++-
+ win32/win32_compat.c         | 6 ------
+ 2 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/include/win32/win32_compat.h b/include/win32/win32_compat.h
+index 70214b7..e11bf70 100755
+--- a/include/win32/win32_compat.h
++++ b/include/win32/win32_compat.h
+@@ -150,9 +150,15 @@ struct pollfd {
+ int     getpid(void);
+ int     win32_inet_pton(int af, const char * src, void * dst);
+ int     win32_poll(struct pollfd *fds, unsigned int nfsd, int timeout);
+-int     win32_gettimeofday(struct timeval *tv, struct timezone *tz);
+ #ifdef __MINGW32__
+ # define win32_gettimeofday mingw_gettimeofday
++#else
++struct timezone
++{
++  int  tz_minuteswest; /* minutes W of Greenwich */
++  int  tz_dsttime;     /* type of dst correction */
++};
++int     win32_gettimeofday(struct timeval *tv, struct timezone *tz);
+ #endif
+ 
+ #define DllExport
+diff --git a/win32/win32_compat.c b/win32/win32_compat.c
+index 3654788..fb5f0aa 100644
+--- a/win32/win32_compat.c
++++ b/win32/win32_compat.c
+@@ -157,12 +157,6 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
+ #endif
+  
+ #ifndef __MINGW32__
+-struct timezone 
+-{
+-  int  tz_minuteswest; /* minutes W of Greenwich */
+-  int  tz_dsttime;     /* type of dst correction */
+-};
+- 
+ int win32_gettimeofday(struct timeval *tv, struct timezone *tz)
+ {
+   FILETIME ft;
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/nfs/0004-win32-fix-build-with-MSVC.patch
=====================================
@@ -0,0 +1,42 @@
+From 7f4d51641ae8383d51779f104ae4f7ba121b75f6 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 16 Dec 2024 10:06:20 +0100
+Subject: [PATCH 4/5] win32: fix build with MSVC
+
+strndup doesn't exist, but there's a compat version for that.
+---
+ include/win32/win32_compat.h | 2 +-
+ lib/nfs_v4.c                 | 4 ++++
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/include/win32/win32_compat.h b/include/win32/win32_compat.h
+index e11bf70..09f8eb1 100755
+--- a/include/win32/win32_compat.h
++++ b/include/win32/win32_compat.h
+@@ -163,7 +163,7 @@ int     win32_gettimeofday(struct timeval *tv, struct timezone *tz);
+ 
+ #define DllExport
+ 
+-#ifdef __MINGW32__
++#if defined(__MINGW32__) || defined(_MSC_VER)
+ char* libnfs_strndup(const char *s, size_t n);
+ #define strndup libnfs_strndup
+ #endif
+diff --git a/lib/nfs_v4.c b/lib/nfs_v4.c
+index 31d89d7..dbbea95 100644
+--- a/lib/nfs_v4.c
++++ b/lib/nfs_v4.c
+@@ -88,6 +88,10 @@
+ #include <pwd.h>
+ #endif
+ 
++#ifdef WIN32
++#include <win32/win32_compat.h>
++#endif
++
+ #include <ctype.h>
+ #include <stdio.h>
+ #include <stdarg.h>
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/nfs/0005-win32-don-t-use-pthread-on-Windows.patch
=====================================
@@ -0,0 +1,49 @@
+From e540715f492e7cb13cf811838327f54831832389 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 16 Dec 2024 10:12:01 +0100
+Subject: [PATCH 5/5] win32: don't use pthread on Windows
+
+mingw-w64 has winpthread which is detected as available. But on Windows
+there is custom threading code to use. We should only use one of them.
+And the win32 API doesn't require an extra -lpthread to link.
+
+Fixes #506
+---
+ include/libnfs-multithreading.h | 14 ++++++--------
+ 1 file changed, 6 insertions(+), 8 deletions(-)
+
+diff --git a/include/libnfs-multithreading.h b/include/libnfs-multithreading.h
+index e3caa97..305ad95 100644
+--- a/include/libnfs-multithreading.h
++++ b/include/libnfs-multithreading.h
+@@ -29,7 +29,12 @@ extern "C" {
+ 
+ #ifdef HAVE_MULTITHREADING
+ 
+-#ifdef HAVE_PTHREAD
++#ifdef WIN32
++typedef HANDLE libnfs_thread_t;
++typedef HANDLE libnfs_mutex_t;
++typedef HANDLE libnfs_sem_t;
++typedef DWORD nfs_tid_t;
++#elif defined(HAVE_PTHREAD)
+ #include <pthread.h>
+ typedef pthread_t libnfs_thread_t;
+ typedef pthread_mutex_t libnfs_mutex_t;
+@@ -48,13 +53,6 @@ typedef pid_t nfs_tid_t;
+ #endif
+ #endif /* HAVE_PTHREAD */
+ 
+-#ifdef WIN32
+-typedef HANDLE libnfs_thread_t;
+-typedef HANDLE libnfs_mutex_t;
+-typedef HANDLE libnfs_sem_t;
+-typedef DWORD nfs_tid_t;
+-#endif
+-
+ nfs_tid_t nfs_mt_get_tid(void);
+ int nfs_mt_mutex_init(libnfs_mutex_t *mutex);
+ int nfs_mt_mutex_destroy(libnfs_mutex_t *mutex);
+-- 
+2.45.0.windows.1
+


=====================================
contrib/src/nfs/SHA512SUMS
=====================================
@@ -1 +1 @@
-6dcf4ea8a01b35beb53694625d20fbebd858a88725c2742671878ad6fe7877999f93d262fb58a435b00c283c3e6fb6fa7222d04bb4540bf674b7ce196e9424f5  libnfs-5.0.2.tar.gz
+539790ab98aac7b2f25755b745d1f5e016518f1adb3748b8c58df187048bc31e091915d59e6359bb95c49dd986361cbbf2536edcda02598b0fac236762b61a46  libnfs-6.0.2.tar.gz


=====================================
contrib/src/nfs/rules.mak
=====================================
@@ -1,20 +1,32 @@
 # NFS
-NFS_VERSION := 5.0.2
+NFS_VERSION := 6.0.2
 NFS_URL := $(GITHUB)/sahlberg/libnfs/archive/libnfs-$(NFS_VERSION).tar.gz
 
+ifdef BUILD_NETWORK
 PKGS += nfs
 ifeq ($(call need_pkg,"libnfs >= 1.10"),)
 PKGS_FOUND += nfs
 endif
+endif
+
+ifneq ($(findstring gnutls,$(PKGS)),)
+DEPS_nfs = gnutls $(DEPS_gnutls)
+endif
 
 $(TARBALLS)/libnfs-$(NFS_VERSION).tar.gz:
 	$(call download_pkg,$(NFS_URL),nfs)
 
 .sum-nfs: libnfs-$(NFS_VERSION).tar.gz
 
+nfs: UNPACK_DIR=libnfs-libnfs-$(NFS_VERSION)
 nfs: libnfs-$(NFS_VERSION).tar.gz .sum-nfs
 	$(UNPACK)
-	mv libnfs-libnfs-$(NFS_VERSION) libnfs-$(NFS_VERSION)
+	$(APPLY) $(SRC)/nfs/0001-cant-have-win32.h-referenced-from-a-header-we-instal.patch
+	$(APPLY) $(SRC)/nfs/0002-pthread-and-win32-need-to-be-exclusive-in-multithrea.patch
+	$(APPLY) $(SRC)/nfs/0003-win32-define-struct-timezone-for-non-mingw-w32.patch
+	$(APPLY) $(SRC)/nfs/0004-win32-fix-build-with-MSVC.patch
+	$(APPLY) $(SRC)/nfs/0005-win32-don-t-use-pthread-on-Windows.patch
+	$(APPLY) $(SRC)/nfs/0001-cmake-export-the-necessary-library-in-the-pkg-config.patch
 	$(MOVE)
 
 .nfs: nfs toolchain.cmake



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f2379a0e276597efdfe7a6aa970fb0f9ae21fbc3...7ee26e6fa72ce6b4dab5ad5d7ad4c31a3e036133

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f2379a0e276597efdfe7a6aa970fb0f9ae21fbc3...7ee26e6fa72ce6b4dab5ad5d7ad4c31a3e036133
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list