From 9e095923da9faf63bbb4ccf4ed40f455aadefb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 21 Apr 2022 15:02:07 +0300 Subject: [PATCH] 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 (which provides the declaration) and/or 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 --- contrib/src/shout/rules.mak | 1 + contrib/src/shout/win32-gettimeofday.patch | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 contrib/src/shout/win32-gettimeofday.patch diff --git a/contrib/src/shout/rules.mak b/contrib/src/shout/rules.mak index 76d73c5b42..2b74bddbfb 100644 --- a/contrib/src/shout/rules.mak +++ b/contrib/src/shout/rules.mak @@ -28,6 +28,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) diff --git a/contrib/src/shout/win32-gettimeofday.patch b/contrib/src/shout/win32-gettimeofday.patch new file mode 100644 index 0000000000..ff31183da7 --- /dev/null +++ b/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 + #include + #else ++#include ++#endif ++ + #ifdef TIME_WITH_SYS_TIME + # include + # include +@@ -48,9 +51,6 @@ + # endif + #endif + +-#include +-#endif +- + #ifdef HAVE_SYS_SELECT_H + #include + #endif