From 674f2f6f52341ae7260365de9ff78e3d1b4b7631 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Cerveau?= Date: Mon, 19 Jun 2023 17:12:22 +0200 Subject: [PATCH] wrap: add libpsl patch to fix win build These patches are necessary for Windows build since 0.21.2 See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4890 Part-of: --- subprojects/libpsl.wrap | 1 + .../0001-tools-psl.c-Fix-build-on-Windows.patch | 32 +++++++++++++++ ...tools-psl.c-Fix-logic-fallout-and-warning.patch | 46 ++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 subprojects/packagefiles/libpsl-0.21.2/0001-tools-psl.c-Fix-build-on-Windows.patch create mode 100644 subprojects/packagefiles/libpsl-0.21.2/0002-tools-psl.c-Fix-logic-fallout-and-warning.patch diff --git a/subprojects/libpsl.wrap b/subprojects/libpsl.wrap index de7b077..99bcf3e 100644 --- a/subprojects/libpsl.wrap +++ b/subprojects/libpsl.wrap @@ -3,3 +3,4 @@ directory=libpsl url=https://github.com/rockdaboot/libpsl.git revision=0.21.2 clone-recursive=true +diff_files = libpsl-0.21.2/0001-tools-psl.c-Fix-build-on-Windows.patch, libpsl-0.21.2/0002-tools-psl.c-Fix-logic-fallout-and-warning.patch \ No newline at end of file diff --git a/subprojects/packagefiles/libpsl-0.21.2/0001-tools-psl.c-Fix-build-on-Windows.patch b/subprojects/packagefiles/libpsl-0.21.2/0001-tools-psl.c-Fix-build-on-Windows.patch new file mode 100644 index 0000000..2e1ce11 --- /dev/null +++ b/subprojects/packagefiles/libpsl-0.21.2/0001-tools-psl.c-Fix-build-on-Windows.patch @@ -0,0 +1,32 @@ +From c47cf796fcf98641cb34929d17de041b26c54447 Mon Sep 17 00:00:00 2001 +From: Chun-wei Fan +Date: Tue, 27 Dec 2022 12:57:04 +0800 +Subject: [PATCH 1/9] tools/psl.c: Fix build on Windows + +localtime_r() is not available on Windows but a more-secure variant +of localtime(), localtime_s() is provided on Windows. + +Define localtime_r() on Windows as its arguments are reversed as compared +to localetime_s(), to achive more or less the same purpose. +--- + tools/psl.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/tools/psl.c b/tools/psl.c +index 95d8b65..054d0b6 100644 +--- a/tools/psl.c ++++ b/tools/psl.c +@@ -38,6 +38,10 @@ + + #ifdef _WIN32 + # include // WSAStartup, WSACleanup ++ ++// Windows does not have localtime_r but has localtime_s, which is more or less ++// the same except that the arguments are reversed ++# define localtime_r(t_sec,t_now) localtime_s(t_now,t_sec) + #endif + + #include +-- +2.34.1 + diff --git a/subprojects/packagefiles/libpsl-0.21.2/0002-tools-psl.c-Fix-logic-fallout-and-warning.patch b/subprojects/packagefiles/libpsl-0.21.2/0002-tools-psl.c-Fix-logic-fallout-and-warning.patch new file mode 100644 index 0000000..7a3e70c --- /dev/null +++ b/subprojects/packagefiles/libpsl-0.21.2/0002-tools-psl.c-Fix-logic-fallout-and-warning.patch @@ -0,0 +1,46 @@ +From 3dfe19d4578c361f800738c9c974d9c405801209 Mon Sep 17 00:00:00 2001 +From: Chun-wei Fan +Date: Mon, 16 Jan 2023 11:17:04 +0800 +Subject: [PATCH 1/7] tools/psl.c: Fix logic fallout and warning + +In the previous update to tools/psl.c, I neglected to see the return type of +localtime_s() and the difference in what value to expect for a successful call. + +Use macros instead to remedy this. + +Thanks to vtorri for pointing this out in issue #201. + +Fixes: #201. +--- + tools/psl.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/tools/psl.c b/tools/psl.c +index 054d0b6..ed94d5c 100644 +--- a/tools/psl.c ++++ b/tools/psl.c +@@ -41,7 +41,11 @@ + + // Windows does not have localtime_r but has localtime_s, which is more or less + // the same except that the arguments are reversed +-# define localtime_r(t_sec,t_now) localtime_s(t_now,t_sec) ++# define LOCALTIME_R_SUCCESSFUL(t_sec,t_now) \ ++ (localtime_s(t_now, t_sec) == 0) ++#else ++# define LOCALTIME_R_SUCCESSFUL(t_sec,t_now) \ ++ (localtime_r(t_sec, t_now) != NULL) + #endif + + #include +@@ -94,7 +98,7 @@ static const char *time2str(time_t t) + static char buf[64]; + struct tm tm; + +- if (localtime_r(&t, &tm) != NULL) ++ if (LOCALTIME_R_SUCCESSFUL(&t, &tm)) + strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", &tm); + else + strcpy(buf, "--notime--"); +-- +2.34.1 + -- 2.7.4