[vlc-commits] [Git][videolan/vlc][3.0.x] 5 commits: contrib: upnp: Add a patch to avoid implicit declarations of gettimeofday on mingw

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Sat May 7 10:55:44 UTC 2022



Hugo Beauzée-Luyssen pushed to branch 3.0.x at VideoLAN / VLC


Commits:
89006bde by Martin Storsjö at 2022-05-06T09:30:34+03:00
contrib: upnp: Add a patch to avoid implicit declarations of gettimeofday on mingw

This patch has been sent upstream at
https://github.com/pupnp/pupnp/pull/387, but hasn't been acted
on by upstream yet.

In mingw headers, both time.h and sys/time.h define
struct timezone and _TIMEZONE_DEFINED - however only one of them,
sys/time.h, define gettimeofday. Thus, if time.h had been included
before, we'd have _TIMEZONE_DEFINED defined, and we'd omit our own
declaration of the gettimeofday function too, leading to calls to
an undeclared function.

(If the actual sys/time.h header is included, its declaration of
the gettimeofday function does conflict with both the declaration
and the definition of upnp's gettimeofday, due to details like missing
the restrict attribute on pointers. But that issue already existed
and is unaffected by this patch.)

Since Clang 15 (which still is under development, so this may
still change before it's released) [1], implicit function
declarations are a hard error by default, when building code
in C99 mode (or newer).

[1] https://github.com/llvm/llvm-project/commit/7d644e1215b376ec5e915df9ea2eeb56e2d94626

(cherry picked from commit 83d7194d0115dce40ec49830d092fdcb1e3f6f16)

- - - - -
a0517308 by Martin Storsjö at 2022-05-06T09:30:34+03:00
contrib: libshout: Apply a patch to avoid implicit declarations of gettimeofday

This patch has been sent upstream at
https://gitlab.xiph.org/xiph/icecast-common/-/merge_requests/2
but hasn't been acted upon there yet.

When building for a mingw target, HAVE_GETTIMEOFDAY is defined
(as the gettimeofday function was found), but the #ifdef _WIN32 #else
block never tried to include <sys/time.h> (which provides the
declaration) and/or <time.h> for such targets. This caused
gettimeofday to be used without a prior declaration.

This has been visible as an easily overlooked warning, but Clang 15
changed this into a fatal error by default, when building in C99
mode (or newer). [1] (While Clang 15 still is under development, this
may still change before it's released, but the warning is valid
in any case.)

Decouple including of those headers from the #ifdef _WIN32 #else
block and just check their corresponding availability defines.

[1] https://github.com/llvm/llvm-project/commit/7d644e1215b376ec5e915df9ea2eeb56e2d94626

(cherry picked from commit 9e095923da9faf63bbb4ccf4ed40f455aadefb1c)

- - - - -
8260294a by Martin Storsjö at 2022-05-06T09:30:34+03:00
contrib: zvbi: Add a custom patch to avoid implicit declarations of functions on Windows

Since Clang 15 (which still is under development, so this may
still change before it's released) [1], implicit function
declarations are a hard error by default, when building code
in C99 mode (or newer).

[1] https://github.com/llvm/llvm-project/commit/7d644e1215b376ec5e915df9ea2eeb56e2d94626

The upstream zvbi code doesn't seem to have any support for
building for Windows at all, therefore not trying to upstream it.

On Windows, the <io.h> header is needed for getting declarations
of functions like open/read/write/close. The zvbi project has a
header of its own, named io.h, and it resides on a path added with
-I, so any includes of <io.h> ends up including this header instead
of the system header. Therefore, add an #include_next <io.h> which
should bring in the system header and its declarations too.

Adjust ifdefs to ifdef out larger bits of the code that contained
calls to functions that simply don't exist on Windows, like
ioctl, munmap etc. Previously, the zvbi library has been built with
implicit declarations of those functions, and the static library has
had undefined references to them. As long as those object files
from the static library haven't been included in the link, this issue
has been unnoticed so far.

For the function ffs(), which also was undefined on Windows,
provide a _BitScanForward based reimplementation. This also resides
in a file that doesn't end up included in the end, but for this
case it's just as easy to provide a working implementation as it
would be to ifdef it out.

(cherry picked from commit 68efd7e558d19fb177991e9e0f0739defcaf9014)

- - - - -
7a321fcf by Martin Storsjö at 2022-05-06T09:30:34+03:00
contrib: regex: Apply a patch to add missing function declarations

This code seems to be a stale copy of a regex library from glibc,
thus not sending the patch further upstream.

In some configurations, this library seems to choose not to include
standard C headers but declare the functions manually (without a
proper prototype though!). In this case, it already declared malloc
and realloc, but didn't declare abort and free in the same way.

Just add declarations of these functions in the same way - while
the most correct path forward would be to actually make it use
the proper system headers.

(cherry picked from commit 0e836b4eb2b05c8e130b73dcce8c53ac8397466f)

- - - - -
4622e243 by Martin Storsjö at 2022-05-06T09:30:34+03:00
contrib: projectM: Apply a patch to add missing includes of <functional>

This source file in projectM uses std::bind2nd, which is declared
in the <functional> header. Previously it relied on this header
being included implicitly.

libc++ recently stopped including <functional> transitively in
<algorithm> in
https://github.com/llvm/llvm-project/commit/a83f4b9cda57c5b3d414ec3bcf9ac891b2ec27e1.

Upstream projectM stopped using std::bind2nd in this file in
https://github.com/projectM-visualizer/projectm/commit/10faca9abf4c879a63cdf426ddae338620baf238
- thus not trying to upstream the patch.

(cherry picked from commit 3c181d46d74498f50fa0c18234010dda078ebe02)

- - - - -


10 changed files:

- + contrib/src/projectM/missing-includes.patch
- contrib/src/projectM/rules.mak
- + contrib/src/regex/decls.patch
- contrib/src/regex/rules.mak
- contrib/src/shout/rules.mak
- + contrib/src/shout/win32-gettimeofday.patch
- contrib/src/upnp/rules.mak
- + contrib/src/upnp/win32-gettimeofday.patch
- contrib/src/zvbi/rules.mak
- + contrib/src/zvbi/zvbi-win32-undefined.patch


Changes:

=====================================
contrib/src/projectM/missing-includes.patch
=====================================
@@ -0,0 +1,10 @@
+--- projectM/Renderer/Waveform.cpp.orig	2022-04-27 10:54:35.706616587 +0300
++++ projectM/Renderer/Waveform.cpp	2022-04-27 10:54:43.374663065 +0300
+@@ -17,6 +17,7 @@
+ 
+ #include "Waveform.hpp"
+ #include <algorithm>
++#include <functional>
+ #include "BeatDetect.hpp"
+ 
+ Waveform::Waveform(int samples)


=====================================
contrib/src/projectM/rules.mak
=====================================
@@ -28,6 +28,7 @@ ifdef HAVE_WIN32
 endif
 	$(APPLY) $(SRC)/projectM/gcc6.patch
 	$(APPLY) $(SRC)/projectM/clang6.patch
+	$(APPLY) $(SRC)/projectM/missing-includes.patch
 	$(MOVE)
 
 DEPS_projectM = glew $(DEPS_glew)


=====================================
contrib/src/regex/decls.patch
=====================================
@@ -0,0 +1,11 @@
+--- regex/regex.c.orig	2022-04-21 17:46:06.786845467 +0300
++++ regex/regex.c	2022-04-21 16:46:41.670051683 +0300
+@@ -127,6 +127,8 @@
+ #  else
+ char *malloc ();
+ char *realloc ();
++void abort ();
++void free ();
+ #  endif
+ 
+ /* When used in Emacs's lib-src, we need to get bzero and bcopy somehow..


=====================================
contrib/src/regex/rules.mak
=====================================
@@ -15,6 +15,7 @@ $(TARBALLS)/regex-$(REGEX_VERSION).tar.gz:
 regex: regex-$(REGEX_VERSION).tar.gz .sum-regex
 	$(UNPACK)
 	$(APPLY) $(SRC)/regex/no-docs.patch
+	$(APPLY) $(SRC)/regex/decls.patch
 	$(MOVE)
 
 .regex: regex


=====================================
contrib/src/shout/rules.mak
=====================================
@@ -29,6 +29,7 @@ libshout: libshout-$(SHOUT_VERSION).tar.gz .sum-shout
 	$(APPLY) $(SRC)/shout/no-examples.patch
 	$(APPLY) $(SRC)/shout/no-force-libwsock.patch
 	$(APPLY) $(SRC)/shout/should-win32-ws2tcpip.patch
+	$(APPLY) $(SRC)/shout/win32-gettimeofday.patch
 	$(call pkg_static,"shout.pc.in")
 	$(UPDATE_AUTOCONFIG)
 	$(MOVE)


=====================================
contrib/src/shout/win32-gettimeofday.patch
=====================================
@@ -0,0 +1,22 @@
+--- libshout/src/common/timing/timing.c.orig	2022-04-21 15:00:39.729501137 +0300
++++ libshout/src/common/timing/timing.c	2022-04-21 15:00:43.565527749 +0300
+@@ -37,6 +37,9 @@
+ #include <mmsystem.h>
+ #include <winsock2.h>
+ #else
++#include <unistd.h>
++#endif
++
+ #ifdef TIME_WITH_SYS_TIME
+ #  include <sys/time.h>
+ #  include <time.h>
+@@ -48,9 +51,6 @@
+ #  endif
+ #endif
+ 
+-#include <unistd.h>
+-#endif
+-
+ #ifdef HAVE_SYS_SELECT_H
+ #include <sys/select.h>
+ #endif


=====================================
contrib/src/upnp/rules.mak
=====================================
@@ -38,6 +38,7 @@ ifdef HAVE_WIN32
 	$(APPLY) $(SRC)/upnp/libupnp-win32.patch
 	$(APPLY) $(SRC)/upnp/libupnp-win64.patch
 	$(APPLY) $(SRC)/upnp/windows-version-inet.patch
+	$(APPLY) $(SRC)/upnp/win32-gettimeofday.patch
 endif
 ifdef HAVE_LINUX
 ifndef HAVE_ANDROID


=====================================
contrib/src/upnp/win32-gettimeofday.patch
=====================================
@@ -0,0 +1,12 @@
+--- upnp/upnp/src/threadutil/ThreadPool.h.orig	2022-04-21 15:07:27.194156972 +0300
++++ upnp/upnp/src/threadutil/ThreadPool.h	2022-04-21 15:07:31.026076222 +0300
+@@ -54,8 +54,8 @@
+ 			int  tz_minuteswest; /* minutes W of Greenwich */
+ 			int  tz_dsttime;     /* type of dst correction */
+ 		};
+-		int gettimeofday(struct timeval *tv, struct timezone *tz);
+ 	#endif
++	int gettimeofday(struct timeval *tv, struct timezone *tz);
+ #else /* _WIN32 */
+ 	#include <sys/param.h>
+ 	#include <sys/time.h> /* for gettimeofday() */


=====================================
contrib/src/zvbi/rules.mak
=====================================
@@ -20,6 +20,7 @@ zvbi: zvbi-$(ZVBI_VERSION).tar.bz2 .sum-zvbi
 	$(APPLY) $(SRC)/zvbi/zvbi-fix-static-linking.patch
 ifdef HAVE_WIN32
 	$(APPLY) $(SRC)/zvbi/zvbi-win32.patch
+	$(APPLY) $(SRC)/zvbi/zvbi-win32-undefined.patch
 endif
 	$(APPLY) $(SRC)/zvbi/zvbi-fix-clang-support.patch
 ifdef HAVE_ANDROID


=====================================
contrib/src/zvbi/zvbi-win32-undefined.patch
=====================================
@@ -0,0 +1,88 @@
+--- zvbi/src/io.h.orig	2022-04-27 13:12:22.154124296 +0300
++++ zvbi/src/io.h	2022-04-27 13:12:54.706349113 +0300
+@@ -28,6 +28,12 @@
+ #include "decoder.h"
+ #include "bit_slicer.h"
+ 
++#if defined(_WIN32) && defined(__has_include_next)
++# if __has_include_next(<io.h>)
++#  include_next <io.h>
++# endif
++#endif
++
+ /* Public */
+ 
+ #include <sys/time.h> /* struct timeval */
+--- zvbi/src/io.c.orig	2022-04-21 14:52:30.294105422 +0300
++++ zvbi/src/io.c	2022-04-21 14:39:26.424663785 +0300
+@@ -556,7 +556,6 @@
+ 		return ret;
+ 	}
+ }
+-#endif
+ /* Helper functions to log the communication between the library and drivers.
+    FIXME remove fp arg, call user log function instead (0.3). */
+ 
+@@ -777,7 +776,6 @@
+ 	return err;
+ }
+ 
+-#ifndef _WIN32
+ /**
+  * @internal
+  * Drop-in for mmap(). Logs the request on fp if not NULL.
+@@ -827,7 +825,7 @@
+ 
+ 	return r;
+ }
+-#endif
++
+ /**
+  * @internal
+  * Drop-in for munmap(). Logs the request on fp if not NULL.
+@@ -860,6 +858,7 @@
+ 
+ 	return r;
+ }
++#endif
+ 
+ /*
+ Local variables:
+--- zvbi/src/page_table.c.orig	2022-04-21 14:52:22.018047995 +0300
++++ zvbi/src/page_table.c	2022-04-21 14:48:38.224494983 +0300
+@@ -35,6 +35,17 @@
+ #include "misc.h"
+ #include "page_table.h"
+ 
++#ifdef _WIN32
++#include <intrin.h>
++static inline int ffs(int value) {
++	unsigned long index;
++	if (value == 0)
++		return 0;
++	_BitScanForward(&index, value);
++	return index + 1;
++}
++#endif
++
+ /**
+  * addtogroup PageTable Teletext Page Number Table
+  * ingroup LowDec
+--- zvbi/src/pdc.c.orig	2022-04-21 14:52:12.297980549 +0300
++++ zvbi/src/pdc.c	2022-04-21 14:51:40.529760109 +0300
+@@ -35,6 +35,7 @@
+ #include "pdc.h"
+ #include "conv.h"
+ 
++#ifndef _WIN32
+ /**
+  * @addtogroup ProgramID VPS/PDC Program ID
+  * @ingroup LowDec
+@@ -1460,6 +1461,7 @@
+ 		}
+ 	}
+ }
++#endif
+ 
+ /*
+ Local variables:



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2baf4b09f71ca0455e8844f3cd2804877cecd73a...4622e243a37208c23be5084862d73e67476feb9d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2baf4b09f71ca0455e8844f3cd2804877cecd73a...4622e243a37208c23be5084862d73e67476feb9d
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