[vlc-devel] [PATCH] contrib: dav1d: backport upstream patch fixing posix_memalign usage

Steve Lhomme robux4 at ycbcr.xyz
Sat May 30 08:35:31 CEST 2020


posix_memalign is defined as a built-in in gcc in msys2 but it's not available
when linking with the Universal C Runtime. _aligned_malloc is available in the
UCRT.
---
 ...-_aligned_malloc-over-posix_memalign.patch | 36 +++++++++++++++++++
 contrib/src/dav1d/rules.mak                   |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 contrib/src/dav1d/0001-meson-favor-_aligned_malloc-over-posix_memalign.patch

diff --git a/contrib/src/dav1d/0001-meson-favor-_aligned_malloc-over-posix_memalign.patch b/contrib/src/dav1d/0001-meson-favor-_aligned_malloc-over-posix_memalign.patch
new file mode 100644
index 000000000000..29bbf23cb5cb
--- /dev/null
+++ b/contrib/src/dav1d/0001-meson-favor-_aligned_malloc-over-posix_memalign.patch
@@ -0,0 +1,36 @@
+From ed39e8fb63bcdb837e3f131140d2d73d02095ca1 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at videolan.org>
+Date: Thu, 28 May 2020 10:55:24 +0200
+Subject: [PATCH] meson: favor _aligned_malloc over posix_memalign
+
+posix_memalign is defined as a built-in in gcc in msys2 but it's not available
+when linking with the Universal C Runtime. _aligned_malloc is available in the
+UCRT.
+
+That should only affect builds targeting Windows since _aligned_malloc is a MS
+thing.
+---
+ meson.build | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 65bea09..25f037f 100644
+--- a/meson.build
++++ b/meson.build
+@@ -196,10 +196,10 @@ else
+     getopt_dependency = []
+ endif
+ 
+-if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>', args : test_args)
+-    cdata.set('HAVE_POSIX_MEMALIGN', 1)
+-elif cc.has_function('_aligned_malloc', prefix : '#include <malloc.h>', args : test_args)
++if cc.has_function('_aligned_malloc', prefix : '#include <malloc.h>', args : test_args)
+     cdata.set('HAVE_ALIGNED_MALLOC', 1)
++elif cc.has_function('posix_memalign', prefix : '#include <stdlib.h>', args : test_args)
++    cdata.set('HAVE_POSIX_MEMALIGN', 1)
+ elif cc.has_function('memalign', prefix : '#include <malloc.h>', args : test_args)
+     cdata.set('HAVE_MEMALIGN', 1)
+ endif
+-- 
+2.26.0.windows.1
+
diff --git a/contrib/src/dav1d/rules.mak b/contrib/src/dav1d/rules.mak
index 3239f1b734f5..66c538b784dc 100644
--- a/contrib/src/dav1d/rules.mak
+++ b/contrib/src/dav1d/rules.mak
@@ -21,6 +21,7 @@ $(TARBALLS)/dav1d-$(DAV1D_VERSION).tar.xz:
 
 dav1d: dav1d-$(DAV1D_VERSION).tar.xz .sum-dav1d
 	$(UNPACK)
+	$(APPLY) $(SRC)/dav1d/0001-meson-favor-_aligned_malloc-over-posix_memalign.patch
 	$(MOVE)
 
 .dav1d: dav1d crossfile.meson
-- 
2.26.2



More information about the vlc-devel mailing list